-
Notifications
You must be signed in to change notification settings - Fork 57
Vnext-81889 | | Name fields for in-person Pickup #1409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@godaddy/react': patch | ||
| --- | ||
|
|
||
| Require customer first and last name for in-person pickup orders. Names are collected in the Pickup section, synced to order billing, and validated for card, offline, free, and express checkout paths. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,12 +282,12 @@ export function Checkout(props: CheckoutProps) { | |
| } | ||
| } | ||
|
|
||
| // Billing address validation - only required if not using shipping address OR pickup | ||
| // BUT skip for free orders (paymentMethod === 'offline') | ||
| const isFreeOrder = data.paymentMethod === PaymentMethodType.OFFLINE; | ||
| // Billing address validation - only required when billing is separate from shipping. | ||
| // Offline pickup (pay in store / $0 order) only requires customer names. | ||
| const isOfflinePayment = data.paymentMethod === PaymentMethodType.OFFLINE; | ||
| const isPickup = data.deliveryMethod === DeliveryMethods.PICKUP; | ||
| const isShipping = data.deliveryMethod === DeliveryMethods.SHIP; | ||
| const isFreePickup = isFreeOrder && isPickup; | ||
| const isOfflinePickup = isOfflinePayment && isPickup; | ||
|
|
||
| // Billing is separate from shipping when there is no shipping address | ||
| // to copy from. `mapOrderToFormValues` canonicalizes deliveryMethod | ||
|
|
@@ -297,18 +297,31 @@ export function Checkout(props: CheckoutProps) { | |
| const billingIsSeparateFromShipping = | ||
| !isShipping || !data.paymentUseShippingAddress; | ||
|
|
||
| const billingNameFields = [ | ||
| { key: 'billingFirstName', message: t.validation.enterFirstName }, | ||
| { key: 'billingLastName', message: t.validation.enterLastName }, | ||
| ]; | ||
|
|
||
| // Pickup orders always require customer name (collected in Pickup section). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Ensure required pickup names are persisted before confirmation. The |
||
| if (isPickup) { | ||
| for (const { key, message } of billingNameFields) { | ||
| if (!String(data[key as keyof typeof data] ?? '').trim()) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message, | ||
| path: [key], | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const requireBillingNamesOnly = | ||
| (!enableBillingAddressCollection && billingIsSeparateFromShipping) || | ||
| isFreePickup; | ||
| !isPickup && | ||
| (!enableBillingAddressCollection && billingIsSeparateFromShipping); | ||
|
|
||
| if (requireBillingNamesOnly) { | ||
| const nameFields = [ | ||
| { key: 'billingFirstName', message: t.validation.enterFirstName }, | ||
| { key: 'billingLastName', message: t.validation.enterLastName }, | ||
| ]; | ||
|
|
||
| for (const { key, message } of nameFields) { | ||
| if (!data[key as keyof typeof data]) { | ||
| for (const { key, message } of billingNameFields) { | ||
| if (!String(data[key as keyof typeof data] ?? '').trim()) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message, | ||
|
|
@@ -320,7 +333,7 @@ export function Checkout(props: CheckoutProps) { | |
|
|
||
| const requireBillingAddress = | ||
| enableBillingAddressCollection && | ||
| !isFreePickup && | ||
| !isOfflinePickup && | ||
| billingIsSeparateFromShipping; | ||
|
|
||
| if (requireBillingAddress) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Remove or type-correct this property. The
offlinepayment-method shape only acceptsprocessorandcheckoutTypes, so this addition makespnpm --filter @godaddy/react typecheckfail with TS2353.