@cimplify/cli 0.7.16 → 0.7.18

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 (52) hide show
  1. package/dist/{add-YRLROMEN.mjs → add-UXXUPBKR.mjs} +1 -1
  2. package/dist/{chunk-ATCBAM44.mjs → chunk-GAN7PG6N.mjs} +2 -2
  3. package/dist/{chunk-7PNEG4JY.mjs → chunk-HWHV62KB.mjs} +18 -18
  4. package/dist/{chunk-7CCC37ER.mjs → chunk-MR3Q43SU.mjs} +1 -1
  5. package/dist/dispatcher.mjs +11 -11
  6. package/dist/{doctor-UMTO3BI6.mjs → doctor-IGQNPWUY.mjs} +2 -2
  7. package/dist/{explain-2VWT5OFP.mjs → explain-IK2FYBB7.mjs} +2 -2
  8. package/dist/{introspect-PCLYGIDK.mjs → introspect-ZS6I46OO.mjs} +2 -2
  9. package/dist/{list-6FUJKW7D.mjs → list-P74FSKQR.mjs} +1 -1
  10. package/dist/{projects-JSEC2YCX.mjs → projects-QSUWVTJZ.mjs} +27 -4
  11. package/dist/{update-CCNTKRPV.mjs → update-E6Q3KV3B.mjs} +1 -1
  12. package/package.json +2 -2
  13. package/templates/storefront-auto/app/account/orders/[id]/page.tsx +42 -0
  14. package/templates/storefront-auto/app/layout.tsx +11 -2
  15. package/templates/storefront-auto/components/order-detail.tsx +11 -0
  16. package/templates/storefront-auto/components/providers.tsx +17 -3
  17. package/templates/storefront-auto/package.json +1 -1
  18. package/templates/storefront-bakery/app/account/orders/[id]/page.tsx +42 -0
  19. package/templates/storefront-bakery/app/layout.tsx +11 -2
  20. package/templates/storefront-bakery/components/order-detail.tsx +11 -0
  21. package/templates/storefront-bakery/components/providers.tsx +17 -3
  22. package/templates/storefront-bakery/package.json +1 -1
  23. package/templates/storefront-fashion/app/account/orders/[id]/page.tsx +42 -0
  24. package/templates/storefront-fashion/app/layout.tsx +11 -2
  25. package/templates/storefront-fashion/components/order-detail.tsx +11 -0
  26. package/templates/storefront-fashion/components/providers.tsx +17 -3
  27. package/templates/storefront-fashion/package.json +1 -1
  28. package/templates/storefront-grocery/app/account/orders/[id]/page.tsx +42 -0
  29. package/templates/storefront-grocery/app/layout.tsx +11 -2
  30. package/templates/storefront-grocery/components/order-detail.tsx +11 -0
  31. package/templates/storefront-grocery/components/providers.tsx +17 -3
  32. package/templates/storefront-grocery/package.json +1 -1
  33. package/templates/storefront-pharmacy/app/account/orders/[id]/page.tsx +42 -0
  34. package/templates/storefront-pharmacy/app/layout.tsx +11 -2
  35. package/templates/storefront-pharmacy/components/order-detail.tsx +11 -0
  36. package/templates/storefront-pharmacy/components/providers.tsx +17 -3
  37. package/templates/storefront-pharmacy/package.json +1 -1
  38. package/templates/storefront-restaurant/app/account/orders/[id]/page.tsx +42 -0
  39. package/templates/storefront-restaurant/app/layout.tsx +11 -2
  40. package/templates/storefront-restaurant/components/order-detail.tsx +11 -0
  41. package/templates/storefront-restaurant/components/providers.tsx +17 -3
  42. package/templates/storefront-restaurant/package.json +1 -1
  43. package/templates/storefront-retail/app/account/orders/[id]/page.tsx +42 -0
  44. package/templates/storefront-retail/app/layout.tsx +11 -2
  45. package/templates/storefront-retail/components/order-detail.tsx +11 -0
  46. package/templates/storefront-retail/components/providers.tsx +17 -3
  47. package/templates/storefront-retail/package.json +1 -1
  48. package/templates/storefront-services/app/account/orders/[id]/page.tsx +42 -0
  49. package/templates/storefront-services/app/layout.tsx +11 -2
  50. package/templates/storefront-services/components/order-detail.tsx +11 -0
  51. package/templates/storefront-services/components/providers.tsx +17 -3
  52. package/templates/storefront-services/package.json +1 -1
