mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 07:56:59 +00:00
updates
This commit is contained in:
parent
206d221f34
commit
863c2c5b6e
@ -1,5 +1,6 @@
|
|||||||
import pageTemplates from "components/agility-pageTemplates"
|
import pageTemplates from "components/agility-pageTemplates"
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
|
import { Text } from '@components/ui'
|
||||||
|
|
||||||
const AgilityPage = ({ agilityProps, error, revalidate }: { agilityProps: any, error?: any, revalidate?: any }) => {
|
const AgilityPage = ({ agilityProps, error, revalidate }: { agilityProps: any, error?: any, revalidate?: any }) => {
|
||||||
|
|
||||||
@ -20,7 +21,12 @@ const AgilityPage = ({ agilityProps, error, revalidate }: { agilityProps: any, e
|
|||||||
<Head>
|
<Head>
|
||||||
<title>Page Not Found - {pageTitle}</title>
|
<title>Page Not Found - {pageTitle}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<div className="m-8 text-center" >Page not found.</div>
|
<div className="max-w-2xl mx-8 sm:mx-auto py-20 flex flex-col items-center justify-center fit">
|
||||||
|
<Text variant="heading">Not Found</Text>
|
||||||
|
<Text className="">
|
||||||
|
The requested page doesn't exist or you don't have access to it.
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -37,6 +43,9 @@ const AgilityPage = ({ agilityProps, error, revalidate }: { agilityProps: any, e
|
|||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{agilityProps.sitemapNode?.title} - {pageTitle}</title>
|
<title>{agilityProps.sitemapNode?.title} - {pageTitle}</title>
|
||||||
|
<meta name="description" content={agilityProps.page?.seo?.metaDescription} />
|
||||||
|
<meta name="generator" content="Agility CMS" />
|
||||||
|
<meta name="agility_timestamp" content={new Date().toLocaleString()} />
|
||||||
</Head>
|
</Head>
|
||||||
<AgilityPageTemplate {...agilityProps} />
|
<AgilityPageTemplate {...agilityProps} />
|
||||||
</>
|
</>
|
||||||
|
@ -22,23 +22,27 @@ const Footer: FC<Props> = ({ className, pages, agilityProps }) => {
|
|||||||
const { sitePages } = usePages(pages)
|
const { sitePages } = usePages(pages)
|
||||||
const rootClassName = cn(s.root, className)
|
const rootClassName = cn(s.root, className)
|
||||||
|
|
||||||
const siteData = agilityProps.globalData["sitedata"]
|
const siteData = agilityProps?.globalData["sitedata"] || null
|
||||||
|
|
||||||
|
const agilityLinks = siteData?.links || []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer className={rootClassName}>
|
<footer className={rootClassName}>
|
||||||
<Container>
|
<Container>
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 border-b border-accent-2 py-12 text-primary bg-primary transition-colors duration-150">
|
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 border-b border-accent-2 py-12 text-primary bg-primary transition-colors duration-150">
|
||||||
<div className="col-span-1 lg:col-span-2">
|
<div className="col-span-1 lg:col-span-2">
|
||||||
|
{ siteData &&
|
||||||
<Link href="/">
|
<Link href="/">
|
||||||
<a className="flex flex-initial items-center font-bold md:mr-24 ">
|
<a className="flex flex-initial items-center font-bold md:mr-24 ">
|
||||||
<img src={siteData.logo.url} height="32" width="32" className="rounded-full border border-accent-6 mr-2" />
|
<img src={siteData.logo.url} height="32" width="32" className="rounded-full border border-accent-6 mr-2" />
|
||||||
<span>{siteData.name}</span>
|
<span>{siteData.name}</span>
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-1 lg:col-span-8">
|
<div className="col-span-1 lg:col-span-8">
|
||||||
<div className="grid md:grid-rows-4 md:grid-cols-3 md:grid-flow-col">
|
<div className="grid md:grid-rows-4 md:grid-cols-3 md:grid-flow-col">
|
||||||
{[...links, ...sitePages, ...siteData.links].map((page) => (
|
{[...links, ...sitePages, ...agilityLinks].map((page) => (
|
||||||
<span key={page.url} className="py-3 md:py-0 md:pb-4">
|
<span key={page.url} className="py-3 md:py-0 md:pb-4">
|
||||||
<Link href={page.url!}>
|
<Link href={page.url!}>
|
||||||
<a className="text-accent-9 hover:text-accent-6 transition ease-in-out duration-150">
|
<a className="text-accent-9 hover:text-accent-6 transition ease-in-out duration-150">
|
||||||
|
@ -6,7 +6,7 @@ import config from '@config/seo.json'
|
|||||||
const Head: FC = () => {
|
const Head: FC = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DefaultSeo {...config} />
|
{/* MOD - JOEL VARTY - this is set in the AgilityPage.tsx component <DefaultSeo {...config} /> */}
|
||||||
<NextHead>
|
<NextHead>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="manifest" href="/site.webmanifest" key="site-manifest" />
|
<link rel="manifest" href="/site.webmanifest" key="site-manifest" />
|
||||||
|
@ -16,18 +16,20 @@ interface NavbarProps {
|
|||||||
|
|
||||||
const Navbar: FC<NavbarProps> = ({ links, agilityProps }) => {
|
const Navbar: FC<NavbarProps> = ({ links, agilityProps }) => {
|
||||||
|
|
||||||
const siteData = agilityProps.globalData["sitedata"]
|
const siteData = agilityProps?.globalData["sitedata"] || null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavbarRoot>
|
<NavbarRoot>
|
||||||
<Container>
|
<Container>
|
||||||
<div className={s.nav}>
|
<div className={s.nav}>
|
||||||
<div className="flex items-center flex-1">
|
<div className="flex items-center flex-1">
|
||||||
|
{siteData &&
|
||||||
<Link href="/">
|
<Link href="/">
|
||||||
<a className={s.logo} aria-label="Logo">
|
<a className={s.logo} aria-label="Logo">
|
||||||
<img src={siteData.logo.url} alt={siteData.logo.label} height="32" width="32" className="rounded-full border border-accent-6" />
|
<img src={siteData.logo.url} alt={siteData.logo.label} height="32" width="32" className="rounded-full border border-accent-6" />
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
|
}
|
||||||
<nav className={s.navMenu}>
|
<nav className={s.navMenu}>
|
||||||
<Link href="/search">
|
<Link href="/search">
|
||||||
<a className={s.link}>All</a>
|
<a className={s.link}>All</a>
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
import type {
|
|
||||||
GetStaticPathsContext,
|
|
||||||
GetStaticPropsContext,
|
|
||||||
InferGetStaticPropsType,
|
|
||||||
} from 'next'
|
|
||||||
import commerce from '@lib/api/commerce'
|
|
||||||
import { Text } from '@components/ui'
|
|
||||||
import { Layout } from '@components/common'
|
|
||||||
import getSlug from '@lib/get-slug'
|
|
||||||
import { missingLocaleInPages } from '@lib/usage-warns'
|
|
||||||
import type { Page } from '@commerce/types/page'
|
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
|
||||||
preview,
|
|
||||||
params,
|
|
||||||
locale,
|
|
||||||
locales,
|
|
||||||
}: GetStaticPropsContext<{ pages: string[] }>) {
|
|
||||||
const config = { locale, locales }
|
|
||||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
||||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
||||||
const { pages } = await pagesPromise
|
|
||||||
const { categories } = await siteInfoPromise
|
|
||||||
const path = params?.pages.join('/')
|
|
||||||
const slug = locale ? `${locale}/${path}` : path
|
|
||||||
const pageItem = pages.find((p: Page) =>
|
|
||||||
p.url ? getSlug(p.url) === slug : false
|
|
||||||
)
|
|
||||||
const data =
|
|
||||||
pageItem &&
|
|
||||||
(await commerce.getPage({
|
|
||||||
variables: { id: pageItem.id! },
|
|
||||||
config,
|
|
||||||
preview,
|
|
||||||
}))
|
|
||||||
|
|
||||||
const page = data?.page
|
|
||||||
|
|
||||||
if (!page) {
|
|
||||||
// We throw to make sure this fails at build time as this is never expected to happen
|
|
||||||
throw new Error(`Page with slug '${slug}' not found`)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: { pages, page, categories },
|
|
||||||
revalidate: 60 * 60, // Every hour
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getStaticPaths({ locales }: GetStaticPathsContext) {
|
|
||||||
const config = { locales }
|
|
||||||
const { pages }: { pages: Page[] } = await commerce.getAllPages({ config })
|
|
||||||
const [invalidPaths, log] = missingLocaleInPages()
|
|
||||||
const paths = pages
|
|
||||||
.map((page) => page.url)
|
|
||||||
.filter((url) => {
|
|
||||||
if (!url || !locales) return url
|
|
||||||
// If there are locales, only include the pages that include one of the available locales
|
|
||||||
if (locales.includes(getSlug(url).split('/')[0])) return url
|
|
||||||
|
|
||||||
invalidPaths.push(url)
|
|
||||||
})
|
|
||||||
log()
|
|
||||||
|
|
||||||
return {
|
|
||||||
paths,
|
|
||||||
fallback: 'blocking',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Pages({
|
|
||||||
page,
|
|
||||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
return router.isFallback ? (
|
|
||||||
<h1>Loading...</h1> // TODO (BC) Add Skeleton Views
|
|
||||||
) : (
|
|
||||||
<div className="max-w-2xl mx-8 sm:mx-auto py-20">
|
|
||||||
{page?.body && <Text html={page.body} />}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Pages.Layout = Layout
|
|
@ -1,177 +0,0 @@
|
|||||||
import type { GetStaticPropsContext } from 'next'
|
|
||||||
import useCart from '@framework/cart/use-cart'
|
|
||||||
import usePrice from '@framework/product/use-price'
|
|
||||||
import commerce from '@lib/api/commerce'
|
|
||||||
import { Layout } from '@components/common'
|
|
||||||
import { Button, Text } from '@components/ui'
|
|
||||||
import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons'
|
|
||||||
import { CartItem } from '@components/cart'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
|
||||||
preview,
|
|
||||||
locale,
|
|
||||||
locales,
|
|
||||||
}: GetStaticPropsContext) {
|
|
||||||
const config = { locale, locales }
|
|
||||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
||||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
||||||
const { pages } = await pagesPromise
|
|
||||||
const { categories } = await siteInfoPromise
|
|
||||||
return {
|
|
||||||
props: { pages, categories },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Cart() {
|
|
||||||
const error = null
|
|
||||||
const success = null
|
|
||||||
const { data, isLoading, isEmpty } = useCart()
|
|
||||||
|
|
||||||
const { price: subTotal } = usePrice(
|
|
||||||
data && {
|
|
||||||
amount: Number(data.subtotalPrice),
|
|
||||||
currencyCode: data.currency.code,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
const { price: total } = usePrice(
|
|
||||||
data && {
|
|
||||||
amount: Number(data.totalPrice),
|
|
||||||
currencyCode: data.currency.code,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="grid lg:grid-cols-12 w-full max-w-7xl mx-auto">
|
|
||||||
<div className="lg:col-span-8">
|
|
||||||
{isLoading || isEmpty ? (
|
|
||||||
<div className="flex-1 px-12 py-24 flex flex-col justify-center items-center ">
|
|
||||||
<span className="border border-dashed border-secondary flex items-center justify-center w-16 h-16 bg-primary p-12 rounded-lg text-primary">
|
|
||||||
<Bag className="absolute" />
|
|
||||||
</span>
|
|
||||||
<h2 className="pt-6 text-2xl font-bold tracking-wide text-center">
|
|
||||||
Your cart is empty
|
|
||||||
</h2>
|
|
||||||
<p className="text-accent-6 px-10 text-center pt-2">
|
|
||||||
Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
) : error ? (
|
|
||||||
<div className="flex-1 px-4 flex flex-col justify-center items-center">
|
|
||||||
<span className="border border-white rounded-full flex items-center justify-center w-16 h-16">
|
|
||||||
<Cross width={24} height={24} />
|
|
||||||
</span>
|
|
||||||
<h2 className="pt-6 text-xl font-light text-center">
|
|
||||||
We couldn’t process the purchase. Please check your card
|
|
||||||
information and try again.
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
) : success ? (
|
|
||||||
<div className="flex-1 px-4 flex flex-col justify-center items-center">
|
|
||||||
<span className="border border-white rounded-full flex items-center justify-center w-16 h-16">
|
|
||||||
<Check />
|
|
||||||
</span>
|
|
||||||
<h2 className="pt-6 text-xl font-light text-center">
|
|
||||||
Thank you for your order.
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="px-4 sm:px-6 flex-1">
|
|
||||||
<Text variant="pageHeading">My Cart</Text>
|
|
||||||
<Text variant="sectionHeading">Review your Order</Text>
|
|
||||||
<ul className="py-6 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-b border-accent-2">
|
|
||||||
{data!.lineItems.map((item: any) => (
|
|
||||||
<CartItem
|
|
||||||
key={item.id}
|
|
||||||
item={item}
|
|
||||||
currencyCode={data?.currency.code!}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
<div className="my-6">
|
|
||||||
<Text>
|
|
||||||
Before you leave, take a look at these items. We picked them
|
|
||||||
just for you
|
|
||||||
</Text>
|
|
||||||
<div className="flex py-6 space-x-6">
|
|
||||||
{[1, 2, 3, 4, 5, 6].map((x) => (
|
|
||||||
<div
|
|
||||||
key={x}
|
|
||||||
className="border border-accent-3 w-full h-24 bg-accent-2 bg-opacity-50 transform cursor-pointer hover:scale-110 duration-75"
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="lg:col-span-4">
|
|
||||||
<div className="flex-shrink-0 px-4 py-24 sm:px-6">
|
|
||||||
{process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED && (
|
|
||||||
<>
|
|
||||||
{/* Shipping Address */}
|
|
||||||
{/* Only available with customCheckout set to true - Meaning that the provider does offer checkout functionality. */}
|
|
||||||
<div className="rounded-md border border-accent-2 px-6 py-6 mb-4 text-center flex items-center justify-center cursor-pointer hover:border-accent-4">
|
|
||||||
<div className="mr-5">
|
|
||||||
<MapPin />
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-center font-medium">
|
|
||||||
<span className="uppercase">+ Add Shipping Address</span>
|
|
||||||
{/* <span>
|
|
||||||
1046 Kearny Street.<br/>
|
|
||||||
San Franssisco, California
|
|
||||||
</span> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* Payment Method */}
|
|
||||||
{/* Only available with customCheckout set to true - Meaning that the provider does offer checkout functionality. */}
|
|
||||||
<div className="rounded-md border border-accent-2 px-6 py-6 mb-4 text-center flex items-center justify-center cursor-pointer hover:border-accent-4">
|
|
||||||
<div className="mr-5">
|
|
||||||
<CreditCard />
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-center font-medium">
|
|
||||||
<span className="uppercase">+ Add Payment Method</span>
|
|
||||||
{/* <span>VISA #### #### #### 2345</span> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<div className="border-t border-accent-2">
|
|
||||||
<ul className="py-3">
|
|
||||||
<li className="flex justify-between py-1">
|
|
||||||
<span>Subtotal</span>
|
|
||||||
<span>{subTotal}</span>
|
|
||||||
</li>
|
|
||||||
<li className="flex justify-between py-1">
|
|
||||||
<span>Taxes</span>
|
|
||||||
<span>Calculated at checkout</span>
|
|
||||||
</li>
|
|
||||||
<li className="flex justify-between py-1">
|
|
||||||
<span>Estimated Shipping</span>
|
|
||||||
<span className="font-bold tracking-wide">FREE</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div className="flex justify-between border-t border-accent-2 py-3 font-bold mb-10">
|
|
||||||
<span>Total</span>
|
|
||||||
<span>{total}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-row justify-end">
|
|
||||||
<div className="w-full lg:w-72">
|
|
||||||
{isEmpty ? (
|
|
||||||
<Button href="/" Component="a" width="100%">
|
|
||||||
Continue Shopping
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Button href="/checkout" Component="a" width="100%">
|
|
||||||
Proceed to Checkout
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Cart.Layout = Layout
|
|
@ -1,42 +0,0 @@
|
|||||||
import type { GetStaticPropsContext } from 'next'
|
|
||||||
import commerce from '@lib/api/commerce'
|
|
||||||
import { Bag } from '@components/icons'
|
|
||||||
import { Layout } from '@components/common'
|
|
||||||
import { Container, Text } from '@components/ui'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
|
||||||
preview,
|
|
||||||
locale,
|
|
||||||
locales,
|
|
||||||
}: GetStaticPropsContext) {
|
|
||||||
const config = { locale, locales }
|
|
||||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
||||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
||||||
const { pages } = await pagesPromise
|
|
||||||
const { categories } = await siteInfoPromise
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: { pages, categories },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Orders() {
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<Text variant="pageHeading">My Orders</Text>
|
|
||||||
<div className="flex-1 p-24 flex flex-col justify-center items-center ">
|
|
||||||
<span className="border border-dashed border-secondary rounded-full flex items-center justify-center w-16 h-16 p-12 bg-primary text-primary">
|
|
||||||
<Bag className="absolute" />
|
|
||||||
</span>
|
|
||||||
<h2 className="pt-6 text-2xl font-bold tracking-wide text-center">
|
|
||||||
No orders found
|
|
||||||
</h2>
|
|
||||||
<p className="text-accent-6 px-10 text-center pt-2">
|
|
||||||
Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Orders.Layout = Layout
|
|
@ -1,81 +0,0 @@
|
|||||||
import type {
|
|
||||||
GetStaticPathsContext,
|
|
||||||
GetStaticPropsContext,
|
|
||||||
InferGetStaticPropsType,
|
|
||||||
} from 'next'
|
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
import commerce from '@lib/api/commerce'
|
|
||||||
import { Layout } from '@components/common'
|
|
||||||
import { ProductView } from '@components/product'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
|
||||||
params,
|
|
||||||
locale,
|
|
||||||
locales,
|
|
||||||
preview,
|
|
||||||
}: GetStaticPropsContext<{ slug: string }>) {
|
|
||||||
const config = { locale, locales }
|
|
||||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
||||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
||||||
const productPromise = commerce.getProduct({
|
|
||||||
variables: { slug: params!.slug },
|
|
||||||
config,
|
|
||||||
preview,
|
|
||||||
})
|
|
||||||
|
|
||||||
const allProductsPromise = commerce.getAllProducts({
|
|
||||||
variables: { first: 4 },
|
|
||||||
config,
|
|
||||||
preview,
|
|
||||||
})
|
|
||||||
const { pages } = await pagesPromise
|
|
||||||
const { categories } = await siteInfoPromise
|
|
||||||
const { product } = await productPromise
|
|
||||||
const { products: relatedProducts } = await allProductsPromise
|
|
||||||
|
|
||||||
if (!product) {
|
|
||||||
throw new Error(`Product with slug '${params!.slug}' not found`)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
pages,
|
|
||||||
product,
|
|
||||||
relatedProducts,
|
|
||||||
categories,
|
|
||||||
},
|
|
||||||
revalidate: 200,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getStaticPaths({ locales }: GetStaticPathsContext) {
|
|
||||||
const { products } = await commerce.getAllProductPaths()
|
|
||||||
|
|
||||||
return {
|
|
||||||
paths: locales
|
|
||||||
? locales.reduce<string[]>((arr, locale) => {
|
|
||||||
// Add a product path for every locale
|
|
||||||
products.forEach((product: any) => {
|
|
||||||
arr.push(`/${locale}/product${product.path}`)
|
|
||||||
})
|
|
||||||
return arr
|
|
||||||
}, [])
|
|
||||||
: products.map((product: any) => `/product${product.path}`),
|
|
||||||
fallback: 'blocking',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Slug({
|
|
||||||
product,
|
|
||||||
relatedProducts,
|
|
||||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
return router.isFallback ? (
|
|
||||||
<h1>Loading...</h1>
|
|
||||||
) : (
|
|
||||||
<ProductView product={product} relatedProducts={relatedProducts} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Slug.Layout = Layout
|
|
@ -1,48 +0,0 @@
|
|||||||
import type { GetStaticPropsContext } from 'next'
|
|
||||||
import useCustomer from '@framework/customer/use-customer'
|
|
||||||
import commerce from '@lib/api/commerce'
|
|
||||||
import { Layout } from '@components/common'
|
|
||||||
import { Container, Text } from '@components/ui'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
|
||||||
preview,
|
|
||||||
locale,
|
|
||||||
locales,
|
|
||||||
}: GetStaticPropsContext) {
|
|
||||||
const config = { locale, locales }
|
|
||||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
||||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
||||||
const { pages } = await pagesPromise
|
|
||||||
const { categories } = await siteInfoPromise
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: { pages, categories },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Profile() {
|
|
||||||
const { data } = useCustomer()
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<Text variant="pageHeading">My Profile</Text>
|
|
||||||
{data && (
|
|
||||||
<div className="grid lg:grid-cols-12">
|
|
||||||
<div className="lg:col-span-8 pr-4">
|
|
||||||
<div>
|
|
||||||
<Text variant="sectionHeading">Full Name</Text>
|
|
||||||
<span>
|
|
||||||
{data.firstName} {data.lastName}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="mt-5">
|
|
||||||
<Text variant="sectionHeading">Email</Text>
|
|
||||||
<span>{data.email}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Container>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Profile.Layout = Layout
|
|
@ -1,9 +0,0 @@
|
|||||||
import { getSearchStaticProps } from '@lib/search-props'
|
|
||||||
import type { GetStaticPropsContext } from 'next'
|
|
||||||
import Search from '@components/search'
|
|
||||||
|
|
||||||
export async function getStaticProps(context: GetStaticPropsContext) {
|
|
||||||
return getSearchStaticProps(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Search
|
|
@ -1,71 +0,0 @@
|
|||||||
import type { GetStaticPropsContext } from 'next'
|
|
||||||
import commerce from '@lib/api/commerce'
|
|
||||||
import { Heart } from '@components/icons'
|
|
||||||
import { Layout } from '@components/common'
|
|
||||||
import { Text, Container } from '@components/ui'
|
|
||||||
import { useCustomer } from '@framework/customer'
|
|
||||||
import { WishlistCard } from '@components/wishlist'
|
|
||||||
import useWishlist from '@framework/wishlist/use-wishlist'
|
|
||||||
|
|
||||||
export async function getStaticProps({
|
|
||||||
preview,
|
|
||||||
locale,
|
|
||||||
locales,
|
|
||||||
}: GetStaticPropsContext) {
|
|
||||||
// Disabling page if Feature is not available
|
|
||||||
if (!process.env.COMMERCE_WISHLIST_ENABLED) {
|
|
||||||
return {
|
|
||||||
notFound: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = { locale, locales }
|
|
||||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
||||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
||||||
const { pages } = await pagesPromise
|
|
||||||
const { categories } = await siteInfoPromise
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
pages,
|
|
||||||
categories,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Wishlist() {
|
|
||||||
const { data: customer } = useCustomer()
|
|
||||||
// @ts-ignore Shopify - Fix this types
|
|
||||||
const { data, isLoading, isEmpty } = useWishlist({ includeProducts: true })
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<div className="mt-3 mb-20">
|
|
||||||
<Text variant="pageHeading">My Wishlist</Text>
|
|
||||||
<div className="group flex flex-col">
|
|
||||||
{isLoading || isEmpty ? (
|
|
||||||
<div className="flex-1 px-12 py-24 flex flex-col justify-center items-center ">
|
|
||||||
<span className="border border-dashed border-secondary flex items-center justify-center w-16 h-16 bg-primary p-12 rounded-lg text-primary">
|
|
||||||
<Heart className="absolute" />
|
|
||||||
</span>
|
|
||||||
<h2 className="pt-6 text-2xl font-bold tracking-wide text-center">
|
|
||||||
Your wishlist is empty
|
|
||||||
</h2>
|
|
||||||
<p className="text-accent-6 px-10 text-center pt-2">
|
|
||||||
Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
data &&
|
|
||||||
// @ts-ignore Shopify - Fix this types
|
|
||||||
data.items?.map((item) => (
|
|
||||||
<WishlistCard key={item.id} product={item.product! as any} />
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Wishlist.Layout = Layout
|
|
Loading…
x
Reference in New Issue
Block a user