diff --git a/app/checkout/page.tsx b/app/checkout/page.tsx
index 187db6d8f..7faf79a98 100644
--- a/app/checkout/page.tsx
+++ b/app/checkout/page.tsx
@@ -1,4 +1,5 @@
-'use client';
+import { CheckoutCart } from '@/components/checkout/checkout-cart';
+import { LoadingCart } from '@/components/checkout/loading-cart';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
@@ -10,66 +11,9 @@ import {
SelectTrigger,
SelectValue
} from '@/components/ui/select';
-import { Separator } from '@/components/ui/separator';
-import Image from 'next/image';
-import { useState } from 'react';
-
-const US_STATES = [
- { value: 'AL', label: 'Alabama' },
- { value: 'AK', label: 'Alaska' },
- { value: 'AZ', label: 'Arizona' },
- { value: 'AR', label: 'Arkansas' },
- { value: 'CA', label: 'California' },
- { value: 'CO', label: 'Colorado' },
- { value: 'CT', label: 'Connecticut' },
- { value: 'DE', label: 'Delaware' },
- { value: 'FL', label: 'Florida' },
- { value: 'GA', label: 'Georgia' },
- { value: 'HI', label: 'Hawaii' },
- { value: 'ID', label: 'Idaho' },
- { value: 'IL', label: 'Illinois' },
- { value: 'IN', label: 'Indiana' },
- { value: 'IA', label: 'Iowa' },
- { value: 'KS', label: 'Kansas' },
- { value: 'KY', label: 'Kentucky' },
- { value: 'LA', label: 'Louisiana' },
- { value: 'ME', label: 'Maine' },
- { value: 'MD', label: 'Maryland' },
- { value: 'MA', label: 'Massachusetts' },
- { value: 'MI', label: 'Michigan' },
- { value: 'MN', label: 'Minnesota' },
- { value: 'MS', label: 'Mississippi' },
- { value: 'MO', label: 'Missouri' },
- { value: 'MT', label: 'Montana' },
- { value: 'NE', label: 'Nebraska' },
- { value: 'NV', label: 'Nevada' },
- { value: 'NH', label: 'New Hampshire' },
- { value: 'NJ', label: 'New Jersey' },
- { value: 'NM', label: 'New Mexico' },
- { value: 'NY', label: 'New York' },
- { value: 'NC', label: 'North Carolina' },
- { value: 'ND', label: 'North Dakota' },
- { value: 'OH', label: 'Ohio' },
- { value: 'OK', label: 'Oklahoma' },
- { value: 'OR', label: 'Oregon' },
- { value: 'PA', label: 'Pennsylvania' },
- { value: 'RI', label: 'Rhode Island' },
- { value: 'SC', label: 'South Carolina' },
- { value: 'SD', label: 'South Dakota' },
- { value: 'TN', label: 'Tennessee' },
- { value: 'TX', label: 'Texas' },
- { value: 'UT', label: 'Utah' },
- { value: 'VT', label: 'Vermont' },
- { value: 'VA', label: 'Virginia' },
- { value: 'WA', label: 'Washington' },
- { value: 'WV', label: 'West Virginia' },
- { value: 'WI', label: 'Wisconsin' },
- { value: 'WY', label: 'Wyoming' }
-];
+import { Suspense } from 'react';
export default function CheckoutPage() {
- const [selectedCountry, setSelectedCountry] = useState('us');
-
return (
-
+
-
+
-
@@ -164,35 +99,9 @@ export default function CheckoutPage() {
Order Summary
-
-
-
-
-
Product Name
-
Product description
-
-
$99.99
-
-
-
- Subtotal
- $99.99
-
-
- Shipping
- $9.99
-
-
- Total
- $109.98
-
-
+ }>
+
+
diff --git a/components/cart/modal.tsx b/components/cart/modal.tsx
index ca1e34652..5e22222ff 100644
--- a/components/cart/modal.tsx
+++ b/components/cart/modal.tsx
@@ -8,6 +8,7 @@ import { DEFAULT_OPTION } from 'lib/constants';
import { createUrl } from 'lib/utils';
import Image from 'next/image';
import Link from 'next/link';
+import { usePathname } from 'next/navigation';
import { Fragment, useEffect, useRef, useState } from 'react';
import { useFormStatus } from 'react-dom';
import { createCartAndSetCookie, redirectToCheckout } from './actions';
@@ -27,6 +28,7 @@ export default function CartModal() {
const quantityRef = useRef(cart?.totalQuantity);
const openCart = () => setIsOpen(true);
const closeCart = () => setIsOpen(false);
+ const pathname = usePathname();
useEffect(() => {
if (!cart) {
@@ -47,6 +49,10 @@ export default function CartModal() {
}
}, [isOpen, cart?.totalQuantity, quantityRef]);
+ useEffect(() => {
+ if (pathname === '/checkout') closeCart();
+ }, [pathname]);
+
return (
<>