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
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"dependencies": {
"@next/third-parties": "^16.1.6",
"@sentry/nextjs": "^10.38.0",
"@spree/next": "^0.13.0",
"@spree/sdk": "^0.13.0",
"@spree/next": "^0.14.1",
"@spree/sdk": "^0.14.2",
"@stripe/react-stripe-js": "^5.6.0",
"@stripe/stripe-js": "^8.7.0",
"class-variance-authority": "^0.7.1",
Expand Down
22 changes: 14 additions & 8 deletions src/app/[country]/[locale]/(checkout)/checkout/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ export default function CheckoutPage({ params }: CheckoutPageProps) {
const handleAutoSave = useCallback(
async (addressData: {
email: string;
ship_address?: AddressParams;
ship_address_id?: string;
shipping_address?: AddressParams;
shipping_address_id?: string;
}) => {
const currentOrder = cartRef.current;
if (!currentOrder) return;
Expand All @@ -242,11 +242,11 @@ export default function CheckoutPage({ params }: CheckoutPageProps) {
try {
const updateResult = await updateOrderAddresses(currentOrder.id, {
email: addressData.email,
...(addressData.ship_address && {
ship_address: addressData.ship_address,
...(addressData.shipping_address && {
shipping_address: addressData.shipping_address,
}),
...(addressData.ship_address_id && {
ship_address_id: addressData.ship_address_id,
...(addressData.shipping_address_id && {
shipping_address_id: addressData.shipping_address_id,
}),
});

Expand Down Expand Up @@ -315,15 +315,21 @@ export default function CheckoutPage({ params }: CheckoutPageProps) {

// Handle billing address update (called by PaymentSection before gateway confirmation)
const handleUpdateBillingAddress = useCallback(
async (data: { bill_address: AddressParams }): Promise<boolean> => {
async (data: {
billing_address?: AddressParams;
use_shipping?: boolean;
}): Promise<boolean> => {
const currentOrder = cartRef.current;
if (!currentOrder) return false;

setError(null);

try {
const updateResult = await updateOrderAddresses(currentOrder.id, {
bill_address: data.bill_address,
...(data.billing_address && {
billing_address: data.billing_address,
}),
...(data.use_shipping && { use_shipping: data.use_shipping }),
});

if (!updateResult.success) {
Expand Down
65 changes: 34 additions & 31 deletions src/app/[country]/[locale]/(checkout)/order-placed/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function OrderPlacedPage({ params }: OrderPlacedPageProps) {
}

const customerName =
order.bill_address?.full_name || order.ship_address?.full_name || "";
order.billing_address?.full_name || order.shipping_address?.full_name || "";

return (
<div className="py-8 max-w-2xl mx-auto">
Expand Down Expand Up @@ -168,14 +168,15 @@ export default function OrderPlacedPage({ params }: OrderPlacedPageProps) {
{order.display_delivery_total}
</span>
</div>
{order.promo_total && Number.parseFloat(order.promo_total) !== 0 && (
<div className="flex justify-between text-sm">
<span className="text-gray-500">Discount</span>
<span className="text-green-600">
{order.display_promo_total}
</span>
</div>
)}
{order.discount_total &&
Number.parseFloat(order.discount_total) !== 0 && (
<div className="flex justify-between text-sm">
<span className="text-gray-500">Discount</span>
<span className="text-green-600">
{order.display_discount_total}
</span>
</div>
)}
<div className="flex justify-between text-sm">
<span className="text-gray-500">Tax</span>
<span className="text-gray-900">{order.display_tax_total}</span>
Expand All @@ -202,55 +203,57 @@ export default function OrderPlacedPage({ params }: OrderPlacedPageProps) {
)}

<div className="grid grid-cols-1 sm:grid-cols-2 gap-6">
{order.ship_address && (
{order.shipping_address && (
<div>
<h3 className="text-sm font-semibold text-gray-900 mb-2">
Shipping Address
</h3>
<div className="text-sm text-gray-600 space-y-0.5">
<p className="font-medium text-gray-800">
{order.ship_address.full_name}
{order.shipping_address.full_name}
</p>
{order.ship_address.company && (
<p>{order.ship_address.company}</p>
{order.shipping_address.company && (
<p>{order.shipping_address.company}</p>
)}
<p>{order.ship_address.address1}</p>
{order.ship_address.address2 && (
<p>{order.ship_address.address2}</p>
<p>{order.shipping_address.address1}</p>
{order.shipping_address.address2 && (
<p>{order.shipping_address.address2}</p>
)}
<p>
{order.ship_address.city}, {order.ship_address.state_text}{" "}
{order.ship_address.zipcode}
{order.shipping_address.city},{" "}
{order.shipping_address.state_text}{" "}
{order.shipping_address.postal_code}
</p>
<p>{order.ship_address.country_name}</p>
{order.ship_address.phone && (
<p className="mt-1">{order.ship_address.phone}</p>
<p>{order.shipping_address.country_name}</p>
{order.shipping_address.phone && (
<p className="mt-1">{order.shipping_address.phone}</p>
)}
</div>
</div>
)}

{order.bill_address && (
{order.billing_address && (
<div>
<h3 className="text-sm font-semibold text-gray-900 mb-2">
Billing Address
</h3>
<div className="text-sm text-gray-600 space-y-0.5">
<p className="font-medium text-gray-800">
{order.bill_address.full_name}
{order.billing_address.full_name}
</p>
{order.bill_address.company && (
<p>{order.bill_address.company}</p>
{order.billing_address.company && (
<p>{order.billing_address.company}</p>
)}
<p>{order.bill_address.address1}</p>
{order.bill_address.address2 && (
<p>{order.bill_address.address2}</p>
<p>{order.billing_address.address1}</p>
{order.billing_address.address2 && (
<p>{order.billing_address.address2}</p>
)}
<p>
{order.bill_address.city}, {order.bill_address.state_text}{" "}
{order.bill_address.zipcode}
{order.billing_address.city},{" "}
{order.billing_address.state_text}{" "}
{order.billing_address.postal_code}
</p>
<p>{order.bill_address.country_name}</p>
<p>{order.billing_address.country_name}</p>
</div>
</div>
)}
Expand Down
11 changes: 8 additions & 3 deletions src/app/[country]/[locale]/(storefront)/cart/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export default function CartPage() {

// Track view_cart when cart loads with items
useEffect(() => {
if (!loading && cart && cart.item_count > 0 && !viewCartFiredRef.current) {
if (
!loading &&
cart &&
cart.total_quantity > 0 &&
!viewCartFiredRef.current
) {
trackViewCart(cart);
viewCartFiredRef.current = true;
}
Expand Down Expand Up @@ -141,10 +146,10 @@ export default function CartPage() {
<dt className="text-gray-500">Subtotal</dt>
<dd className="text-gray-900">{cart.display_item_total}</dd>
</div>
{cart.promo_total && parseFloat(cart.promo_total) < 0 && (
{cart.discount_total && parseFloat(cart.discount_total) < 0 && (
<div className="flex justify-between text-green-600">
<dt>Discount</dt>
<dd>{cart.display_promo_total}</dd>
<dd>{cart.display_discount_total}</dd>
</div>
)}
{cart.delivery_total && parseFloat(cart.delivery_total) > 0 && (
Expand Down
9 changes: 4 additions & 5 deletions src/components/account/CreditCardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function CreditCardItem({
<div className="flex justify-between items-start">
<div className="flex items-center gap-4">
<PaymentIcon
type={getCardIconType(card.cc_type)}
type={getCardIconType(card.brand)}
format="flatRounded"
width={48}
/>
<div>
<p className="text-sm font-medium text-gray-900">
{getCardLabel(card.cc_type)} ending in {card.last_digits}
{getCardLabel(card.brand)} ending in {card.last4}
</p>
<p className="text-xs text-gray-500">
Exp {String(card.month).padStart(2, "0")}/{card.year}
Expand All @@ -73,9 +73,8 @@ function CreditCardItem({
<AlertDialogHeader>
<AlertDialogTitle>Remove payment method?</AlertDialogTitle>
<AlertDialogDescription>
This will remove the {getCardLabel(card.cc_type)} ending in{" "}
{card.last_digits} from your account. This action cannot be
undone.
This will remove the {getCardLabel(card.brand)} ending in{" "}
{card.last4} from your account. This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
Expand Down
35 changes: 18 additions & 17 deletions src/components/account/OrderDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ function PaymentSourceInfo({ payment }: { payment: Payment }) {
return (
<div className="flex items-center gap-3">
<PaymentIcon
type={getCardIconType(card.cc_type)}
type={getCardIconType(card.brand)}
format="flatRounded"
width={40}
/>
<div>
<p className="text-sm font-medium text-gray-900">
{getCardLabel(card.cc_type)} ending in {card.last_digits}
{getCardLabel(card.brand)} ending in {card.last4}
</p>
<p className="text-xs text-gray-500">
Expires {String(card.month).padStart(2, "0")}/{card.year}
Expand Down Expand Up @@ -67,7 +67,7 @@ function AddressBlock({ address }: { address: Address }) {
<p>{address.address1}</p>
{address.address2 && <p>{address.address2}</p>}
<p>
{address.city}, {address.state_text} {address.zipcode}
{address.city}, {address.state_text} {address.postal_code}
</p>
<p>{address.country_name}</p>
{address.phone && <p className="mt-1">{address.phone}</p>}
Expand Down Expand Up @@ -255,7 +255,7 @@ export function OrderDetail({ order, basePath }: OrderDetailProps) {
<FulfillmentBlock
key={fulfillment.id}
fulfillment={fulfillment}
shipAddress={order.ship_address}
shipAddress={order.shipping_address}
basePath={basePath}
lineItems={fulfillmentLineItems}
/>
Expand All @@ -273,23 +273,23 @@ export function OrderDetail({ order, basePath }: OrderDetailProps) {
</div>
)}

{order.special_instructions && (
{order.customer_note && (
<div className="bg-white rounded-xl border border-gray-200 p-6 mb-4">
<h3 className="text-sm font-semibold text-gray-900 mb-2">
Special Instructions
Customer Note
</h3>
<p className="text-sm text-gray-900">{order.special_instructions}</p>
<p className="text-sm text-gray-900">{order.customer_note}</p>
</div>
)}

<div className="bg-white rounded-xl border border-gray-200 overflow-hidden mb-4">
<div className="grid grid-cols-1 lg:grid-cols-2 divide-y lg:divide-y-0 lg:divide-x divide-gray-200">
{order.bill_address && (
{order.billing_address && (
<div className="px-6 py-4">
<h3 className="text-sm font-semibold text-gray-900 mb-2">
Billing Address
</h3>
<AddressBlock address={order.bill_address} />
<AddressBlock address={order.billing_address} />
</div>
)}
{order.payments && order.payments.length > 0 && (
Expand Down Expand Up @@ -324,14 +324,15 @@ export function OrderDetail({ order, basePath }: OrderDetailProps) {
{order.display_delivery_total}
</span>
</div>
{order.promo_total && Number.parseFloat(order.promo_total) !== 0 && (
<div className="flex justify-between text-sm">
<span className="text-gray-500">Discount</span>
<span className="text-green-600">
{order.display_promo_total}
</span>
</div>
)}
{order.discount_total &&
Number.parseFloat(order.discount_total) !== 0 && (
<div className="flex justify-between text-sm">
<span className="text-gray-500">Discount</span>
<span className="text-green-600">
{order.display_discount_total}
</span>
</div>
)}
{Number.parseFloat(order.tax_total) > 0 && (
<div className="flex justify-between text-sm">
<span className="text-gray-500">Tax</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/addresses/AddressManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function AddressCard({ address, onEdit, onDelete }: AddressCardProps) {
<p>{address.address1}</p>
{address.address2 && <p>{address.address2}</p>}
<p>
{address.city}, {address.state_text} {address.zipcode}
{address.city}, {address.state_text} {address.postal_code}
</p>
<p>{address.country_name}</p>
{address.phone && <p className="mt-1">{address.phone}</p>}
Expand Down
11 changes: 8 additions & 3 deletions src/components/cart/CartDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export function CartDrawer() {

// Track view_cart when drawer opens with items (fire once per open)
useEffect(() => {
if (isOpen && cart && cart.item_count > 0 && !viewCartFiredRef.current) {
if (
isOpen &&
cart &&
cart.total_quantity > 0 &&
!viewCartFiredRef.current
) {
trackViewCart(cart);
viewCartFiredRef.current = true;
}
Expand Down Expand Up @@ -216,10 +221,10 @@ export function CartDrawer() {
<span>Subtotal</span>
<span>{cart?.display_item_total}</span>
</div>
{cart?.promo_total && parseFloat(cart.promo_total) < 0 && (
{cart?.discount_total && parseFloat(cart.discount_total) < 0 && (
<div className="flex justify-between items-center text-sm text-green-600">
<span>Discount</span>
<span>{cart.display_promo_total}</span>
<span>{cart.display_discount_total}</span>
</div>
)}
<div className="flex justify-between items-center">
Expand Down
Loading
Loading