From 097cb8356813e1cd2fe89ba4f2373cac0a5406c4 Mon Sep 17 00:00:00 2001 From: Sol Irvine Date: Sat, 19 Aug 2023 17:18:45 +0900 Subject: [PATCH] wip: Product detail view --- app/[locale]/page.tsx | 2 +- app/[locale]/product/[handle]/layout.tsx | 43 ++++++++++++++++++++++ app/[locale]/product/[handle]/page.tsx | 16 ++++---- app/[locale]/products/page.tsx | 2 +- components/cart/add-to-cart.tsx | 2 +- components/cart/close-cart.tsx | 2 +- components/cart/modal.tsx | 27 ++++++-------- components/cart/open-cart.tsx | 2 +- components/layout/footer.tsx | 8 +++- components/layout/navbar/index.tsx | 4 +- components/layout/newsletter-footer.tsx | 4 +- components/layout/newsletter-signup.tsx | 4 +- components/product/gallery.tsx | 19 +++++----- components/product/product-description.tsx | 8 ++-- 14 files changed, 92 insertions(+), 51 deletions(-) create mode 100644 app/[locale]/product/[handle]/layout.tsx diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 9e381b16f..5e3f0d437 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -39,7 +39,7 @@ export default async function HomePage({ } return ( -
+
diff --git a/app/[locale]/product/[handle]/layout.tsx b/app/[locale]/product/[handle]/layout.tsx new file mode 100644 index 000000000..14ddd776c --- /dev/null +++ b/app/[locale]/product/[handle]/layout.tsx @@ -0,0 +1,43 @@ +import Footer from 'components/layout/footer'; +import { SupportedLocale } from 'components/layout/navbar/language-control'; + +import Navbar from 'components/layout/navbar'; +import { getCart } from 'lib/shopify'; +import { cookies } from 'next/headers'; +import { ReactNode, Suspense } from 'react'; + +export const runtime = 'edge'; +const { SITE_NAME } = process.env; + +export const metadata = { + title: SITE_NAME, + description: SITE_NAME, + openGraph: { + type: 'website' + } +}; + +export default async function ProductLayout({ + params: { locale }, + children +}: { + params: { locale?: SupportedLocale }; + children: ReactNode[] | ReactNode | string; +}) { + const cartId = cookies().get('cartId')?.value; + let cart; + + if (cartId) { + cart = await getCart(cartId); + } + + return ( +
+ + {children} + +
+ +
+ ); +} diff --git a/app/[locale]/product/[handle]/page.tsx b/app/[locale]/product/[handle]/page.tsx index c1a3cca64..7352a52e9 100644 --- a/app/[locale]/product/[handle]/page.tsx +++ b/app/[locale]/product/[handle]/page.tsx @@ -3,7 +3,6 @@ import { notFound } from 'next/navigation'; import { Suspense } from 'react'; import { GridTileImage } from 'components/grid/tile'; -import Footer from 'components/layout/footer'; import { Gallery } from 'components/product/gallery'; import { ProductDescription } from 'components/product/product-description'; import { HIDDEN_PRODUCT_TAG } from 'lib/constants'; @@ -81,8 +80,8 @@ export default async function ProductPage({ params }: { params: { handle: string __html: JSON.stringify(productJsonLd) }} /> -
-
+
+
({ @@ -100,9 +99,6 @@ export default async function ProductPage({ params }: { params: { handle: string
- -