@cimplify/sdk 0.38.5 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-JTU5P6GM.mjs → chunk-3WD6U5RD.mjs} +1 -83
  2. package/dist/chunk-BGCEKFLA.js +89 -0
  3. package/dist/chunk-IRJFDKFV.mjs +83 -0
  4. package/dist/{chunk-5VHKZTFJ.js → chunk-OMAP327U.js} +0 -87
  5. package/dist/index.js +34 -33
  6. package/dist/index.mjs +2 -1
  7. package/dist/react.js +47 -46
  8. package/dist/react.mjs +3 -2
  9. package/dist/server.d.mts +97 -0
  10. package/dist/server.d.ts +97 -0
  11. package/dist/server.js +107 -0
  12. package/dist/server.mjs +92 -0
  13. package/dist/styles.css +1 -1
  14. package/package.json +7 -1
  15. package/templates/storefront/app/about/page.tsx +61 -0
  16. package/templates/storefront/app/categories/[slug]/listing-client.tsx +19 -0
  17. package/templates/storefront/app/categories/[slug]/page.tsx +94 -57
  18. package/templates/storefront/app/collections/[slug]/listing-client.tsx +20 -0
  19. package/templates/storefront/app/collections/[slug]/page.tsx +94 -57
  20. package/templates/storefront/app/faq/page.tsx +122 -0
  21. package/templates/storefront/app/page.tsx +77 -45
  22. package/templates/storefront/app/privacy/page.tsx +88 -0
  23. package/templates/storefront/app/shop/page.tsx +25 -41
  24. package/templates/storefront/app/shop/shop-client.tsx +27 -0
  25. package/templates/storefront/app/terms/page.tsx +102 -0
  26. package/templates/storefront/components/cart-pill.tsx +32 -0
  27. package/templates/storefront/components/footer.tsx +186 -15
  28. package/templates/storefront/components/header.tsx +32 -22
  29. package/templates/storefront/components/nav-link.tsx +20 -0
  30. package/templates/storefront/components/store-product-card.tsx +9 -25
  31. package/templates/storefront/lib/server-client.ts +27 -0
  32. package/templates/storefront/next.config.ts +4 -0
@@ -1,59 +1,74 @@
1
- "use client";
2
-
3
- import { useEffect, useState, use } from "react";
1
+ import type { Metadata } from "next";
2
+ import { Suspense } from "react";
4
3
  import Link from "next/link";
5
- import { ProductGrid, useCimplifyClient } from "@cimplify/sdk/react";
6
- import type { Collection, Product } from "@cimplify/sdk";
7
- import { StoreProductCard } from "@/components/store-product-card";
4
+ import { notFound } from "next/navigation";
5
+ import { cacheTag, cacheLife } from "next/cache";
6
+ import {
7
+ getServerClient,
8
+ tags,
9
+ type Collection,
10
+ type Product,
11
+ } from "@cimplify/sdk/server";
12
+ import { ListingClient } from "./listing-client";
8
13
 
