import { PageOptions } from '@graphcommerce/framer-next-pages' import { ApolloCartErrorAlert, CartStartCheckout, CartTotals, EmptyCart, useCartQuery, } from '@graphcommerce/magento-cart' import { CartPageDocument } from '@graphcommerce/magento-cart-checkout' import { CouponAccordion } from '@graphcommerce/magento-cart-coupon' import { CartItem, CartItems } from '@graphcommerce/magento-cart-items' import { ConfigurableCartItem } from '@graphcommerce/magento-product-configurable' import { Money, PageMeta, StoreConfigDocument } from '@graphcommerce/magento-store' import { AnimatedRow, AppShellTitle, Button, GetStaticProps, iconShoppingBag, SheetShellHeader, Stepper, Title, iconChevronRight, SvgImage, } from '@graphcommerce/next-ui' import { Container, NoSsr } from '@material-ui/core' import { AnimatePresence } from 'framer-motion' import PageLink from 'next/link' import React from 'react' import SheetShell, { SheetShellProps } from '../components/AppShell/SheetShell' import apolloClient from '../lib/apolloClient' type Props = Record type GetPageStaticProps = GetStaticProps function CartPage() { const { data, error, loading } = useCartQuery(CartPageDocument, { returnPartialData: true }) const hasItems = (data?.cart?.total_quantity ?? 0) > 0 && typeof data?.cart?.prices?.grand_total?.value !== 'undefined' if (loading) return null return ( <> } divider={ } > {hasItems ? ( <> Cart Total: <Money {...data?.cart?.prices?.grand_total} /> </> ) : ( <>Cart</> )} {hasItems ? ( <> Cart Total: ) : ( {error && } )} ) } const pageOptions: PageOptions = { overlayGroup: 'checkout', SharedComponent: SheetShell, } CartPage.pageOptions = pageOptions export default CartPage export const getStaticProps: GetPageStaticProps = async ({ locale }) => { const client = apolloClient(locale, true) const conf = client.query({ query: StoreConfigDocument }) return { props: { apolloState: await conf.then(() => client.cache.extract()), variant: 'bottom', size: 'max', }, } }