diff --git a/components/discount/freeRegisterCheckout.tsx b/components/discount/freeRegisterCheckout.tsx index ad3f5ebe..0aea3f8d 100644 --- a/components/discount/freeRegisterCheckout.tsx +++ b/components/discount/freeRegisterCheckout.tsx @@ -173,6 +173,23 @@ const FreeRegisterCheckout: FunctionComponent = ({ }); }, [coupon, domain, address, isWrongNetwork]); + const getButtonText = () => { + if (isWrongNetwork) return "Wrong Network"; + if (!termsBox) return "Please accept terms & policies"; + if (couponError || !coupon) return "Enter a valid Coupon"; + if (loadingCallData) return "Loading call data"; + if (loadingGas) { + if (invalidTx) return txError?.short; + return "Loading gas"; + } + if (loadingTypedData) return "Building typed data"; + if (loadingDeploymentData) { + if (paymasterRewards.length > 0) return "Loading deployment data"; + return "No Paymaster reward available"; + } + return "Register my domain"; + }; + return (
@@ -227,25 +244,7 @@ const FreeRegisterCheckout: FunctionComponent = ({ loadingTypedData } > - {isWrongNetwork - ? "Wrong Network" - : !termsBox - ? "Please accept terms & policies" - : couponError || !coupon - ? "Enter a valid Coupon" - : loadingCallData - ? "Loading call data" - : loadingGas - ? invalidTx - ? txError?.short - : "Loading gas" - : loadingTypedData - ? "Building typed data" - : loadingDeploymentData - ? paymasterRewards.length > 0 - ? "Loading deployment data" - : "No Paymaster reward available" - : "Register my domain"} + {getButtonText()} ) : ( diff --git a/components/domains/steps/checkoutCard.tsx b/components/domains/steps/checkoutCard.tsx index c7935cce..308da890 100644 --- a/components/domains/steps/checkoutCard.tsx +++ b/components/domains/steps/checkoutCard.tsx @@ -229,6 +229,12 @@ const CheckoutCard: FunctionComponent = ({ [updateFormState] ); + const getButtonText = () => { + if (!termsBox) return "Please accept terms & policies"; + if (invalidBalance) return `You don't have enough ${displayedCurrency}`; + return "Purchase"; + }; + return ( <> {formState.durationInYears === 1 ? ( @@ -307,11 +313,7 @@ const CheckoutCard: FunctionComponent = ({ !termsBox } > - {!termsBox - ? "Please accept terms & policies" - : invalidBalance - ? `You don't have enough ${displayedCurrency}` - : "Purchase"} + {getButtonText()}
diff --git a/tests/utils/userDataService.test.js b/tests/utils/userDataService.test.js index 6f39cf5f..9f78a774 100644 --- a/tests/utils/userDataService.test.js +++ b/tests/utils/userDataService.test.js @@ -75,8 +75,7 @@ describe("computeMetadataHash function", () => { expectedHashHex.length - 2 ); - const result = await computeMetadataHash( -"none",email, taxState, salt); + const result = await computeMetadataHash(email, taxState, salt); expect(result).toBe(expectedHash); });