9
- /**
10
- * Full grid of products within a single collection. Reads `slug` from the
11
- * route, resolves it against the catalogue API, and renders the SDK
12
- * <ProductGrid/> with our URL-modal-aware <StoreProductCard/>.
13
- */
14
- export default function CollectionPage({ params }: { params: Promise<{ slug: string }> }) {
15
- const { slug } = use(params);
16
- const { client } = useCimplifyClient();
17
- const [collection, setCollection] = useState<Collection>();
18
- const [products, setProducts] = useState<Product[]>([]);
19
- const [loading, setLoading] = useState(true);
14
+ interface CollectionData {
15
+ collection: Collection;
16
+ products: Product[];
17
+ }
20
18
 
21
- useEffect(() => {
22
- let cancelled = false;
23
- void (async () => {
24
- try {
25
- const colRes = await client.catalogue.getCollectionBySlug(slug);
26
- if (cancelled || !colRes.ok) return;
27
- setCollection(colRes.value);
28
- const r = await client.catalogue.getCollectionProducts(colRes.value.id);
29
- if (cancelled) return;
30
- if (r.ok) {
31
- const items = (r.value as { items?: Product[] }).items ?? (r.value as Product[]);
32
- setProducts(items);
33
- }
34
- } finally {
35
- if (!cancelled) setLoading(false);
36
- }
37
- })();
38
- return () => {
39
- cancelled = true;
40
- };
41
- }, [client, slug]);
19
+ async function getCollection(slug: string): Promise<CollectionData | null> {
20
+ "use cache";
21
+ cacheTag(tags.collections());
22
+ cacheLife("hours");
42
23
 
43
- if (loading) {
44
- return <p className="text-center py-20 text-muted-foreground">Loading collection…</p>;
45
- }
46
- if (!collection) {
47
- return (
48
- <div className="text-center py-20 text-muted-foreground">
49
- <p>Collection not found.</p>
50
- <Link href="/" className="text-primary font-semibold">
51
- ← Back home
52
- </Link>
53
- </div>
54
- );
55
- }
24
+ const client = getServerClient();
25
+ const colRes = await client.catalogue.getCollectionBySlug(slug);
26
+ if (!colRes.ok) return null;
27
+
28
+ cacheTag(tags.collection(colRes.value.id), tags.collectionProducts(colRes.value.id));
29
+ const r = await client.catalogue.getCollectionProducts(colRes.value.id);
30
+ const products = r.ok
31
+ ? ((r.value as { items?: Product[] }).items ?? (r.value as Product[]))
32
+ : [];
33
+ return { collection: colRes.value, products };
34
+ }
35
+
36
+ export async function generateMetadata({
37
+ params,
38
+ }: {
39
+ params: Promise<{ slug: string }>;
40
+ }): Promise<Metadata> {
41
+ const { slug } = await params;
42
+ const data = await getCollection(slug);
43
+ if (!data) return {};
44
+ return {
45
+ title: `${data.collection.name} — Akua's Bakery`,
46
+ description: data.collection.description ?? undefined,
47
+ };
48
+ }
49
+
50
+ export default async function CollectionPage({
51
+ params,
52
+ }: {
53
+ params: Promise<{ slug: string }>;
54
+ }) {
55
+ return (
56
+ <Suspense fallback={<CollectionSkeleton />}>
57
+ <CollectionContent params={params} />
58
+ </Suspense>
59
+ );
60
+ }
56
61
 
62
+ async function CollectionContent({
63
+ params,
64
+ }: {
65
+ params: Promise<{ slug: string }>;
66
+ }) {
67
+ const { slug } = await params;
68
+ const data = await getCollection(slug);
69
+ if (!data) notFound();
70
+
71
+ const { collection, products } = data;
57
72
  return (
58
73
  <section className="max-w-7xl mx-auto px-8 pt-12">
59
74
  <header className="mb-8 text-center">
@@ -64,17 +79,39 @@ export default function CollectionPage({ params }: { params: Promise<{ slug: str
64
79
  {collection.name}
65
80
  </h1>
66
81
  {collection.description && (
67
- <p className="mx-auto mb-2 max-w-xl text-muted-foreground">{collection.description}</p>
82
+ <p className="mx-auto mb-2 max-w-xl text-muted-foreground">
83
+ {collection.description}
84
+ </p>
68
85
  )}
69
86
  <p className="text-sm text-muted-foreground">
70
87
  {products.length} item{products.length === 1 ? "" : "s"}
71
88
  </p>
72
89
  </header>
73
- <ProductGrid
74
- products={products}
75
- emptyMessage="No products in this collection yet."
76
- renderCard={(p) => <StoreProductCard product={p} />}
77
- />
90
+ <ListingClient products={products} />
91
+ {products.length === 0 && (
92
+ <p className="text-center mt-8">
93
+ <Link href="/" className="text-primary font-semibold">
94
+ ← Back home
95
+ </Link>
96
+ </p>
97
+ )}
98
+ </section>
99
+ );
100
+ }
101
+
102
+ function CollectionSkeleton() {
103
+ return (
104
+ <section className="max-w-7xl mx-auto px-8 pt-12">
105
+ <header className="mb-8 text-center">
106
+ <div className="mx-auto h-3 w-20 bg-muted rounded mb-2 animate-pulse" />
107
+ <div className="mx-auto h-10 w-64 bg-muted rounded mb-2 animate-pulse" />
108
+ <div className="mx-auto h-4 w-80 bg-muted rounded animate-pulse" />
109
+ </header>
110
+ <div className="grid grid-cols-2 md:grid-cols-3 gap-4">
111
+ {Array.from({ length: 6 }).map((_, i) => (
112
+ <div key={i} className="aspect-square bg-muted rounded-2xl animate-pulse" />
113
+ ))}
114
+ </div>
78
115
  </section>
79
116
  );
80
117
  }
@@ -0,0 +1,122 @@
1
+ import type { Metadata } from "next";
2
+
3
+ export const metadata: Metadata = {
4
+ title: "FAQ — Akua's Bakery",
5
+ description:
6
+ "Delivery, pickup, custom cakes, allergens, payment — answers to the questions we hear most often.",
7
+ };
8
+
9
+ interface QA {
10
+ q: string;
11
+ a: string;
12
+ }
13
+
14
+ const SECTIONS: { title: string; items: QA[] }[] = [
15
+ {
16
+ title: "Ordering & delivery",
17
+ items: [
18
+ {
19
+ q: "Where do you deliver?",
20
+ a: "Same-day delivery within Greater Accra for orders placed before 2pm. Outside Accra, we offer next-day shipping by partner courier — checkout will show the available options for your address.",
21
+ },
22
+ {
23
+ q: "Can I pick up my order?",
24
+ a: "Yes. Pickup is available 8am–8pm at our East Legon location, 12 Independence Avenue. Choose 'Pickup' at checkout and we'll have everything boxed and ready when you arrive.",
25
+ },
26
+ {
27
+ q: "How quickly will my order arrive?",
28
+ a: "Same-day delivery typically arrives within 2–4 hours of order confirmation. You'll get an SMS when the rider is en route.",
29
+ },
30
+ {
31
+ q: "Do you offer subscriptions?",
32
+ a: "Yes — our Weekly Loaf Subscription delivers a fresh loaf to your door every week. Pause or skip any time. See the Classes & Stays category for details.",
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ title: "Custom cakes & celebrations",
38
+ items: [
39
+ {
40
+ q: "How much notice do you need for a custom cake?",
41
+ a: "48 hours minimum for tier cakes; 7 days for elaborate designs with sugar work or fondant figures. Book a free Custom Cake Consultation to walk through flavours, sizes, and decoration.",
42
+ },
43
+ {
44
+ q: "Can I bring my own design?",
45
+ a: "Absolutely — send us a reference image and we'll quote what's possible within your timeline and budget.",
46
+ },
47
+ {
48
+ q: "Do you do wedding cakes?",
49
+ a: "We do, with at least 6 weeks' notice. Tasting sessions are GH₵150 and credited toward your final order.",
50
+ },
51
+ ],
52
+ },
53
+ {
54
+ title: "Allergens & ingredients",
55
+ items: [
56
+ {
57
+ q: "Is your kitchen allergen-free?",
58
+ a: "No. Our kitchen handles wheat, dairy, eggs, and tree nuts. Cross-contamination is possible. Please let us know about severe allergies before ordering — we'll be honest about whether we can safely accommodate them.",
59
+ },
60
+ {
61
+ q: "Do you have vegan options?",
62
+ a: "Yes. The country sourdough, whole-wheat seed loaf, baguette, and most of the breads are vegan. The hibiscus drink (Sobolo) and orange juice are also vegan.",
63
+ },
64
+ {
65
+ q: "Where does your flour come from?",
66
+ a: "We mill our own heritage wheat flour from the Volta Region. The 25kg sack is available in our Merch & More category for home bakers and trade customers.",
67
+ },
68
+ ],
69
+ },
70
+ {
71
+ title: "Payment & returns",
72
+ items: [
73
+ {
74
+ q: "What payment methods do you accept?",
75
+ a: "Mobile Money (MTN, Telecel, AirtelTigo), Visa/Mastercard, and cash on delivery for Accra-based orders.",
76
+ },
77
+ {
78
+ q: "What's your return policy?",
79
+ a: "We don't accept returns on baked goods for food-safety reasons, but if anything is wrong with your order — quality, accuracy, or freshness — message us within 24 hours and we'll make it right or refund you.",
80
+ },
81
+ {
82
+ q: "Do you offer wholesale pricing?",
83
+ a: "Yes — our Heritage Flour 25kg sack ships with quantity-tier pricing, and we'd love to talk if you run a café or restaurant. Email hello@akuasbakery.test.",
84
+ },
85
+ ],
86
+ },
87
+ ];
88
+
89
+ export default function FaqPage() {
90
+ return (
91
+ <article className="max-w-3xl mx-auto px-8 py-16">
92
+ <p className="text-[11px] font-semibold uppercase tracking-[0.16em] text-primary mb-2">
93
+ Frequently asked
94
+ </p>
95
+ <h1 className="font-serif text-[clamp(2.25rem,5vw,3.5rem)] font-semibold mb-10 -tracking-[0.02em]">
96
+ Questions, answered.
97
+ </h1>
98
+ <div className="space-y-12">
99
+ {SECTIONS.map((section) => (
100
+ <section key={section.title}>
101
+ <h2 className="font-serif text-2xl font-semibold mb-5">{section.title}</h2>
102
+ <dl className="space-y-6">
103
+ {section.items.map((item) => (
104
+ <div key={item.q}>
105
+ <dt className="font-medium text-foreground mb-1.5">{item.q}</dt>
106
+ <dd className="text-muted-foreground leading-relaxed">{item.a}</dd>
107
+ </div>
108
+ ))}
109
+ </dl>
110
+ </section>
111
+ ))}
112
+ </div>
113
+ <p className="mt-12 pt-8 border-t border-border text-sm text-muted-foreground">
114
+ Still stuck? Email{" "}
115
+ <a href="mailto:hello@akuasbakery.test" className="text-primary font-semibold hover:underline">
116
+ hello@akuasbakery.test
117
+ </a>{" "}
118
+ and a real human will reply within 24 hours.
119
+ </p>
120
+ </article>
121
+ );
122
+ }
@@ -1,48 +1,48 @@
1
- "use client";
2
-
3
- import { useEffect, useState } from "react";
4
- import { useCimplifyClient } from "@cimplify/sdk/react";
5
- import type { Category, Collection, Product } from "@cimplify/sdk";
1
+ import type { Metadata } from "next";
2
+ import { Suspense } from "react";
3
+ import { cacheTag, cacheLife } from "next/cache";
4
+ import { getServerClient, tags, type Product } from "@cimplify/sdk/server";
6
5
  import { Hero } from "@/components/hero";
7
6
  import { CollectionStrip } from "@/components/collection-strip";
8
7
  import { CategoryGrid } from "@/components/category-grid";
9
8
 
10
- interface CollectionWithProducts {
11
- collection: Collection;
12
- products: Product[];
13
- }
9
+ export const metadata: Metadata = {
10
+ title: "Akua's Bakery — Fresh from the oven, every day",
11
+ description:
12
+ "Sourdough, croissants, cakes, and more — handcrafted in East Legon, delivered across Accra.",
13
+ };
14
+
15
+ async function getHomeData() {
16
+ "use cache";
17
+ cacheTag(tags.collections(), tags.categories(), tags.products());
18
+ cacheLife("hours");
19
+
20
+ const client = getServerClient();
21
+ const [colRes, catRes] = await Promise.all([
22
+ client.catalogue.getCollections(),
23
+ client.catalogue.getCategories(),
24
+ ]);
25
+ const collections = colRes.ok ? colRes.value : [];
26
+ const categories = catRes.ok ? catRes.value : [];
14
27
 
15
- export default function HomePage() {
16
- const { client } = useCimplifyClient();
17
- const [collections, setCollections] = useState<CollectionWithProducts[]>([]);
18
- const [categories, setCategories] = useState<Category[]>([]);
28
+ const collectionsWithProducts = await Promise.all(
29
+ collections.map(async (col) => {
30
+ const r = await client.catalogue.getCollectionProducts(col.id);
31
+ const items = r.ok
32
+ ? ((r.value as { items?: Product[] }).items ?? (r.value as Product[]))
33
+ : [];
34
+ return { collection: col, products: items };
35
+ }),
36
+ );
37
+
38
+ return {
39
+ collections: collectionsWithProducts.filter((x) => x.products.length > 0),
40
+ categories,
41
+ };
42
+ }
19
43
 
20
- useEffect(() => {
21
- let cancelled = false;
22
- void (async () => {
23
- const [colRes, catRes] = await Promise.all([
24
- client.catalogue.getCollections(),
25
- client.catalogue.getCategories(),
26
- ]);
27
- if (cancelled) return;
28
- if (catRes.ok) setCategories(catRes.value);
29
- if (colRes.ok) {
30
- const withProducts = await Promise.all(
31
- colRes.value.map(async (col) => {
32
- const r = await client.catalogue.getCollectionProducts(col.id);
33
- const items = r.ok
34
- ? ((r.value as { items?: Product[] }).items ?? (r.value as Product[]))
35
- : [];
36
- return { collection: col, products: items };
37
- }),
38
- );
39
- if (!cancelled) setCollections(withProducts.filter((x) => x.products.length > 0));
40
- }
41
- })();
42
- return () => {
43
- cancelled = true;
44
- };
45
- }, [client]);
44
+ export default async function HomePage() {
45
+ const { collections, categories } = await getHomeData();
46
46
 
47
47
  return (
48
48
  <>
@@ -52,14 +52,46 @@ export default function HomePage() {
52
52
  subtitle="Sourdough, croissants, cakes, and more — handcrafted in East Legon, delivered across Accra."
53
53
  />
54
54
  {collections.map(({ collection, products }) => (
55
- <CollectionStrip
55
+ <Suspense
56
56
  key={collection.id}
57
- collection={collection}
58
- products={products}
59
- collectionHref={`/collections/${collection.slug}`}
60
- />
57
+ fallback={<StripSkeleton title={collection.name} />}
58
+ >
59
+ <CollectionStrip
60
+ collection={collection}
61
+ products={products}
62
+ collectionHref={`/collections/${collection.slug}`}
63
+ />
64
+ </Suspense>
61
65
  ))}
62
- <CategoryGrid categories={categories} />
66
+ <Suspense fallback={<CategoryGridSkeleton />}>
67
+ <CategoryGrid categories={categories} />
68
+ </Suspense>
63
69
  </>
64
70
  );
65
71
  }
72
+
73
+ function StripSkeleton({ title }: { title: string }) {
74
+ return (
75
+ <section className="max-w-7xl mx-auto px-8 pt-12">
76
+ <h2 className="font-serif text-[28px] font-semibold m-0 mb-5">{title}</h2>
77
+ <div className="grid grid-flow-col auto-cols-[minmax(220px,1fr)] gap-4 overflow-x-auto pb-2">
78
+ {Array.from({ length: 5 }).map((_, i) => (
79
+ <div key={i} className="aspect-square bg-muted rounded-2xl animate-pulse" />
80
+ ))}
81
+ </div>
82
+ </section>
83
+ );
84
+ }
85
+
86
+ function CategoryGridSkeleton() {
87
+ return (
88
+ <section className="max-w-7xl mx-auto px-8 pt-14">
89
+ <div className="h-8 w-48 bg-muted rounded mb-5 animate-pulse" />
90
+ <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
91
+ {Array.from({ length: 6 }).map((_, i) => (
92
+ <div key={i} className="h-32 bg-muted rounded-2xl animate-pulse" />
93
+ ))}
94
+ </div>
95
+ </section>
96
+ );
97
+ }
@@ -0,0 +1,88 @@
1
+ import type { Metadata } from "next";
2
+
3
+ export const metadata: Metadata = {
4
+ title: "Privacy Policy — Akua's Bakery",
5
+ description:
6
+ "How Akua's Bakery collects, uses, and protects your personal data.",
7
+ };
8
+
9
+ export default function PrivacyPage() {
10
+ return (
11
+ <article className="max-w-3xl mx-auto px-8 py-16 prose prose-lg max-w-none">
12
+ <p className="text-[11px] font-semibold uppercase tracking-[0.16em] text-primary mb-2 not-prose">
13
+ Privacy
14
+ </p>
15
+ <h1 className="font-serif text-[clamp(2.25rem,5vw,3.5rem)] font-semibold mb-2 -tracking-[0.02em]">
16
+ Privacy Policy
17
+ </h1>
18
+ <p className="text-sm text-muted-foreground not-prose mb-10">
19
+ Last updated: 1 May 2026
20
+ </p>
21
+
22
+ <section className="space-y-5 leading-relaxed text-foreground/90">
23
+ <h2 className="font-serif text-2xl font-semibold mt-0">What we collect</h2>
24
+ <p>
25
+ We collect only what we need to fulfil your order: your name, phone,
26
+ delivery address, email, and the items in your order. Payment details
27
+ are processed by our payment partners (Paystack, Stripe) and never
28
+ stored on our servers.
29
+ </p>
30
+
31
+ <h2 className="font-serif text-2xl font-semibold">How we use it</h2>
32
+ <ul className="list-disc pl-6 space-y-2">
33
+ <li>To prepare, deliver, and confirm your order.</li>
34
+ <li>To send order updates by SMS and email.</li>
35
+ <li>
36
+ To send occasional product news — only if you opted in. Unsubscribe
37
+ anytime in one click.
38
+ </li>
39
+ <li>
40
+ To analyse aggregated, anonymised browsing patterns so we can
41
+ improve the site.
42
+ </li>
43
+ </ul>
44
+
45
+ <h2 className="font-serif text-2xl font-semibold">Who we share it with</h2>
46
+ <p>
47
+ We share data only with the partners required to fulfil your order:
48
+ payment processors (Paystack, Stripe), delivery riders, and our
49
+ email/SMS providers. We do not sell or rent personal data to third
50
+ parties — ever.
51
+ </p>
52
+
53
+ <h2 className="font-serif text-2xl font-semibold">Cookies</h2>
54
+ <p>
55
+ We use a small number of strictly-necessary cookies to keep your cart
56
+ working and your session signed in. We don't use third-party
57
+ advertising or tracking cookies.
58
+ </p>
59
+
60
+ <h2 className="font-serif text-2xl font-semibold">Your rights</h2>
61
+ <p>
62
+ Under the Ghana Data Protection Act, 2012 (Act 843), you have the
63
+ right to access the data we hold about you, correct it, or have it
64
+ deleted. Email{" "}
65
+ <a
66
+ href="mailto:privacy@akuasbakery.test"
67
+ className="text-primary font-semibold hover:underline"
68
+ >
69
+ privacy@akuasbakery.test
70
+ </a>{" "}
71
+ and we'll respond within 14 days.
72
+ </p>
73
+
74
+ <h2 className="font-serif text-2xl font-semibold">Retention</h2>
75
+ <p>
76
+ We keep order records for 7 years to comply with Ghanaian tax law.
77
+ Marketing-list opt-ins are kept until you unsubscribe.
78
+ </p>
79
+
80
+ <h2 className="font-serif text-2xl font-semibold">Changes</h2>
81
+ <p>
82
+ If we make material changes to this policy, we'll email customers on
83
+ our marketing list and update the &quot;last updated&quot; date above.
84
+ </p>
85
+ </section>
86
+ </article>
87
+ );
88
+ }
@@ -1,46 +1,30 @@
1
- "use client";
1
+ import type { Metadata } from "next";
2
+ import { cacheTag, cacheLife } from "next/cache";
3
+ import { getServerClient, tags } from "@cimplify/sdk/server";
4
+ import { ShopClient } from "./shop-client";
2
5
 
3
- import { useEffect, useState } from "react";
4
- import { CataloguePage, useCimplifyClient } from "@cimplify/sdk/react";
5
- import type { Category, Product } from "@cimplify/sdk";
6
- import { StoreProductCard } from "@/components/store-product-card";
6
+ export const metadata: Metadata = {
7
+ title: "Shop — Akua's Bakery",
8
+ description: "Browse the full catalogue: breads, pastries, cakes, drinks, merch, and more.",
9
+ };
7
10
 
8
- /** Full catalogue page — every product, with the SDK's filterable layout. */
9
- export default function ShopPage() {
10
- const { client } = useCimplifyClient();
11
- const [products, setProducts] = useState<Product[]>();
12
- const [categories, setCategories] = useState<Category[]>();
13
- const [loading, setLoading] = useState(true);
11
+ async function getShopData() {
12
+ "use cache";
13
+ cacheTag(tags.products(), tags.categories());
14
+ cacheLife("hours");
14
15
 
15
- useEffect(() => {
16
- let cancelled = false;
17
- void (async () => {
18
- try {
19
- const [p, c] = await Promise.all([
20
- client.catalogue.getProducts({ limit: 50 }),
21
- client.catalogue.getCategories(),
22
- ]);
23
- if (cancelled) return;
24
- if (p.ok) setProducts(p.value.items);
25
- if (c.ok) setCategories(c.value);
26
- } finally {
27
- if (!cancelled) setLoading(false);
28
- }
29
- })();
30
- return () => {
31
- cancelled = true;
32
- };
33
- }, [client]);
16
+ const client = getServerClient();
17
+ const [p, c] = await Promise.all([
18
+ client.catalogue.getProducts({ limit: 50 }),
19
+ client.catalogue.getCategories(),
20
+ ]);
21
+ return {
22
+ products: p.ok ? p.value.items : [],
23
+ categories: c.ok ? c.value : [],
24
+ };
25
+ }
34
26
 
35
- if (loading) {
36
- return <p className="text-center py-20 text-muted-foreground">Loading shop…</p>;
37
- }
38
- return (
39
- <CataloguePage
40
- title="The Menu"
41
- products={products}
42
- categories={categories}
43
- renderCard={(p) => <StoreProductCard product={p} />}
44
- />
45
- );
27
+ export default async function ShopPage() {
28
+ const { products, categories } = await getShopData();
29
+ return <ShopClient products={products} categories={categories} />;
46
30
  }
@@ -0,0 +1,27 @@
1
+ "use client";
2
+
3
+ import { CataloguePage } from "@cimplify/sdk/react";
4
+ import type { Category, Product } from "@cimplify/sdk";
5
+ import { StoreProductCard } from "@/components/store-product-card";
6
+
7
+ /**
8
+ * Client island for the shop page. Server-side fetches all products and
9
+ * categories (cached via `'use cache'` in `app/shop/page.tsx`), then hands
10
+ * them to `<CataloguePage>` which owns the interactive filter / sort state.
11
+ */
12
+ export function ShopClient({
13
+ products,
14
+ categories,
15
+ }: {
16
+ products: Product[];
17
+ categories: Category[];
18
+ }) {
19
+ return (
20
+ <CataloguePage
21
+ title="The Menu"
22
+ products={products}
23
+ categories={categories}
24
+ renderCard={(p) => <StoreProductCard product={p} />}
25
+ />
26
+ );
27
+ }