forked from crowetic/commerce
Add current locale to commerce provider
This commit is contained in:
parent
3f337737e8
commit
e111d351bf
@ -1,14 +1,16 @@
|
|||||||
|
import { FC, useEffect, useState } from 'react'
|
||||||
import cn from 'classnames'
|
import cn from 'classnames'
|
||||||
import s from './Layout.module.css'
|
import { useRouter } from 'next/router'
|
||||||
import React, { FC, useEffect, useState } from 'react'
|
import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages'
|
||||||
|
import { CommerceProvider } from '@lib/bigcommerce'
|
||||||
import { CartSidebarView } from '@components/cart'
|
import { CartSidebarView } from '@components/cart'
|
||||||
import { Container, Sidebar, Button, Modal } from '@components/ui'
|
import { Container, Sidebar, Button, Modal } from '@components/ui'
|
||||||
import { Navbar, Featurebar, Footer } from '@components/core'
|
import { Navbar, Featurebar, Footer } from '@components/core'
|
||||||
import { LoginView, SignUpView } from '@components/auth'
|
import { LoginView, SignUpView } from '@components/auth'
|
||||||
import { useUI } from '@components/ui/context'
|
import { useUI } from '@components/ui/context'
|
||||||
import { usePreventScroll } from '@react-aria/overlays'
|
import { usePreventScroll } from '@react-aria/overlays'
|
||||||
import { CommerceProvider } from '@lib/bigcommerce'
|
import s from './Layout.module.css'
|
||||||
import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages'
|
|
||||||
interface Props {
|
interface Props {
|
||||||
pageProps: {
|
pageProps: {
|
||||||
pages?: Page[]
|
pages?: Page[]
|
||||||
@ -25,6 +27,7 @@ const Layout: FC<Props> = ({ children, pageProps }) => {
|
|||||||
} = useUI()
|
} = useUI()
|
||||||
const [acceptedCookies, setAcceptedCookies] = useState(false)
|
const [acceptedCookies, setAcceptedCookies] = useState(false)
|
||||||
const [hasScrolled, setHasScrolled] = useState(false)
|
const [hasScrolled, setHasScrolled] = useState(false)
|
||||||
|
const { locale = 'en-US' } = useRouter()
|
||||||
|
|
||||||
// TODO: Update code, add throttle and more.
|
// TODO: Update code, add throttle and more.
|
||||||
// TODO: Make sure to not do any unnecessary updates as it's doing right now
|
// TODO: Make sure to not do any unnecessary updates as it's doing right now
|
||||||
@ -47,7 +50,7 @@ const Layout: FC<Props> = ({ children, pageProps }) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommerceProvider locale="en-us">
|
<CommerceProvider locale={locale}>
|
||||||
<div className={cn(s.root)}>
|
<div className={cn(s.root)}>
|
||||||
<header
|
<header
|
||||||
className={cn(
|
className={cn(
|
||||||
|
@ -26,6 +26,11 @@ const ProductCard: FC<Props> = ({
|
|||||||
priority,
|
priority,
|
||||||
}) => {
|
}) => {
|
||||||
const src = p.images.edges?.[0]?.node.urlLarge!
|
const src = p.images.edges?.[0]?.node.urlLarge!
|
||||||
|
const { price } = usePrice({
|
||||||
|
amount: p.prices?.price?.value,
|
||||||
|
baseAmount: p.prices?.retailPrice?.value,
|
||||||
|
currencyCode: p.prices?.price?.currencyCode!,
|
||||||
|
})
|
||||||
|
|
||||||
if (variant === 'slim') {
|
if (variant === 'slim') {
|
||||||
return (
|
return (
|
||||||
@ -47,12 +52,6 @@ const ProductCard: FC<Props> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { price } = usePrice({
|
|
||||||
amount: p.prices?.price?.value,
|
|
||||||
baseAmount: p.prices?.retailPrice?.value,
|
|
||||||
currencyCode: p.prices?.price?.currencyCode!,
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={`product${p.path}`}>
|
<Link href={`product${p.path}`}>
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user