MCPcopy
hub / github.com/joschan21/digitalhippo / Page

Function Page

src/app/product/[productId]/page.tsx:23–156  ·  view source on GitHub ↗
({ params }: PageProps)

Source from the content-addressed store, hash-verified

21]
22
23const Page = async ({ params }: PageProps) => {
24 const { productId } = params
25
26 const payload = await getPayloadClient()
27
28 const { docs: products } = await payload.find({
29 collection: 'products',
30 limit: 1,
31 where: {
32 id: {
33 equals: productId,
34 },
35 approvedForSale: {
36 equals: 'approved',
37 },
38 },
39 })
40
41 const [product] = products
42
43 if (!product) return notFound()
44
45 const label = PRODUCT_CATEGORIES.find(
46 ({ value }) => value === product.category
47 )?.label
48
49 const validUrls = product.images
50 .map(({ image }) =>
51 typeof image === 'string' ? image : image.url
52 )
53 .filter(Boolean) as string[]
54
55 return (
56 <MaxWidthWrapper className='bg-white'>
57 <div className='bg-white'>
58 <div className='mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:grid lg:max-w-7xl lg:grid-cols-2 lg:gap-x-8 lg:px-8'>
59 {/* Product Details */}
60 <div className='lg:max-w-lg lg:self-end'>
61 <ol className='flex items-center space-x-2'>
62 {BREADCRUMBS.map((breadcrumb, i) => (
63 <li key={breadcrumb.href}>
64 <div className='flex items-center text-sm'>
65 <Link
66 href={breadcrumb.href}
67 className='font-medium text-sm text-muted-foreground hover:text-gray-900'>
68 {breadcrumb.name}
69 </Link>
70 {i !== BREADCRUMBS.length - 1 ? (
71 <svg
72 viewBox='0 0 20 20'
73 fill='currentColor'
74 aria-hidden='true'
75 className='ml-2 h-5 w-5 flex-shrink-0 text-gray-300'>
76 <path d='M5.555 17.776l8-16 .894.448-8 16-.894-.448z' />
77 </svg>
78 ) : null}
79 </div>
80 </li>

Callers

nothing calls this directly

Calls 2

getPayloadClientFunction · 0.90
formatPriceFunction · 0.90

Tested by

no test coverage detected