From b6ba260b775ac88584b5418f7b9c833dc99b26e5 Mon Sep 17 00:00:00 2001 From: Jieren Chen Date: Sun, 8 Sep 2024 16:53:43 -0400 Subject: [PATCH] currency and checkout --- app/layout.tsx | 18 +------ app/page.tsx | 14 ++++-- app/product/[handle]/page.tsx | 69 +++++++++++++++------------ components/cart/actions.ts | 14 +++--- components/cart/add-to-cart.tsx | 1 - components/cart/cart-context.tsx | 2 +- components/cart/modal.tsx | 2 +- components/grid/three-items.tsx | 6 +-- components/layout/navbar/currency.tsx | 61 +++++++++++++++++++++++ components/layout/navbar/index.tsx | 12 ++--- components/wrapper.tsx | 17 +++++++ lib/fourthwall/index.ts | 38 ++++++++++----- lib/fourthwall/reshape.ts | 1 + lib/fourthwall/types.ts | 4 ++ lib/shopify/types.ts | 1 + 15 files changed, 179 insertions(+), 81 deletions(-) create mode 100644 components/layout/navbar/currency.tsx create mode 100644 components/wrapper.tsx diff --git a/app/layout.tsx b/app/layout.tsx index c4c4f9773..4c199666e 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,12 +1,6 @@ -import { CartProvider } from 'components/cart/cart-context'; -import { Navbar } from 'components/layout/navbar'; -import { WelcomeToast } from 'components/welcome-toast'; import { GeistSans } from 'geist/font/sans'; -import { getCart } from 'lib/fourthwall'; import { ensureStartsWith } from 'lib/utils'; -import { cookies } from 'next/headers'; import { ReactNode } from 'react'; -import { Toaster } from 'sonner'; import './globals.css'; const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env; @@ -37,21 +31,11 @@ export const metadata = { }; export default async function RootLayout({ children }: { children: ReactNode }) { - const cartId = cookies().get('cartId')?.value; - // Don't await the fetch, pass the Promise to the context provider - const cart = getCart(cartId, 'USD'); return ( - - -
- {children} - - -
-
+ {children} ); diff --git a/app/page.tsx b/app/page.tsx index af275eab5..3e12b7af3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,6 +1,9 @@ import { Carousel } from 'components/carousel'; import { ThreeItemGrid } from 'components/grid/three-items'; import Footer from 'components/layout/footer'; +import { Wrapper } from 'components/wrapper'; +import { getCart } from 'lib/fourthwall'; +import { cookies } from 'next/headers'; export const metadata = { description: 'High-performance ecommerce store built with Next.js, Vercel, and Shopify.', @@ -9,14 +12,17 @@ export const metadata = { } }; -export default function HomePage({ searchParams }: { searchParams: { currency?: string } }) { +export default async function HomePage({ searchParams }: { searchParams: { currency?: string } }) { + const cartId = cookies().get('cartId')?.value; const currency = searchParams.currency || 'USD'; + // Don't await the fetch, pass the Promise to the context provider + const cart = getCart(cartId, currency); return ( - <> + - +