Skip to content

Commit

Permalink
feat: add checkout page
Browse files Browse the repository at this point in the history
  • Loading branch information
VariableVic committed May 12, 2023
1 parent d9e00ff commit b8f154c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
13 changes: 9 additions & 4 deletions app/[page]/page.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,13 +13,15 @@ export async function generateMetadata({
}: {
params: { page: string };
}): Promise<Metadata> {
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: [
{
Expand All @@ -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();

Expand Down
9 changes: 9 additions & 0 deletions lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
<a href="https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-checkout-flow">our guide on implementing a checkout flow</a> to learn more`,
description: 'Checkout is not implemented yet in this template',
updatedAt: new Date().toISOString(),
createdAt: new Date().toISOString()
};
2 changes: 1 addition & 1 deletion lib/medusa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit b8f154c

Please sign in to comment.