mirror of
https://github.com/vercel/commerce.git
synced 2025-06-28 17:31:22 +00:00
feat: add checkout page
This commit is contained in:
parent
d9e00ff560
commit
b8f154cdf5
@ -1,6 +1,7 @@
|
|||||||
import type { Metadata } from 'next';
|
import type { Metadata } from 'next';
|
||||||
|
|
||||||
import Prose from 'components/prose';
|
import Prose from 'components/prose';
|
||||||
|
import { CHECKOUT_PAGE_PROPS } from 'lib/constants';
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
@ -12,13 +13,15 @@ export async function generateMetadata({
|
|||||||
}: {
|
}: {
|
||||||
params: { page: string };
|
params: { page: string };
|
||||||
}): Promise<Metadata> {
|
}): Promise<Metadata> {
|
||||||
const page: any = null;
|
let page;
|
||||||
|
|
||||||
|
params.page === 'checkout' && (page = CHECKOUT_PAGE_PROPS);
|
||||||
|
|
||||||
if (!page) return notFound();
|
if (!page) return notFound();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: page.seo?.title || page.title,
|
title: page.title,
|
||||||
description: page.seo?.description || page.bodySummary,
|
description: '',
|
||||||
openGraph: {
|
openGraph: {
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
@ -35,7 +38,9 @@ export async function generateMetadata({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function Page({ params }: { params: { page: string } }) {
|
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();
|
if (!page) return notFound();
|
||||||
|
|
||||||
|
@ -22,3 +22,12 @@ export const sorting: SortFilterItem[] = [
|
|||||||
|
|
||||||
export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden';
|
export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden';
|
||||||
export const DEFAULT_OPTION = 'Default Title';
|
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()
|
||||||
|
};
|
||||||
|
@ -74,7 +74,7 @@ export default async function medusaRequest(
|
|||||||
const reshapeCart = (cart: MedusaCart): Cart => {
|
const reshapeCart = (cart: MedusaCart): Cart => {
|
||||||
const lines = cart?.items?.map((item) => reshapeLineItem(item)) || [];
|
const lines = cart?.items?.map((item) => reshapeLineItem(item)) || [];
|
||||||
const totalQuantity = lines.reduce((a, b) => a + b.quantity, 0);
|
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';
|
const currencyCode = cart.region?.currency_code.toUpperCase() || 'USD';
|
||||||
|
|
||||||
let subtotalAmount = '0';
|
let subtotalAmount = '0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user