@@ -19,7 +19,7 @@
19
19
  "check": "bun run typecheck && bun run test:run"
20
20
  },
21
21
  "dependencies": {
22
- "@cimplify/sdk": "^0.70.3",
22
+ "@cimplify/sdk": "^0.72.0",
23
23
  "next": "^16.2.6",
24
24
  "react": "^19.0.0",
25
25
  "react-dom": "^19.0.0"
@@ -0,0 +1,42 @@
1
+ import { notFound } from "next/navigation";
2
+ import { AccountSignedOutPrompt, toAccountOrderView } from "@cimplify/sdk/react";
3
+ import type { EnrichedOrder } from "@cimplify/sdk";
4
+ import { brand } from "@/lib/brand";
5
+ import { apiFetch, serverAccessToken, serverSession } from "@/lib/cimplify-server";
6
+ import { OrderDetail } from "@/components/order-detail";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
10
+
11
+ export default async function OrderDetailPage({
12
+ params,
13
+ }: {
14
+ params: Promise<{ id: string }>;
15
+ }) {
16
+ const { id } = await params;
17
+
18
+ const session = await serverSession();
19
+ if (!session) {
20
+ return (
21
+ <AccountSignedOutPrompt
22
+ clientId={CLIENT_ID}
23
+ redirectUri={REDIRECT_URI}
24
+ eyebrow={brand.account.loginEyebrow}
25
+ title={brand.account.loginTitle}
26
+ description={brand.account.loginSubtitle}
27
+ />
28
+ );
29
+ }
30
+
31
+ const bearer = await serverAccessToken();
32
+ const order = await apiFetch<EnrichedOrder>(`/api/v1/orders/${encodeURIComponent(id)}`, {
33
+ bearer,
34
+ });
35
+ if (!order) notFound();
36
+
37
+ return (
38
+ <div className="mx-auto w-full max-w-5xl px-4 py-8 sm:px-6">
39
+ <OrderDetail {...toAccountOrderView(order)} />
40
+ </div>
41
+ );
42
+ }
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
2
2
  import { Inter } from "next/font/google";
3
3
  import "./globals.css";
4
4
  import { Providers } from "@/components/providers";
5
+ import { getServerClient, tags } from "@cimplify/sdk/server";
5
6
  import { Header } from "@/components/header";
6
7
  import { Footer } from "@/components/footer";
7
8
  import { ProductModal } from "@/components/product-modal";
@@ -35,7 +36,15 @@ export async function generateMetadata(): Promise<Metadata> {
35
36
  };
36
37
  }
37
38
 
