Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: email required when buying with credit card
Browse files Browse the repository at this point in the history
blushi committed Jan 20, 2025
1 parent aa7d3db commit f5f75c5
Showing 4 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ export const CustomerInfo = ({
error={!!errors['email']}
helperText={errors['email']?.message}
disabled={!!accountEmail}
optional={!!wallet?.address}
optional={paymentOption === PAYMENT_OPTIONS.CRYPTO}
/>
{!accountId && !wallet?.address && (
<CheckboxLabel
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { z } from 'zod';

import { Wallet } from 'lib/wallet/wallet';

import { PAYMENT_OPTIONS } from 'pages/BuyCredits/BuyCredits.constants';
import { PaymentOptionsType } from 'pages/BuyCredits/BuyCredits.types';

export const paymentInfoFormSchema = (
paymentOption: PaymentOptionsType,
wallet?: Wallet,
) =>
export const paymentInfoFormSchema = (paymentOption: PaymentOptionsType) =>
z.object({
name:
paymentOption === PAYMENT_OPTIONS.CARD ? z.string().min(1) : z.string(),
email:
paymentOption === PAYMENT_OPTIONS.CARD && !wallet?.address
paymentOption === PAYMENT_OPTIONS.CARD
? z.string().email().min(1)
: z.union([z.literal(''), z.string().email().nullable()]),
createAccount: z.boolean(),
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ export const PaymentInfoForm = ({
const [paymentInfoValid, setPaymentInfoValid] = useState(false);

const form = useZodForm({
schema: paymentInfoFormSchema(paymentOption, wallet),
schema: paymentInfoFormSchema(paymentOption),
defaultValues: {
email: initialValues?.email || accountEmail,
name: initialValues?.name || accountName,
1 change: 1 addition & 0 deletions web-marketplace/src/pages/BuyCredits/BuyCredits.tsx
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ export const BuyCredits = () => {
]);

const [retiring, setRetiring] = useState<boolean>(true);

const [confirmationTokenId, setConfirmationTokenId] = useState<
string | undefined
>();

0 comments on commit f5f75c5

Please sign in to comment.