diff --git a/components/commerce/hooks/useCommerce.ts b/components/commerce/hooks/useCommerce.ts index 985c536ba..cd17fcc73 100644 --- a/components/commerce/hooks/useCommerce.ts +++ b/components/commerce/hooks/useCommerce.ts @@ -1,10 +1,12 @@ import { useContext } from 'react' import { CommerceContext } from '../context' -export const useCommerce = () => { +const useCommerce = () => { const context = useContext(CommerceContext) if (context === undefined) { throw new Error(`useCommerce must be used within a CommerceProvider`) } return context } + +export default useCommerce diff --git a/components/commerce/index.ts b/components/commerce/index.ts index ff381c2c1..d45bcf437 100644 --- a/components/commerce/index.ts +++ b/components/commerce/index.ts @@ -1 +1,3 @@ export { default as useCart } from './hooks/useCart' +export { default as useCommerce } from './hooks/useCommerce' +export * from './context' diff --git a/components/common/Layout/Layout.tsx b/components/common/Layout/Layout.tsx index caad88b8c..f689fb3d7 100644 --- a/components/common/Layout/Layout.tsx +++ b/components/common/Layout/Layout.tsx @@ -1,16 +1,15 @@ import cn from 'classnames' import s from './Layout.module.css' -import { useRouter } from 'next/router' + import { usePreventScroll } from '@react-aria/overlays' import { FC, useCallback, useEffect, useState } from 'react' import { useUI } from '@components/ui/context' import { CartSidebarView } from '@components/cart' import { Navbar, Featurebar, Footer } from '@components/common' import { LoginView, SignUpView, ForgotPassword } from '@components/auth' -import { Container, Sidebar, Button, Modal, Toast } from '@components/ui' +import { Container, Sidebar, Button, Modal } from '@components/ui' import debounce from 'lodash.debounce' -import { CommerceProvider } from '@bigcommerce/storefront-data-hooks' import type { Page } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' interface Props { @@ -29,7 +28,6 @@ const Layout: FC = ({ children, pageProps }) => { } = useUI() const [acceptedCookies, setAcceptedCookies] = useState(false) const [hasScrolled, setHasScrolled] = useState(false) - const { locale = 'en-US' } = useRouter() usePreventScroll({ isDisabled: !(displaySidebar || displayModal), @@ -52,38 +50,36 @@ const Layout: FC = ({ children, pageProps }) => { }, [handleScroll]) return ( - -
-
- - - -
-
{children}
-
+
+
+ + + +
+
{children}
+
- {/** Aditional UI Components */} - - - + {/** Aditional UI Components */} + + + - - {modalView === 'LOGIN_VIEW' && } - {modalView === 'SIGNUP_VIEW' && } - {modalView === 'FORGOT_VIEW' && } - + + {modalView === 'LOGIN_VIEW' && } + {modalView === 'SIGNUP_VIEW' && } + {modalView === 'FORGOT_VIEW' && } + - setAcceptedCookies(true)}> - Accept cookies - - } - /> -
- + setAcceptedCookies(true)}> + Accept cookies + + } + /> +
) } diff --git a/pages/_app.tsx b/pages/_app.tsx index dabaaf8d0..794396a89 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -3,22 +3,26 @@ import 'keen-slider/keen-slider.min.css' import { FC } from 'react' import type { AppProps } from 'next/app' - -import { ManagedUIContext } from '@components/ui/context' import { Head } from '@components/common' +import { ManagedUIContext } from '@components/ui/context' + +import { useRouter } from 'next/router' +import { CommerceProvider } from '@bigcommerce/storefront-data-hooks' const Noop: FC = ({ children }) => <>{children} export default function MyApp({ Component, pageProps }: AppProps) { const Layout = (Component as any).Layout || Noop - + const { locale = 'en-US' } = useRouter() return ( <> - - - + + + + + )