Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/plenty-memes-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@godaddy/react": patch
---

Add support for locale prop on context provider
13 changes: 7 additions & 6 deletions packages/react/src/components/checkout/form/checkout-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { ShippingMethodForm } from '@/components/checkout/shipping/shipping-meth
import { Target } from '@/components/checkout/target/target';
import { TipsForm } from '@/components/checkout/tips/tips-form';
import { DraftOrderTotals } from '@/components/checkout/totals/totals';
import { formatCurrency } from '@/components/checkout/utils/format-currency';
import { useFormatCurrency } from '@/components/checkout/utils/format-currency';
import {
Accordion,
AccordionContent,
Expand Down Expand Up @@ -71,6 +71,7 @@ export function CheckoutForm({
items,
...props
}: CheckoutFormProps) {
const formatCurrency = useFormatCurrency();
const { t } = useGoDaddyContext();
const { session, isCheckoutDisabled } = useCheckoutContext();

Expand Down Expand Up @@ -439,7 +440,7 @@ export function CheckoutForm({
{formatCurrency({
amount: totals?.total?.value || 0,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
})}
</span>
</div>
Expand All @@ -449,11 +450,11 @@ export function CheckoutForm({
<DraftOrderLineItems
currencyCode={currencyCode}
items={items}
isInCents
inputInMinorUnits
/>

<DraftOrderTotals
isInCents
inputInMinorUnits
currencyCode={currencyCode}
tip={tipTotal}
taxes={taxTotal}
Expand All @@ -480,11 +481,11 @@ export function CheckoutForm({
<DraftOrderLineItems
currencyCode={currencyCode}
items={items}
isInCents
inputInMinorUnits
/>

<DraftOrderTotals
isInCents
inputInMinorUnits
currencyCode={currencyCode}
tip={tipTotal}
taxes={taxTotal}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { Badge } from "@/components/ui/badge";

import { Image } from 'lucide-react';
import { formatCurrency } from '@/components/checkout/utils/format-currency';
import { useFormatCurrency } from '@/components/checkout/utils/format-currency';
import { useGoDaddyContext } from '@/godaddy-provider';
import type { SKUProduct } from '@/types';

Expand Down Expand Up @@ -56,15 +56,16 @@ export type Product = Partial<SKUProduct> & {
export interface DraftOrderLineItemsProps {
items: Product[];
currencyCode?: string;
isInCents?: boolean;
inputInMinorUnits?: boolean;
}

export function DraftOrderLineItems({
items,
currencyCode = 'USD',
isInCents = false,
inputInMinorUnits = false,
}: DraftOrderLineItemsProps) {
const { t } = useGoDaddyContext();
const formatCurrency = useFormatCurrency();

return (
<div className='space-y-4 mb-4'>
Expand Down Expand Up @@ -135,7 +136,7 @@ export function DraftOrderLineItems({
{formatCurrency({
amount: item.originalPrice * item.quantity,
currencyCode,
isInCents,
inputInMinorUnits,
})}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { filterAndSortShippingMethods } from '@/components/checkout/shipping/uti
import { useGetShippingMethodByAddress } from '@/components/checkout/shipping/utils/use-get-shipping-methods';
import { useGetTaxes } from '@/components/checkout/taxes/utils/use-get-taxes';
import { mapOrderToFormValues } from '@/components/checkout/utils/checkout-transformers';
import { formatCurrency } from '@/components/checkout/utils/format-currency';
import { useFormatCurrency } from '@/components/checkout/utils/format-currency';
import { Skeleton } from '@/components/ui/skeleton';
import { useGoDaddyContext } from '@/godaddy-provider';
import { GraphQLErrorWithCodes } from '@/lib/graphql-with-errors';
Expand All @@ -46,6 +46,7 @@ import {
} from '@/tracking/track';

export function ExpressCheckoutButton() {
const formatCurrency = useFormatCurrency();
const { session, setCheckoutErrors } = useCheckoutContext();
const { isPoyntLoaded } = useLoadPoyntCollect();
const { godaddyPaymentsConfig } = useCheckoutContext();
Expand Down Expand Up @@ -139,7 +140,7 @@ export function ExpressCheckoutButton() {
const shippingMethodPrice = formatCurrency({
amount: method.cost?.value || 0,
currencyCode: method.cost?.currencyCode || currencyCode,
isInCents: true,
inputInMinorUnits: true,
});

return {
Expand All @@ -151,7 +152,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: method.cost?.value || 0,
currencyCode: method.cost?.currencyCode || currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
amountInMinorUnits: method.cost?.value || 0, // Keep original minor unit value
Expand Down Expand Up @@ -186,7 +187,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
isPending: false,
Expand All @@ -199,7 +200,7 @@ export function ExpressCheckoutButton() {
const totalAmount = formatCurrency({
amount: totalInMinorUnits,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
});

Expand All @@ -217,7 +218,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
},
Expand Down Expand Up @@ -356,7 +357,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
};
Expand Down Expand Up @@ -553,7 +554,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: godaddyTotals.shipping.value,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
});
Expand All @@ -565,7 +566,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: godaddyTotals.taxes.value,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
});
Expand All @@ -580,7 +581,7 @@ export function ExpressCheckoutButton() {
const totalAmount = formatCurrency({
amount: totalInMinorUnits,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
});

Expand Down Expand Up @@ -631,7 +632,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: godaddyTotals.shipping.value,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
});
Expand All @@ -643,7 +644,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: godaddyTotals.taxes.value,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
});
Expand All @@ -655,7 +656,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -adjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
});
Expand All @@ -670,7 +671,7 @@ export function ExpressCheckoutButton() {
const totalAmount = formatCurrency({
amount: totalInMinorUnits,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
});

Expand All @@ -686,7 +687,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -adjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
},
Expand Down Expand Up @@ -980,7 +981,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: taxesResult.value,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
isPending: false,
Expand Down Expand Up @@ -1016,7 +1017,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
isPending: false,
Expand Down Expand Up @@ -1045,7 +1046,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
};
Expand Down Expand Up @@ -1161,7 +1162,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: taxesResult.value,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
isPending: false,
Expand Down Expand Up @@ -1200,7 +1201,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
isPending: false,
Expand Down Expand Up @@ -1230,7 +1231,7 @@ export function ExpressCheckoutButton() {
amount: formatCurrency({
amount: -priceAdjustment,
currencyCode,
isInCents: true,
inputInMinorUnits: true,
returnRaw: true,
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
DraftOrderTotals,
type DraftOrderTotalsProps,
} from '@/components/checkout/totals/totals';
import { formatCurrency } from '@/components/checkout/utils/format-currency';
import { useFormatCurrency } from '@/components/checkout/utils/format-currency';
import {
Accordion,
AccordionContent,
Expand Down Expand Up @@ -72,6 +72,7 @@ const PAYMENT_METHOD_ICONS: Record<string, React.ReactNode> = {
export function PaymentForm(
props: DraftOrderTotalsProps & { items: Product[] }
) {
const formatCurrency = useFormatCurrency();
const { t } = useGoDaddyContext();
const {
session,
Expand Down Expand Up @@ -451,7 +452,7 @@ export function PaymentForm(
{formatCurrency({
amount: props.total || 0,
currencyCode: props.currencyCode || 'USD',
isInCents: true,
inputInMinorUnits: true,
})}
</span>
</div>
Expand All @@ -461,15 +462,15 @@ export function PaymentForm(
<DraftOrderLineItems
currencyCode={props.currencyCode}
items={props.items}
isInCents
inputInMinorUnits
/>
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
<div className='pt-4'>
<DraftOrderTotals
isInCents
inputInMinorUnits
currencyCode={props.currencyCode}
tip={props.tip}
taxes={props.taxes}
Expand Down
Loading