Skip to content

Commit 70af1a9

Browse files
authored
Fix validation (#198)
1 parent fb58ca6 commit 70af1a9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/DatacapAmountModel.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ const DatacapAmountModal = ({
8888
},
8989
[setAllocationConfig],
9090
)
91-
const isAllocationAmountValid =
91+
const isAllocationAmountInvalid =
9292
!allocationConfig.amount || allocationConfig.amount === '0'
93-
const isEarlyRefillCommentValid =
93+
const isEarlyRefillCommentNotNeeded =
94+
allocationConfig.earlyRefillComment === undefined &&
95+
usedDatatapInPercentage >= 75
96+
const isEarlyRefillCommentInvalid =
9497
allocationConfig.earlyRefillComment !== undefined &&
95-
allocationConfig.earlyRefillComment.length < 10 &&
98+
allocationConfig?.earlyRefillComment?.length < 10 &&
9699
usedDatatapInPercentage < 75
97100
const isSubmitDisabled =
98-
isApiCalling || isAllocationAmountValid || isEarlyRefillCommentValid
99-
101+
isApiCalling ||
102+
isAllocationAmountInvalid ||
103+
(isEarlyRefillCommentInvalid && !isEarlyRefillCommentNotNeeded)
100104
return (
101105
<Dialog open={allocationConfig.isDialogOpen} onClose={onClose} fullWidth>
102106
<DialogTitle>{title}</DialogTitle>

0 commit comments

Comments
 (0)