This PR adds an ecommerce plugin package with both a Payload plugin and React UI utilities for the frontend. It also adds a new ecommerce template and new ecommerce test suite. It also makes a change to the `cpa` package to accept a `--version` flag to install a specific version of Payload defaulting to the latest.
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import configPromise, { currenciesConfig } from '@payload-config'
|
|
import { Cart } from '@/components/Cart.js'
|
|
import { getPayload } from 'payload'
|
|
import React from 'react'
|
|
import { Product } from '@/components/Product.js'
|
|
import { CurrencySelector } from '@/components/CurrencySelector.js'
|
|
import { Payments } from '@/components/Payments.js'
|
|
|
|
export const Page = async () => {
|
|
const payload = await getPayload({
|
|
config: configPromise,
|
|
})
|
|
|
|
const products = await payload.find({
|
|
collection: 'products',
|
|
depth: 2,
|
|
limit: 10,
|
|
})
|
|
|
|
return (
|
|
<div>
|
|
<h1>Shop Page - {payload?.config?.collections?.length} collections</h1>
|
|
|
|
{products?.docs?.length > 0 ? (
|
|
<ul>
|
|
{products.docs.map((product) => (
|
|
<li key={product.id}>
|
|
<Product product={product} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
) : (
|
|
<p>No products found.</p>
|
|
)}
|
|
|
|
<Cart />
|
|
|
|
<CurrencySelector currenciesConfig={currenciesConfig} />
|
|
|
|
<Payments currenciesConfig={currenciesConfig} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default Page
|