Skip to content

Commit

Permalink
fix: not allow input negative values for votes
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest authored and ctrlc03 committed Aug 30, 2024
1 parent 0b6f148 commit 678260b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const AllocationInput = ({
{...props}
render={({ field }) => (
<NumericFormat
allowNegative={false}
aria-label="allocation-input"
customInput={Input}
error={props.error}
Expand All @@ -38,7 +39,7 @@ export const AllocationInput = ({
defaultValue={props.defaultValue as string}
disabled={props.disabled}
isAllowed={({ floatValue }) =>
votingMaxProject !== undefined ? (floatValue ?? 0) <= votingMaxProject : true
votingMaxProject !== undefined ? (floatValue ?? 0) <= votingMaxProject : (floatValue ?? 0) >= 0
}
thousandSeparator=","
onBlur={onBlur}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ export const VotingWidget = ({ projectId }: IVotingWidgetProps): JSX.Element =>

<div className="flex items-center justify-center gap-5 rounded-xl border border-gray-200 p-5 dark:border-gray-800">
<NumericFormat
allowNegative={false}
aria-label="allocation-input"
autoComplete="off"
className="dark:bg-lightBlack w-auto dark:text-white"
customInput={Input}
defaultValue={amount}
isAllowed={({ floatValue }) => (floatValue ?? 0) <= initialVoiceCredits}
isAllowed={({ floatValue }) => (floatValue ?? 0) <= initialVoiceCredits && (floatValue ?? 0) >= 0}
thousandSeparator=","
onChange={handleInput}
/>
Expand Down

0 comments on commit 678260b

Please sign in to comment.