38
- export default function RootLayout({ children }: { children: React.ReactNode }) {
39
+ export default async function RootLayout({ children }: { children: React.ReactNode }) {
40
+ const server = getServerClient();
41
+ const [bizResult, locResult] = await Promise.all([
42
+ server.business.getInfo({ cacheOptions: { revalidate: 3600, tags: [tags.business()] } }),
43
+ server.business.getLocations({ cacheOptions: { revalidate: 3600, tags: [tags.locations()] } }),
44
+ ]);
45
+ const initialBusiness = bizResult.ok ? bizResult.value : null;
46
+ const initialLocations = locResult.ok ? locResult.value : [];
47
+
39
48
  return (
40
49
  <html lang="en" suppressHydrationWarning className={inter.variable}>
41
50
  <body
@@ -45,7 +54,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
45
54
  <Suspense fallback={null}>
46
55
  <OrganizationJsonLd />
47
56
  </Suspense>
48
- <Providers>
57
+ <Providers initialBusiness={initialBusiness} initialLocations={initialLocations}>
49
58
  <Header />
50
59
  <main className="flex-1 pb-12 w-full">
51
60
  <Suspense fallback={null}>{children}</Suspense>
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import { AccountOrderView, type AccountOrderViewProps } from "@cimplify/sdk/react";
5
+
6
+ // Thin client wrapper so the server page can pass the (serializable) view-model
7
+ // while `onBack` (a function) is supplied on the client.
8
+ export function OrderDetail(props: AccountOrderViewProps) {
9
+ const router = useRouter();
10
+ return <AccountOrderView {...props} onBack={() => router.push("/account/orders")} />;
11
+ }
@@ -1,13 +1,23 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, type ReactNode } from "react";
4
- import { createCimplifyClient } from "@cimplify/sdk";
4
+ import { createCimplifyClient, type Business, type Location } from "@cimplify/sdk";
5
5
  import { CimplifyProvider, CartDrawerProvider } from "@cimplify/sdk/react";
6
6
  import { AuthErrorToast } from "@/components/auth-error-toast";
7
7
 
8
8
  // Same-origin client — every request goes through the Next.js rewrite in
9
9
  // next.config.ts, so no CORS preflight ever hits the browser.
10
- export function Providers({ children }: { children: ReactNode }) {
10
+ export function Providers({
11
+ children,
12
+ initialBusiness,
13
+ initialLocations,
14
+ }: {
15
+ children: ReactNode;
16
+ // Server-fetched in app/layout.tsx so prices render in the right currency
17
+ // during SSR (no default-currency flash before the client bootstrap).
18
+ initialBusiness?: Business | null;
19
+ initialLocations?: Location[];
20
+ }) {
11
21
  const client = useMemo(() => {
12
22
  const baseUrl =
13
23
  typeof window !== "undefined" ? window.location.origin : "http://127.0.0.1:8787";
@@ -20,7 +30,11 @@ export function Providers({ children }: { children: ReactNode }) {
20
30
  }, []);
21
31
 
22
32
  return (
23
- <CimplifyProvider client={client}>
33
+ <CimplifyProvider
34
+ client={client}
35
+ initialBusiness={initialBusiness}
36
+ initialLocations={initialLocations}
37
+ >
24
38
  <CartDrawerProvider>
25
39
  {children}
26
40
  <AuthErrorToast />
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.70.3",
20
+ "@cimplify/sdk": "^0.72.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,42 @@
1
+ import { notFound } from "next/navigation";
2
+ import { AccountSignedOutPrompt, toAccountOrderView } from "@cimplify/sdk/react";
3
+ import type { EnrichedOrder } from "@cimplify/sdk";
4
+ import { brand } from "@/lib/brand";
5
+ import { apiFetch, serverAccessToken, serverSession } from "@/lib/cimplify-server";
6
+ import { OrderDetail } from "@/components/order-detail";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
10
+
11
+ export default async function OrderDetailPage({
12
+ params,
13
+ }: {
14
+ params: Promise<{ id: string }>;
15
+ }) {
16
+ const { id } = await params;
17
+
18
+ const session = await serverSession();
19
+ if (!session) {
20
+ return (
21
+ <AccountSignedOutPrompt
22
+ clientId={CLIENT_ID}
23
+ redirectUri={REDIRECT_URI}
24
+ eyebrow={brand.account.loginEyebrow}
25
+ title={brand.account.loginTitle}
26
+ description={brand.account.loginSubtitle}
27
+ />
28
+ );
29
+ }
30
+
31
+ const bearer = await serverAccessToken();
32
+ const order = await apiFetch<EnrichedOrder>(`/api/v1/orders/${encodeURIComponent(id)}`, {
33
+ bearer,
34
+ });
35
+ if (!order) notFound();
36
+
37
+ return (
38
+ <div className="mx-auto w-full max-w-5xl px-4 py-8 sm:px-6">
39
+ <OrderDetail {...toAccountOrderView(order)} />
40
+ </div>
41
+ );
42
+ }
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
2
2
  import { Inter, JetBrains_Mono } from "next/font/google";
3
3
  import "./globals.css";
4
4
  import { Providers } from "@/components/providers";
5
+ import { getServerClient, tags } from "@cimplify/sdk/server";
5
6
  import { Header } from "@/components/header";
6
7
  import { Footer } from "@/components/footer";
7
8
  import { ProductModal } from "@/components/product-modal";
@@ -41,7 +42,15 @@ export async function generateMetadata(): Promise<Metadata> {
41
42
  };
42
43
  }
43
44
 
44
- export default function RootLayout({ children }: { children: React.ReactNode }) {
45
+ export default async function RootLayout({ children }: { children: React.ReactNode }) {
46
+ const server = getServerClient();
47
+ const [bizResult, locResult] = await Promise.all([
48
+ server.business.getInfo({ cacheOptions: { revalidate: 3600, tags: [tags.business()] } }),
49
+ server.business.getLocations({ cacheOptions: { revalidate: 3600, tags: [tags.locations()] } }),
50
+ ]);
51
+ const initialBusiness = bizResult.ok ? bizResult.value : null;
52
+ const initialLocations = locResult.ok ? locResult.value : [];
53
+
45
54
  return (
46
55
  <html lang="en" suppressHydrationWarning className={`${inter.variable} ${mono.variable}`}>
47
56
  <body
@@ -51,7 +60,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
51
60
  <Suspense fallback={null}>
52
61
  <OrganizationJsonLd />
53
62
  </Suspense>
54
- <Providers>
63
+ <Providers initialBusiness={initialBusiness} initialLocations={initialLocations}>
55
64
  <Header />
56
65
  <main className="flex-1 pb-12 w-full">
57
66
  <Suspense fallback={null}>{children}</Suspense>
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import { AccountOrderView, type AccountOrderViewProps } from "@cimplify/sdk/react";
5
+
6
+ // Thin client wrapper so the server page can pass the (serializable) view-model
7
+ // while `onBack` (a function) is supplied on the client.
8
+ export function OrderDetail(props: AccountOrderViewProps) {
9
+ const router = useRouter();
10
+ return <AccountOrderView {...props} onBack={() => router.push("/account/orders")} />;
11
+ }
@@ -1,13 +1,23 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, type ReactNode } from "react";
4
- import { createCimplifyClient } from "@cimplify/sdk";
4
+ import { createCimplifyClient, type Business, type Location } from "@cimplify/sdk";
5
5
  import { CimplifyProvider, CartDrawerProvider } from "@cimplify/sdk/react";
6
6
  import { AuthErrorToast } from "@/components/auth-error-toast";
7
7
 
8
8
  // Same-origin client — every request goes through the Next.js rewrite in
9
9
  // next.config.ts, so no CORS preflight ever hits the browser.
10
- export function Providers({ children }: { children: ReactNode }) {
10
+ export function Providers({
11
+ children,
12
+ initialBusiness,
13
+ initialLocations,
14
+ }: {
15
+ children: ReactNode;
16
+ // Server-fetched in app/layout.tsx so prices render in the right currency
17
+ // during SSR (no default-currency flash before the client bootstrap).
18
+ initialBusiness?: Business | null;
19
+ initialLocations?: Location[];
20
+ }) {
11
21
  const client = useMemo(() => {
12
22
  const baseUrl =
13
23
  typeof window !== "undefined" ? window.location.origin : "http://127.0.0.1:8787";
@@ -20,7 +30,11 @@ export function Providers({ children }: { children: ReactNode }) {
20
30
  }, []);
21
31
 
22
32
  return (
23
- <CimplifyProvider client={client}>
33
+ <CimplifyProvider
34
+ client={client}
35
+ initialBusiness={initialBusiness}
36
+ initialLocations={initialLocations}
37
+ >
24
38
  <CartDrawerProvider>
25
39
  {children}
26
40
  <AuthErrorToast />
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.70.3",
20
+ "@cimplify/sdk": "^0.72.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,42 @@
1
+ import { notFound } from "next/navigation";
2
+ import { AccountSignedOutPrompt, toAccountOrderView } from "@cimplify/sdk/react";
3
+ import type { EnrichedOrder } from "@cimplify/sdk";
4
+ import { brand } from "@/lib/brand";
5
+ import { apiFetch, serverAccessToken, serverSession } from "@/lib/cimplify-server";
6
+ import { OrderDetail } from "@/components/order-detail";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
10
+
11
+ export default async function OrderDetailPage({
12
+ params,
13
+ }: {
14
+ params: Promise<{ id: string }>;
15
+ }) {
16
+ const { id } = await params;
17
+
18
+ const session = await serverSession();
19
+ if (!session) {
20
+ return (
21
+ <AccountSignedOutPrompt
22
+ clientId={CLIENT_ID}
23
+ redirectUri={REDIRECT_URI}
24
+ eyebrow={brand.account.loginEyebrow}
25
+ title={brand.account.loginTitle}
26
+ description={brand.account.loginSubtitle}
27
+ />
28
+ );
29
+ }
30
+
31
+ const bearer = await serverAccessToken();
32
+ const order = await apiFetch<EnrichedOrder>(`/api/v1/orders/${encodeURIComponent(id)}`, {
33
+ bearer,
34
+ });
35
+ if (!order) notFound();
36
+
37
+ return (
38
+ <div className="mx-auto w-full max-w-5xl px-4 py-8 sm:px-6">
39
+ <OrderDetail {...toAccountOrderView(order)} />
40
+ </div>
41
+ );
42
+ }
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
2
2
  import { Inter, Lora } from "next/font/google";
3
3
  import "./globals.css";
4
4
  import { Providers } from "@/components/providers";
5
+ import { getServerClient, tags } from "@cimplify/sdk/server";
5
6
  import { Header } from "@/components/header";
6
7
  import { Footer } from "@/components/footer";
7
8
  import { ProductModal } from "@/components/product-modal";
@@ -41,7 +42,15 @@ export async function generateMetadata(): Promise<Metadata> {
41
42
  };
42
43
  }
43
44
 
44
- export default function RootLayout({ children }: { children: React.ReactNode }) {
45
+ export default async function RootLayout({ children }: { children: React.ReactNode }) {
46
+ const server = getServerClient();
47
+ const [bizResult, locResult] = await Promise.all([
48
+ server.business.getInfo({ cacheOptions: { revalidate: 3600, tags: [tags.business()] } }),
49
+ server.business.getLocations({ cacheOptions: { revalidate: 3600, tags: [tags.locations()] } }),
50
+ ]);
51
+ const initialBusiness = bizResult.ok ? bizResult.value : null;
52
+ const initialLocations = locResult.ok ? locResult.value : [];
53
+
45
54
  return (
46
55
  <html lang="en" suppressHydrationWarning className={`${inter.variable} ${lora.variable}`}>
47
56
  <body
@@ -51,7 +60,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
51
60
  <Suspense fallback={null}>
52
61
  <OrganizationJsonLd />
53
62
  </Suspense>
54
- <Providers>
63
+ <Providers initialBusiness={initialBusiness} initialLocations={initialLocations}>
55
64
  <Header />
56
65
  <main className="flex-1 pb-12 w-full">
57
66
  <Suspense fallback={null}>{children}</Suspense>
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import { AccountOrderView, type AccountOrderViewProps } from "@cimplify/sdk/react";
5
+
6
+ // Thin client wrapper so the server page can pass the (serializable) view-model
7
+ // while `onBack` (a function) is supplied on the client.
8
+ export function OrderDetail(props: AccountOrderViewProps) {
9
+ const router = useRouter();
10
+ return <AccountOrderView {...props} onBack={() => router.push("/account/orders")} />;
11
+ }
@@ -1,13 +1,23 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, type ReactNode } from "react";
4
- import { createCimplifyClient } from "@cimplify/sdk";
4
+ import { createCimplifyClient, type Business, type Location } from "@cimplify/sdk";
5
5
  import { CimplifyProvider, CartDrawerProvider } from "@cimplify/sdk/react";
6
6
  import { AuthErrorToast } from "@/components/auth-error-toast";
7
7
 
8
8
  // Same-origin client — every request goes through the Next.js rewrite in
9
9
  // next.config.ts, so no CORS preflight ever hits the browser.
10
- export function Providers({ children }: { children: ReactNode }) {
10
+ export function Providers({
11
+ children,
12
+ initialBusiness,
13
+ initialLocations,
14
+ }: {
15
+ children: ReactNode;
16
+ // Server-fetched in app/layout.tsx so prices render in the right currency
17
+ // during SSR (no default-currency flash before the client bootstrap).
18
+ initialBusiness?: Business | null;
19
+ initialLocations?: Location[];
20
+ }) {
11
21
  const client = useMemo(() => {
12
22
  const baseUrl =
13
23
  typeof window !== "undefined" ? window.location.origin : "http://127.0.0.1:8787";
@@ -20,7 +30,11 @@ export function Providers({ children }: { children: ReactNode }) {
20
30
  }, []);
21
31
 
22
32
  return (
23
- <CimplifyProvider client={client}>
33
+ <CimplifyProvider
34
+ client={client}
35
+ initialBusiness={initialBusiness}
36
+ initialLocations={initialLocations}
37
+ >
24
38
  <CartDrawerProvider>
25
39
  {children}
26
40
  <AuthErrorToast />
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.70.3",
20
+ "@cimplify/sdk": "^0.72.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,42 @@
1
+ import { notFound } from "next/navigation";
2
+ import { AccountSignedOutPrompt, toAccountOrderView } from "@cimplify/sdk/react";
3
+ import type { EnrichedOrder } from "@cimplify/sdk";
4
+ import { brand } from "@/lib/brand";
5
+ import { apiFetch, serverAccessToken, serverSession } from "@/lib/cimplify-server";
6
+ import { OrderDetail } from "@/components/order-detail";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
10
+
11
+ export default async function OrderDetailPage({
12
+ params,
13
+ }: {
14
+ params: Promise<{ id: string }>;
15
+ }) {
16
+ const { id } = await params;
17
+
18
+ const session = await serverSession();
19
+ if (!session) {
20
+ return (
21
+ <AccountSignedOutPrompt
22
+ clientId={CLIENT_ID}
23
+ redirectUri={REDIRECT_URI}
24
+ eyebrow={brand.account.loginEyebrow}
25
+ title={brand.account.loginTitle}
26
+ description={brand.account.loginSubtitle}
27
+ />
28
+ );
29
+ }
30
+
31
+ const bearer = await serverAccessToken();
32
+ const order = await apiFetch<EnrichedOrder>(`/api/v1/orders/${encodeURIComponent(id)}`, {
33
+ bearer,
34
+ });
35
+ if (!order) notFound();
36
+
37
+ return (
38
+ <div className="mx-auto w-full max-w-5xl px-4 py-8 sm:px-6">
39
+ <OrderDetail {...toAccountOrderView(order)} />
40
+ </div>
41
+ );
42
+ }
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
2
2
  import { Inter, JetBrains_Mono } from "next/font/google";
3
3
  import "./globals.css";
4
4
  import { Providers } from "@/components/providers";
5
+ import { getServerClient, tags } from "@cimplify/sdk/server";
5
6
  import { Header } from "@/components/header";
6
7
  import { Footer } from "@/components/footer";
7
8
  import { ProductModal } from "@/components/product-modal";
@@ -41,7 +42,15 @@ export async function generateMetadata(): Promise<Metadata> {
41
42
  };
42
43
  }
43
44
 
44
- export default function RootLayout({ children }: { children: React.ReactNode }) {
45
+ export default async function RootLayout({ children }: { children: React.ReactNode }) {
46
+ const server = getServerClient();
47
+ const [bizResult, locResult] = await Promise.all([
48
+ server.business.getInfo({ cacheOptions: { revalidate: 3600, tags: [tags.business()] } }),
49
+ server.business.getLocations({ cacheOptions: { revalidate: 3600, tags: [tags.locations()] } }),
50
+ ]);
51
+ const initialBusiness = bizResult.ok ? bizResult.value : null;
52
+ const initialLocations = locResult.ok ? locResult.value : [];
53
+
45
54
  return (
46
55
  <html lang="en" suppressHydrationWarning className={`${inter.variable} ${mono.variable}`}>
47
56
  <body
@@ -51,7 +60,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
51
60
  <Suspense fallback={null}>
52
61
  <OrganizationJsonLd />
53
62
  </Suspense>
54
- <Providers>
63
+ <Providers initialBusiness={initialBusiness} initialLocations={initialLocations}>
55
64
  <Header />
56
65
  <main className="flex-1 pb-12 w-full">
57
66
  <Suspense fallback={null}>{children}</Suspense>
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import { AccountOrderView, type AccountOrderViewProps } from "@cimplify/sdk/react";
5
+
6
+ // Thin client wrapper so the server page can pass the (serializable) view-model
7
+ // while `onBack` (a function) is supplied on the client.
8
+ export function OrderDetail(props: AccountOrderViewProps) {
9
+ const router = useRouter();
10
+ return <AccountOrderView {...props} onBack={() => router.push("/account/orders")} />;
11
+ }
@@ -1,13 +1,23 @@
1
1
  "use client";
2
2
 
3
3
  import { useMemo, type ReactNode } from "react";
4
- import { createCimplifyClient } from "@cimplify/sdk";
4
+ import { createCimplifyClient, type Business, type Location } from "@cimplify/sdk";
5
5
  import { CimplifyProvider, CartDrawerProvider } from "@cimplify/sdk/react";
6
6
  import { AuthErrorToast } from "@/components/auth-error-toast";
7
7
 
8
8
  // Same-origin client — every request goes through the Next.js rewrite in
9
9
  // next.config.ts, so no CORS preflight ever hits the browser.
10
- export function Providers({ children }: { children: ReactNode }) {
10
+ export function Providers({
11
+ children,
12
+ initialBusiness,
13
+ initialLocations,
14
+ }: {
15
+ children: ReactNode;
16
+ // Server-fetched in app/layout.tsx so prices render in the right currency
17
+ // during SSR (no default-currency flash before the client bootstrap).
18
+ initialBusiness?: Business | null;
19
+ initialLocations?: Location[];
20
+ }) {
11
21
  const client = useMemo(() => {
12
22
  const baseUrl =
13
23
  typeof window !== "undefined" ? window.location.origin : "http://127.0.0.1:8787";
@@ -20,7 +30,11 @@ export function Providers({ children }: { children: ReactNode }) {
20
30
  }, []);
21
31
 
22
32
  return (
23
- <CimplifyProvider client={client}>
33
+ <CimplifyProvider
34
+ client={client}
35
+ initialBusiness={initialBusiness}
36
+ initialLocations={initialLocations}
37
+ >
24
38
  <CartDrawerProvider>
25
39
  {children}
26
40
  <AuthErrorToast />
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.70.3",
20
+ "@cimplify/sdk": "^0.72.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,42 @@
1
+ import { notFound } from "next/navigation";
2
+ import { AccountSignedOutPrompt, toAccountOrderView } from "@cimplify/sdk/react";
3
+ import type { EnrichedOrder } from "@cimplify/sdk";
4
+ import { brand } from "@/lib/brand";
5
+ import { apiFetch, serverAccessToken, serverSession } from "@/lib/cimplify-server";
6
+ import { OrderDetail } from "@/components/order-detail";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
10
+
11
+ export default async function OrderDetailPage({
12
+ params,
13
+ }: {
14
+ params: Promise<{ id: string }>;
15
+ }) {
16
+ const { id } = await params;
17
+
18
+ const session = await serverSession();
19
+ if (!session) {
20
+ return (
21
+ <AccountSignedOutPrompt
22
+ clientId={CLIENT_ID}
23
+ redirectUri={REDIRECT_URI}
24
+ eyebrow={brand.account.loginEyebrow}
25
+ title={brand.account.loginTitle}
26
+ description={brand.account.loginSubtitle}
27
+ />
28
+ );
29
+ }
30
+
31
+ const bearer = await serverAccessToken();
32
+ const order = await apiFetch<EnrichedOrder>(`/api/v1/orders/${encodeURIComponent(id)}`, {
33
+ bearer,
34
+ });
35
+ if (!order) notFound();
36
+
37
+ return (
38
+ <div className="mx-auto w-full max-w-5xl px-4 py-8 sm:px-6">
39
+ <OrderDetail {...toAccountOrderView(order)} />
40
+ </div>
41
+ );
42
+ }
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
2
2
  import { Inter, Fraunces } from "next/font/google";
3
3
  import "./globals.css";
4
4
  import { Providers } from "@/components/providers";
5
+ import { getServerClient, tags } from "@cimplify/sdk/server";
5
6
  import { Header } from "@/components/header";
6
7
  import { Footer } from "@/components/footer";
7
8
  import { ProductModal } from "@/components/product-modal";
@@ -41,7 +42,15 @@ export async function generateMetadata(): Promise<Metadata> {
41
42
  };
42
43
  }
43
44
 
44
- export default function RootLayout({ children }: { children: React.ReactNode }) {
45
+ export default async function RootLayout({ children }: { children: React.ReactNode }) {
46
+ const server = getServerClient();
47
+ const [bizResult, locResult] = await Promise.all([
48
+ server.business.getInfo({ cacheOptions: { revalidate: 3600, tags: [tags.business()] } }),
49
+ server.business.getLocations({ cacheOptions: { revalidate: 3600, tags: [tags.locations()] } }),
50
+ ]);
51
+ const initialBusiness = bizResult.ok ? bizResult.value : null;
52
+ const initialLocations = locResult.ok ? locResult.value : [];
53
+
45
54
  return (
46
55
  <html lang="en" suppressHydrationWarning className={`${inter.variable} ${fraunces.variable}`}>
47
56
  <body
@@ -51,7 +60,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
51
60
  <Suspense fallback={null}>
52
61
  <OrganizationJsonLd />
53
62
  </Suspense>
54
- <Providers>
63
+ <Providers initialBusiness={initialBusiness} initialLocations={initialLocations}>
55
64
  <Header />
56
65
  <main className="flex-1 pb-12 w-full">
57
66
  <Suspense fallback={null}>{children}</Suspense>
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import { AccountOrderView, type AccountOrderViewProps } from "@cimplify/sdk/react";
5
+
6
+ // Thin client wrapper so the server page can pass the (serializable) view-model
7
+ // while `onBack` (a function) is supplied on the client.
8
+ export function OrderDetail(props: AccountOrderViewProps) {
9
+ const router = useRouter();
10
+ return <AccountOrderView {...props} onBack={() => router.push("/account/orders")} />;
11
+ }