Skip to content

Commit

Permalink
ORV2-3306 - FE: Refund by cheque requiring transaction ID (#1745)
Browse files Browse the repository at this point in the history
Co-authored-by: GlenAOT <[email protected]>
  • Loading branch information
glen-aot and glen-aot authored Jan 16, 2025
1 parent 6175b55 commit d365d57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/common/constants/validation_messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"transactionId": {
"defaultMessage": "Invalid transaction ID",
"length": {
"messageTemplate": "Transaction ID length must be no longer than :max characters",
"messageTemplate": "Maximum :max characters",
"placeholders": [":max"]
}
}
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/features/permits/pages/Refund/RefundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,15 @@ const transactionIdRules = {
requiredMessage()
);
},
validateTransactionId: (value: Optional<string>) => {
return (value && value.length <= 15) || invalidTranactionIdLength(15);
validateTransactionId: (
value: Optional<string>,
formValues: RefundFormData,
) => {
return (
!formValues.shouldUsePrevPaymentMethod ||
(value && value.length <= 15) ||
invalidTranactionIdLength(15)
);
},
},
};
Expand Down Expand Up @@ -210,6 +217,7 @@ export const RefundPage = ({
const usePrev = shouldUsePrev === "true";
setShouldUsePrevPaymentMethod(usePrev);
setValue("refundOnlineMethod", usePrev ? getRefundOnlineMethod() : "");
setValue("transactionId", "");
clearErrors("transactionId");
};

Expand All @@ -227,6 +235,7 @@ export const RefundPage = ({
e: React.ChangeEvent<HTMLInputElement>,
) => {
const formattedValue = filterNonNumericValue(e.target.value);
handleRefundMethodChange("true");
setValue("transactionId", formattedValue, { shouldValidate: true });
};

Expand Down

0 comments on commit d365d57

Please sign in to comment.