Skip to content

Commit

Permalink
fix: csm motion input validation and encode
Browse files Browse the repository at this point in the history
  • Loading branch information
katamarinaki committed Sep 13, 2024
1 parent 65197c5 commit 42ef80d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export function DescCSMSettleElStealingPenalty({
<>
Settle (confirm) EL Rewards Stealing penalty for the following CSM{' '}
{pluralize(callData.length, 'operator')}:
{callData.map(item => {
{callData.map((item, index) => {
const nodeOperatorId = item.toNumber()

return <div key={nodeOperatorId}>NO #{nodeOperatorId}</div>
return <div key={index}>NO #{nodeOperatorId}</div>
})}
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const formParts = createMotionFormPart({

<Fieldset>
<InputNumberControl
name={`${fieldNames.nodeOperators}.${fieldIndex}.nodeOperatorId`}
name={`${fieldNames.nodeOperators}.${fieldIndex}.id`}
label="Node operator ID"
rules={{
required: 'Field is required',
Expand All @@ -129,6 +129,15 @@ export const formParts = createMotionFormPart({
return 'Invalid node operator ID'
}

const isAlreadyInInput = selectedNodeOperators.some(
({ id }, index) =>
id === value && index !== fieldIndex,
)

if (isAlreadyInInput) {
return 'This ID is already in the list'
}

return true
},
}}
Expand Down

0 comments on commit 42ef80d

Please sign in to comment.