From 8412c243082c5909be1dff7241c8b9c7e9e03da4 Mon Sep 17 00:00:00 2001 From: Filip-L Date: Thu, 29 May 2025 12:20:41 +0200 Subject: [PATCH] Fix validation --- src/components/DatacapAmountModel.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/DatacapAmountModel.tsx b/src/components/DatacapAmountModel.tsx index 5e37d7b..1923f83 100644 --- a/src/components/DatacapAmountModel.tsx +++ b/src/components/DatacapAmountModel.tsx @@ -88,15 +88,19 @@ const DatacapAmountModal = ({ }, [setAllocationConfig], ) - const isAllocationAmountValid = + const isAllocationAmountInvalid = !allocationConfig.amount || allocationConfig.amount === '0' - const isEarlyRefillCommentValid = + const isEarlyRefillCommentNotNeeded = + allocationConfig.earlyRefillComment === undefined && + usedDatatapInPercentage >= 75 + const isEarlyRefillCommentInvalid = allocationConfig.earlyRefillComment !== undefined && - allocationConfig.earlyRefillComment.length < 10 && + allocationConfig?.earlyRefillComment?.length < 10 && usedDatatapInPercentage < 75 const isSubmitDisabled = - isApiCalling || isAllocationAmountValid || isEarlyRefillCommentValid - + isApiCalling || + isAllocationAmountInvalid || + (isEarlyRefillCommentInvalid && !isEarlyRefillCommentNotNeeded) return ( {title}