diff --git a/components/cart/modal.tsx b/components/cart/modal.tsx
index a8c8db8bd..f9e0f6c01 100644
--- a/components/cart/modal.tsx
+++ b/components/cart/modal.tsx
@@ -49,8 +49,17 @@ export default function CartModal({
// Always update the quantity reference
quantityRef.current = cart?.totalQuantity;
}
+
+ return () => {
+ setIsConfirming(false);
+ };
}, [isOpen, cart?.totalQuantity, quantityRef]);
+ const checkoutWithAgeCheck = () => {
+ setIsOpen(true);
+ setIsConfirming(true);
+ };
+
return (
<>
- {!cart || cart.lines.length === 0 ? (
-
-
-
Your shopping bag is empty.
-
+ {!!isConfirming && !!cart && cart?.checkoutUrl ? (
+ setIsConfirming(false)}
+ checkoutUrl={cart.checkoutUrl}
+ />
) : (
-
-
- {cart.lines.map((item, i) => {
- const merchandiseSearchParams = {} as MerchandiseSearchParams;
-
- item.merchandise.selectedOptions.forEach(({ name, value }) => {
- if (value !== DEFAULT_OPTION) {
- merchandiseSearchParams[name.toLowerCase()] = value;
- }
- });
-
- const merchandiseUrl = createUrl(
- `/product/${item.merchandise.product.handle}`,
- new URLSearchParams(merchandiseSearchParams)
- );
-
- return (
- -
-
-
-
-
-
-
-
-
-
-
-
- {item.merchandise.product.title}
-
- {item.merchandise.title !== DEFAULT_OPTION ? (
-
{item.merchandise.title}
- ) : null}
-
-
-
-
-
-
-
- {item.quantity}
-
-
-
-
-
-
- );
- })}
-
- {!!promotedItem && (
-
- )}
-
-
-
Taxes
-
Calculated at checkout
+ <>
+ {!cart || cart.lines.length === 0 ? (
+
+
+
+ Your shopping bag is empty.
+
-
-
Shipping
-
Calculated at checkout
-
-
-
- {ageConfirmed ? (
- <>
-
- {t('cart.proceed')}
-
- >
) : (
- <>
-
- >
+
+
+ {cart.lines.map((item, i) => {
+ const merchandiseSearchParams = {} as MerchandiseSearchParams;
+
+ item.merchandise.selectedOptions.forEach(({ name, value }) => {
+ if (value !== DEFAULT_OPTION) {
+ merchandiseSearchParams[name.toLowerCase()] = value;
+ }
+ });
+
+ const merchandiseUrl = createUrl(
+ `/product/${item.merchandise.product.handle}`,
+ new URLSearchParams(merchandiseSearchParams)
+ );
+
+ return (
+ -
+
+
+
+
+
+
+
+
+
+
+
+ {item.merchandise.product.title}
+
+ {item.merchandise.title !== DEFAULT_OPTION ? (
+
{item.merchandise.title}
+ ) : null}
+
+
+
+
+
+
+
+ {item.quantity}
+
+
+
+
+
+
+ );
+ })}
+
+ {!!promotedItem && (
+
+ )}
+
+
+
Taxes
+
Calculated at checkout
+
+
+
Shipping
+
Calculated at checkout
+
+
+
+ {ageConfirmed ? (
+ <>
+
+ {t('cart.proceed')}
+
+ >
+ ) : (
+ <>
+
+ >
+ )}
+
)}
- {/*
- {t('cart.proceed')}
- */}
-
+ >
)}
- {!!isConfirming && !!cart && cart?.checkoutUrl && (
-
setIsConfirming(false)} checkoutUrl={cart.checkoutUrl} />
- )}
>
);
}
diff --git a/components/product/age-gate-form.tsx b/components/product/age-gate-form.tsx
index 3c75b60b2..b968c957c 100644
--- a/components/product/age-gate-form.tsx
+++ b/components/product/age-gate-form.tsx
@@ -3,7 +3,7 @@
/* This example requires Tailwind CSS v2.0+ */
import { FC, Fragment, useEffect, useRef, useState, useTransition } from 'react';
-import { Dialog, Transition } from '@headlessui/react';
+import { Transition } from '@headlessui/react';
import { CheckIcon } from '@heroicons/react/24/outline';
import { useAgeConfirmation } from 'app/hooks/use-age-confirmation';
import clsx from 'clsx';
@@ -27,7 +27,7 @@ const AgeGateForm: FC = ({ checkoutUrl, didCancel }) => {
const { onAgeConfirmed } = useAgeConfirmation();
- const yearFieldRef = useRef(null);
+ const yearFieldRef = useRef(null);
const minAge = 20;
const maxAge = 130;
@@ -61,135 +61,126 @@ const AgeGateForm: FC = ({ checkoutUrl, didCancel }) => {
}
}, [month, day, year]);
+ useEffect(() => {
+ if (yearFieldRef) {
+ console.debug('yearFieldRef', yearFieldRef?.current);
+ yearFieldRef?.current?.focus();
+ }
+ }, []);
+
return (
<>
-