From 725a43505a9d3a464be8a2f0f8f01bf03ffe10a4 Mon Sep 17 00:00:00 2001 From: Sol Irvine Date: Fri, 1 Sep 2023 14:54:27 -0700 Subject: [PATCH] fix: Add promoted item to cart --- app/[locale]/about/page.tsx | 10 ++- app/[locale]/bar/page.tsx | 10 ++- app/[locale]/company/page.tsx | 10 ++- app/[locale]/concept/page.tsx | 10 ++- app/[locale]/disclosures/page.tsx | 10 ++- app/[locale]/page.tsx | 2 +- app/[locale]/privacy/page.tsx | 10 ++- app/[locale]/products/page.tsx | 10 ++- app/[locale]/shop-list/page.tsx | 10 ++- app/[locale]/stories/[handle]/layout.tsx | 10 ++- app/[locale]/stories/page.tsx | 10 ++- app/[locale]/terms/page.tsx | 10 ++- components/cart/delete-item-button.tsx | 2 +- components/cart/index.tsx | 13 +++- components/cart/modal.tsx | 31 ++++----- components/cart/promoted-cart-item.tsx | 82 +++++++++++------------- components/layout/footer.tsx | 12 +++- components/layout/navbar/index.tsx | 16 ++--- 18 files changed, 167 insertions(+), 101 deletions(-) diff --git a/app/[locale]/about/page.tsx b/app/[locale]/about/page.tsx index a1354a4a0..936d6628d 100644 --- a/app/[locale]/about/page.tsx +++ b/app/[locale]/about/page.tsx @@ -2,7 +2,8 @@ import Footer from 'components/layout/footer'; import { SupportedLocale } from 'components/layout/navbar/language-control'; import Navbar from 'components/layout/navbar'; -import { getCart, getPage } from 'lib/shopify'; +import { getCart, getPage, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; import AboutNaraiDetail from './about-narai-detail'; @@ -26,11 +27,16 @@ export default async function Page({ params }: { params: { locale?: SupportedLoc cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: params?.locale?.toUpperCase() + }); + const awardsPage = await getPage({ handle: 'awards', language: params?.locale?.toUpperCase() }); return (
- +
diff --git a/app/[locale]/bar/page.tsx b/app/[locale]/bar/page.tsx index 98fe0ea39..c5f496db0 100644 --- a/app/[locale]/bar/page.tsx +++ b/app/[locale]/bar/page.tsx @@ -2,7 +2,8 @@ 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 { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; import SagyobarDetail from './sagyobar-detail'; @@ -28,9 +29,14 @@ export default async function Page({ params }: { params: { locale?: SupportedLoc cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: params?.locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/company/page.tsx b/app/[locale]/company/page.tsx index ae9820f10..fe6ca923c 100644 --- a/app/[locale]/company/page.tsx +++ b/app/[locale]/company/page.tsx @@ -2,7 +2,8 @@ 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 { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; import CompanyDetail from './company-detail'; @@ -28,9 +29,14 @@ export default async function Page({ params }: { params: { locale?: SupportedLoc cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: params?.locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/concept/page.tsx b/app/[locale]/concept/page.tsx index e23066ec4..ea6fc481e 100644 --- a/app/[locale]/concept/page.tsx +++ b/app/[locale]/concept/page.tsx @@ -2,7 +2,8 @@ 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 { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; import ConceptDetail from './concept-detail'; @@ -28,9 +29,14 @@ export default async function Page({ params }: { params: { locale?: SupportedLoc cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: params?.locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/disclosures/page.tsx b/app/[locale]/disclosures/page.tsx index 5e4d03468..8654d2192 100644 --- a/app/[locale]/disclosures/page.tsx +++ b/app/[locale]/disclosures/page.tsx @@ -2,7 +2,8 @@ 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 { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; import Disclosures from './disclosures'; @@ -32,9 +33,14 @@ export default async function DisclosuresPage({ cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 000cfefeb..bca541295 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -151,7 +151,7 @@ export default async function HomePage({
-
+
); diff --git a/app/[locale]/privacy/page.tsx b/app/[locale]/privacy/page.tsx index a45c66492..c63355d2e 100644 --- a/app/[locale]/privacy/page.tsx +++ b/app/[locale]/privacy/page.tsx @@ -2,7 +2,8 @@ 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 { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; import PrivacyPolicy from './privacy-policy'; @@ -32,9 +33,14 @@ export default async function PrivacyPage({ cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/products/page.tsx b/app/[locale]/products/page.tsx index cd18759b1..e013e14c4 100644 --- a/app/[locale]/products/page.tsx +++ b/app/[locale]/products/page.tsx @@ -3,7 +3,8 @@ import { SupportedLocale } from 'components/layout/navbar/language-control'; import { ProductGrid } from 'components/grid/product-grid'; import Navbar from 'components/layout/navbar'; -import { getCart } from 'lib/shopify'; +import { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { Suspense } from 'react'; @@ -32,9 +33,14 @@ export default async function ProductPage({ cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/shop-list/page.tsx b/app/[locale]/shop-list/page.tsx index e44ad1929..0f63e9b6c 100644 --- a/app/[locale]/shop-list/page.tsx +++ b/app/[locale]/shop-list/page.tsx @@ -4,7 +4,8 @@ import Footer from 'components/layout/footer'; import Navbar from 'components/layout/navbar'; import { SupportedLocale } from 'components/layout/navbar/language-control'; import Prose from 'components/prose'; -import { getCart, getPage } from 'lib/shopify'; +import { getCart, getPage, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { notFound } from 'next/navigation'; import { Suspense } from 'react'; @@ -46,9 +47,14 @@ export default async function Page({ params }: { params: { locale?: SupportedLoc if (!page) return notFound(); + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: params?.locale?.toUpperCase() + }); + return (
- +
diff --git a/app/[locale]/stories/[handle]/layout.tsx b/app/[locale]/stories/[handle]/layout.tsx index 928cb9df9..5916e25a2 100644 --- a/app/[locale]/stories/[handle]/layout.tsx +++ b/app/[locale]/stories/[handle]/layout.tsx @@ -2,7 +2,8 @@ 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 { getCart, getProduct } from 'lib/shopify'; +import { Product } from 'lib/shopify/types'; import { cookies } from 'next/headers'; import { ReactNode, Suspense } from 'react'; @@ -31,9 +32,14 @@ export default async function BlogLayout({ cart = await getCart(cartId); } + const promotedItem: Product | undefined = await getProduct({ + handle: 'gift-bag-and-postcard-set', + language: locale?.toUpperCase() + }); + return (
- + {children}