diff --git a/app/home/(user)/(dashboard)/cart/loading.tsx b/app/home/(user)/(dashboard)/cart/loading.tsx new file mode 100644 index 0000000..f093295 --- /dev/null +++ b/app/home/(user)/(dashboard)/cart/loading.tsx @@ -0,0 +1,5 @@ +import SkeletonCartPage from '~/medusa/modules/skeletons/templates/skeleton-cart-page'; + +export default function Loading() { + return ; +} diff --git a/app/home/(user)/(dashboard)/cart/not-found.tsx b/app/home/(user)/(dashboard)/cart/not-found.tsx new file mode 100644 index 0000000..a2f02bd --- /dev/null +++ b/app/home/(user)/(dashboard)/cart/not-found.tsx @@ -0,0 +1,21 @@ +import { Metadata } from 'next'; + +import InteractiveLink from '~/medusa/modules/common/components/interactive-link'; + +export const metadata: Metadata = { + title: '404', + description: 'Something went wrong', +}; + +export default function NotFound() { + return ( +
+

Page not found

+

+ The cart you tried to access does not exist. Clear your cookies and try + again. +

+ Go to frontpage +
+ ); +} diff --git a/app/home/(user)/(dashboard)/cart/page.tsx b/app/home/(user)/(dashboard)/cart/page.tsx new file mode 100644 index 0000000..72fc72b --- /dev/null +++ b/app/home/(user)/(dashboard)/cart/page.tsx @@ -0,0 +1,23 @@ +import { Metadata } from 'next'; + +import { notFound } from 'next/navigation'; + +import { retrieveCart } from '~/medusa/lib/data/cart'; +import { retrieveCustomer } from '~/medusa/lib/data/customer'; +import CartTemplate from '~/medusa/modules/cart/templates'; + +export const metadata: Metadata = { + title: 'Cart', + description: 'View your cart', +}; + +export default async function Cart() { + const cart = await retrieveCart().catch((error) => { + console.error(error); + return notFound(); + }); + + const customer = await retrieveCustomer(); + + return ; +} diff --git a/app/home/(user)/_components/home-menu-navigation.tsx b/app/home/(user)/_components/home-menu-navigation.tsx index cc77954..f1915b4 100644 --- a/app/home/(user)/_components/home-menu-navigation.tsx +++ b/app/home/(user)/_components/home-menu-navigation.tsx @@ -1,16 +1,15 @@ +import Link from 'next/link'; +import { ShoppingCart } from 'lucide-react'; import { Trans } from '@kit/ui/trans'; - import { AppLogo } from '~/components/app-logo'; import { ProfileAccountDropdownContainer } from '~/components/personal-account-dropdown-container'; import { Search } from '~/components/ui/search'; +import { SIDEBAR_WIDTH_PROPERTY } from '@/packages/ui/src/shadcn/constants'; +import { Button } from '@kit/ui/button'; -import { SIDEBAR_WIDTH_PROPERTY } from '../../../../packages/ui/src/shadcn/constants'; -// home imports import { UserNotifications } from '../_components/user-notifications'; import { type UserWorkspace } from '../_lib/server/load-user-workspace'; -import { Button } from '@kit/ui/button'; -import { ShoppingCart } from 'lucide-react'; export function HomeMenuNavigation(props: { workspace: UserWorkspace }) { const { workspace, user, accounts } = props.workspace; @@ -30,10 +29,12 @@ export function HomeMenuNavigation(props: { workspace: UserWorkspace }) { - + + +
diff --git a/app/join/page.tsx b/app/join/page.tsx index 1c1b061..a8ae240 100644 --- a/app/join/page.tsx +++ b/app/join/page.tsx @@ -68,13 +68,11 @@ async function JoinTeamAccountPage(props: JoinTeamAccountPageProps) { const invitation = await api.getInvitation(adminClient, token); // the invitation is not found or expired - if (!invitation) { return ( ); - } // we need to verify the user isn't already in the account // we do so by checking if the user can read the account diff --git a/app/store/[countryCode]/(main)/layout.tsx b/app/store/[countryCode]/(main)/layout.tsx index 31d1512..61aca29 100644 --- a/app/store/[countryCode]/(main)/layout.tsx +++ b/app/store/[countryCode]/(main)/layout.tsx @@ -1,46 +1,117 @@ -import { Metadata } from 'next'; +import { use } from 'react'; -import { StoreCartShippingOption } from '@medusajs/types'; +import { cookies } from 'next/headers'; -import { listCartOptions, retrieveCart } from '~/medusa/lib/data/cart'; -import { retrieveCustomer } from '~/medusa/lib/data/customer'; -import { getBaseURL } from '~/medusa/lib/util/env'; -import CartMismatchBanner from '~/medusa/modules/layout/components/cart-mismatch-banner'; -import Footer from '~/medusa/modules/layout/templates/footer'; -import Nav from '~/medusa/modules/layout/templates/nav'; -import FreeShippingPriceNudge from '~/medusa/modules/shipping/components/free-shipping-price-nudge'; +import { z } from 'zod'; -export const metadata: Metadata = { - metadataBase: new URL(getBaseURL()), -}; +import { UserWorkspaceContextProvider } from '@kit/accounts/components'; +import { Page, PageMobileNavigation, PageNavigation } from '@kit/ui/page'; +import { SidebarProvider } from '@kit/ui/shadcn-sidebar'; -export default async function PageLayout(props: { children: React.ReactNode }) { - const customer = await retrieveCustomer(); - const cart = await retrieveCart(); - let shippingOptions: StoreCartShippingOption[] = []; +import { AppLogo } from '~/components/app-logo'; +import { personalAccountNavigationConfig } from '~/config/personal-account-navigation.config'; +import { withI18n } from '~/lib/i18n/with-i18n'; +import { loadUserWorkspace } from '@/app/home/(user)/_lib/server/load-user-workspace'; +import { HomeSidebar } from '@/app/home/(user)/_components/home-sidebar'; +import { HomeMenuNavigation } from '@/app/home/(user)/_components/home-menu-navigation'; +import { HomeMobileNavigation } from '@/app/home/(user)/_components/home-mobile-navigation'; - if (cart) { - const { shipping_options } = await listCartOptions(); +function UserHomeLayout({ children }: React.PropsWithChildren) { + const state = use(getLayoutState()); - shippingOptions = shipping_options; + if (state.style === 'sidebar') { + return {children}; } + return {children}; +} + +export default withI18n(UserHomeLayout); + +function SidebarLayout({ children }: React.PropsWithChildren) { + const workspace = use(loadUserWorkspace()); + const state = use(getLayoutState()); + + return ( + + + + + + + + + + + + {children} + + + + ); +} + +function HeaderLayout({ children }: React.PropsWithChildren) { + const workspace = use(loadUserWorkspace()); + + return ( + + + + + + + + + + + + + + + + {children} + + + + + ); +} + +function MobileNavigation({ + workspace, +}: { + workspace: Awaited>; +}) { return ( <> -