From 3e513eaf99e35a215bfd4f7e92c571c8c1279875 Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Tue, 8 Aug 2023 11:46:46 +0200 Subject: [PATCH] Updates --- app/[locale]/layout.tsx | 37 ++- components/cart/actions.ts | 69 +++++ components/cart/add-to-cart.tsx | 68 +++++ components/cart/button.tsx | 64 ----- components/cart/close-cart.tsx | 10 + components/cart/delete-item-button.tsx | 56 ++-- components/cart/edit-item-quantity-button.tsx | 67 +++-- components/cart/index.tsx | 15 +- components/cart/modal.tsx | 244 +++++++++--------- components/cart/open-cart.tsx | 24 ++ components/grid/index.tsx | 26 -- components/grid/three-items.tsx | 53 ---- components/grid/tile.tsx | 70 ----- components/layout/footer/copyright.tsx | 2 - components/layout/header/header.tsx | 41 +-- components/layout/product-grid-items.tsx | 29 --- components/modules/hero/hero.tsx | 2 +- components/preview-suspense.tsx | 4 - components/price.tsx | 24 ++ components/product/variant-selector.tsx | 129 ++++----- components/prose.tsx | 2 +- components/ui/product-card/product-card.tsx | 7 - components/ui/wishlist-button/index.ts | 1 - .../ui/wishlist-button/wishlist-button.tsx | 79 ------ lib/constants.tsx | 25 -- lib/storm/types/product.ts | 55 ---- package.json | 6 +- 27 files changed, 449 insertions(+), 760 deletions(-) create mode 100644 components/cart/actions.ts create mode 100644 components/cart/add-to-cart.tsx delete mode 100644 components/cart/button.tsx create mode 100644 components/cart/close-cart.tsx create mode 100644 components/cart/open-cart.tsx delete mode 100644 components/grid/index.tsx delete mode 100644 components/grid/three-items.tsx delete mode 100644 components/grid/tile.tsx delete mode 100644 components/layout/product-grid-items.tsx delete mode 100644 components/preview-suspense.tsx create mode 100644 components/price.tsx delete mode 100644 components/ui/wishlist-button/index.ts delete mode 100644 components/ui/wishlist-button/wishlist-button.tsx diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 105907983..e8999055b 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -1,10 +1,9 @@ import Footer from 'components/layout/footer/footer'; import Header from 'components/layout/header/header'; -import { NextIntlClientProvider } from 'next-intl'; +import { useLocale } from 'next-intl'; import { Inter } from 'next/font/google'; import { notFound } from 'next/navigation'; import { ReactNode } from 'react'; -import { supportedLanguages } from '../../i18n-config'; import './globals.css'; export const metadata = { @@ -33,34 +32,30 @@ const inter = Inter({ variable: '--font-inter' }); -export function generateStaticParams() { - return supportedLanguages.locales.map((locale) => ({ locale: locale.id })); -} +// export function generateStaticParams() { +// return supportedLanguages.locales.map((locale) => ({ locale: locale.id })); +// } -interface LocaleLayoutProps { +export default function LocaleLayout({ + children, + params +}: { children: ReactNode; - params: { - locale: string; - }; -} + params: { locale: string }; +}) { + const locale = useLocale(); -export default async function LocaleLayout({ children, params: { locale } }: LocaleLayoutProps) { - let messages; - - try { - messages = (await import(`../../messages/${locale}.json`)).default; - } catch (error) { + // Show a 404 error if the user requests an unknown locale + if (params.locale !== locale) { notFound(); } return ( - -
-
{children}
-