From 1bc721de8313c15b837280a0a2e37c605af74560 Mon Sep 17 00:00:00 2001 From: B Date: Mon, 31 May 2021 19:44:08 -0300 Subject: [PATCH] Improved Categories (#339) * Improved Categories * Improved Categories * Improved Categories * Improved Categories * Improved Categories * Improved Categories --- components/common/Layout/Layout.tsx | 15 +++++++---- components/common/Navbar/Navbar.tsx | 26 ++++++++++++------- framework/bigcommerce/common/get-site-info.ts | 19 +++++++++++--- framework/bigcommerce/product/use-search.tsx | 2 +- framework/commerce/types.ts | 9 +++++++ framework/shopify/common/get-site-info.ts | 6 ++--- framework/shopify/utils/get-categories.ts | 12 +++------ framework/swell/common/get-site-info.ts | 4 +-- framework/swell/utils/get-categories.ts | 12 +++------ framework/vendure/common/get-site-info.ts | 8 +----- lib/defaults.ts | 14 ---------- pages/[...pages].tsx | 6 ++--- pages/cart.tsx | 4 ++- pages/index.tsx | 14 ++++------ pages/orders.tsx | 7 +++-- pages/product/[slug].tsx | 3 +++ pages/profile.tsx | 4 ++- pages/search.tsx | 10 +++---- pages/wishlist.tsx | 7 ++--- 19 files changed, 94 insertions(+), 88 deletions(-) delete mode 100644 lib/defaults.ts diff --git a/components/common/Layout/Layout.tsx b/components/common/Layout/Layout.tsx index 54749c46b..1e1a22967 100644 --- a/components/common/Layout/Layout.tsx +++ b/components/common/Layout/Layout.tsx @@ -8,10 +8,9 @@ import { Navbar, Footer } from '@components/common' import { useAcceptCookies } from '@lib/hooks/useAcceptCookies' import { Sidebar, Button, Modal, LoadingDots } from '@components/ui' import CartSidebarView from '@components/cart/CartSidebarView' - +import type { Page, Category } from '@commerce/types' import LoginView from '@components/auth/LoginView' import { CommerceProvider } from '@framework' -import type { Page } from '@framework/common/get-all-pages' const Loading = () => (
@@ -41,13 +40,13 @@ const FeatureBar = dynamic( interface Props { pageProps: { pages?: Page[] - commerceFeatures: Record + categories: Category[] } } const Layout: FC = ({ children, - pageProps: { commerceFeatures, ...pageProps }, + pageProps: { categories = [], ...pageProps }, }) => { const { displaySidebar, @@ -58,10 +57,16 @@ const Layout: FC = ({ } = useUI() const { acceptedCookies, onAcceptCookies } = useAcceptCookies() const { locale = 'en-US' } = useRouter() + + const navBarlinks = categories.slice(0, 2).map((c) => ({ + label: c.name, + href: `/search/${c.slug}`, + })) + return (
- +
{children}