From b8f154cdf5e13e6bba82e2a844e603cfbc857533 Mon Sep 17 00:00:00 2001 From: Victor Gerbrands Date: Fri, 12 May 2023 14:13:04 +0200 Subject: [PATCH] feat: add checkout page --- app/[page]/page.tsx | 13 +++++++++---- lib/constants.tsx | 9 +++++++++ lib/medusa/index.ts | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/[page]/page.tsx b/app/[page]/page.tsx index d2faf9760..aa29e26ab 100644 --- a/app/[page]/page.tsx +++ b/app/[page]/page.tsx @@ -1,6 +1,7 @@ import type { Metadata } from 'next'; import Prose from 'components/prose'; +import { CHECKOUT_PAGE_PROPS } from 'lib/constants'; import { notFound } from 'next/navigation'; export const runtime = 'edge'; @@ -12,13 +13,15 @@ export async function generateMetadata({ }: { params: { page: string }; }): Promise { - const page: any = null; + let page; + + params.page === 'checkout' && (page = CHECKOUT_PAGE_PROPS); if (!page) return notFound(); return { - title: page.seo?.title || page.title, - description: page.seo?.description || page.bodySummary, + title: page.title, + description: '', openGraph: { images: [ { @@ -35,7 +38,9 @@ export async function generateMetadata({ } export default async function Page({ params }: { params: { page: string } }) { - const page: any = null; + let page; + + params.page === 'checkout' && (page = CHECKOUT_PAGE_PROPS); if (!page) return notFound(); diff --git a/lib/constants.tsx b/lib/constants.tsx index 49e059002..849817b52 100644 --- a/lib/constants.tsx +++ b/lib/constants.tsx @@ -22,3 +22,12 @@ export const sorting: SortFilterItem[] = [ export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden'; export const DEFAULT_OPTION = 'Default Title'; + +export const CHECKOUT_PAGE_PROPS = { + title: 'Checkout', + body: `Checkout is not implemented yet in this template. Check out + our guide on implementing a checkout flow to learn more`, + description: 'Checkout is not implemented yet in this template', + updatedAt: new Date().toISOString(), + createdAt: new Date().toISOString() +}; diff --git a/lib/medusa/index.ts b/lib/medusa/index.ts index 1aa15221c..73bda0c54 100644 --- a/lib/medusa/index.ts +++ b/lib/medusa/index.ts @@ -74,7 +74,7 @@ export default async function medusaRequest( const reshapeCart = (cart: MedusaCart): Cart => { const lines = cart?.items?.map((item) => reshapeLineItem(item)) || []; const totalQuantity = lines.reduce((a, b) => a + b.quantity, 0); - const checkoutUrl = '/'; + const checkoutUrl = '/checkout'; // todo: implement medusa checkout flow const currencyCode = cart.region?.currency_code.toUpperCase() || 'USD'; let subtotalAmount = '0';