@cimplify/cli 0.7.15 → 0.7.17
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.
- package/dist/{add-A5PYZXDS.mjs → add-VSGQEUDS.mjs} +1 -1
- package/dist/{chunk-DY5TIVWB.mjs → chunk-NIDPHJ45.mjs} +1 -1
- package/dist/{chunk-WNVMNOW7.mjs → chunk-OJRMBHMT.mjs} +1 -1
- package/dist/{chunk-U7L3GR3Y.mjs → chunk-XKO2EB5J.mjs} +16 -24
- package/dist/dispatcher.mjs +9 -9
- package/dist/{doctor-W2BBP6OL.mjs → doctor-AMR3MFFS.mjs} +2 -2
- package/dist/{explain-N6DBSJHA.mjs → explain-6LYQ2OL4.mjs} +1 -1
- package/dist/{introspect-ED3XKT4A.mjs → introspect-HWOZIVET.mjs} +2 -2
- package/dist/{list-X3D3GABS.mjs → list-WC7JWDCJ.mjs} +1 -1
- package/dist/{update-2SWGQJR2.mjs → update-6LL5PQEQ.mjs} +1 -1
- package/package.json +1 -1
- package/templates/storefront-auto/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-auto/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-auto/components/account-pill.tsx +4 -17
- package/templates/storefront-auto/components/order-detail.tsx +11 -0
- package/templates/storefront-auto/lib/brand.ts +0 -1
- package/templates/storefront-auto/lib/cimplify-server.ts +0 -2
- package/templates/storefront-bakery/AGENTS.md +0 -2
- package/templates/storefront-bakery/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-bakery/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-bakery/components/account-pill.tsx +4 -17
- package/templates/storefront-bakery/components/order-detail.tsx +11 -0
- package/templates/storefront-bakery/lib/brand.ts +0 -1
- package/templates/storefront-bakery/lib/cimplify-server.ts +0 -2
- package/templates/storefront-fashion/AGENTS.md +0 -2
- package/templates/storefront-fashion/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-fashion/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-fashion/components/account-pill.tsx +4 -17
- package/templates/storefront-fashion/components/order-detail.tsx +11 -0
- package/templates/storefront-fashion/lib/brand.ts +0 -1
- package/templates/storefront-fashion/lib/cimplify-server.ts +0 -2
- package/templates/storefront-grocery/AGENTS.md +0 -2
- package/templates/storefront-grocery/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-grocery/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-grocery/components/account-pill.tsx +4 -17
- package/templates/storefront-grocery/components/order-detail.tsx +11 -0
- package/templates/storefront-grocery/lib/brand.ts +0 -1
- package/templates/storefront-grocery/lib/cimplify-server.ts +0 -2
- package/templates/storefront-pharmacy/AGENTS.md +0 -2
- package/templates/storefront-pharmacy/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-pharmacy/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-pharmacy/components/account-pill.tsx +4 -17
- package/templates/storefront-pharmacy/components/order-detail.tsx +11 -0
- package/templates/storefront-pharmacy/lib/brand.ts +0 -1
- package/templates/storefront-pharmacy/lib/cimplify-server.ts +0 -2
- package/templates/storefront-restaurant/AGENTS.md +0 -2
- package/templates/storefront-restaurant/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-restaurant/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-restaurant/components/account-pill.tsx +4 -17
- package/templates/storefront-restaurant/components/order-detail.tsx +11 -0
- package/templates/storefront-restaurant/lib/brand.ts +0 -1
- package/templates/storefront-restaurant/lib/cimplify-server.ts +0 -2
- package/templates/storefront-retail/AGENTS.md +0 -2
- package/templates/storefront-retail/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-retail/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-retail/components/account-pill.tsx +4 -17
- package/templates/storefront-retail/components/order-detail.tsx +11 -0
- package/templates/storefront-retail/lib/brand.ts +0 -1
- package/templates/storefront-retail/lib/cimplify-server.ts +0 -2
- package/templates/storefront-services/AGENTS.md +0 -2
- package/templates/storefront-services/app/account/orders/[id]/page.tsx +42 -0
- package/templates/storefront-services/app/sitemap-page/page.tsx +0 -2
- package/templates/storefront-services/components/account-pill.tsx +4 -17
- package/templates/storefront-services/components/order-detail.tsx +11 -0
- package/templates/storefront-services/lib/brand.ts +0 -1
- package/templates/storefront-services/lib/cimplify-server.ts +0 -2
- package/templates/storefront-auto/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-auto/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-auto/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-auto/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-bakery/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-bakery/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-bakery/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-bakery/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-fashion/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-fashion/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-fashion/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-fashion/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-grocery/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-grocery/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-grocery/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-grocery/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-pharmacy/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-pharmacy/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-pharmacy/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-pharmacy/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-restaurant/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-restaurant/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-restaurant/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-restaurant/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-retail/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-retail/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-retail/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-retail/app/account/wallets/page.tsx +0 -185
- package/templates/storefront-services/app/account/addresses/actions.ts +0 -56
- package/templates/storefront-services/app/account/addresses/page.tsx +0 -184
- package/templates/storefront-services/app/account/wallets/actions.ts +0 -52
- package/templates/storefront-services/app/account/wallets/page.tsx +0 -185
|
@@ -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
|
+
}
|
|
@@ -54,8 +54,6 @@ const STATIC_LINKS: { title: string; links: { href: string; label: string }[] }[
|
|
|
54
54
|
links: [
|
|
55
55
|
{ href: "/account", label: "Account" },
|
|
56
56
|
{ href: "/account/orders", label: "Orders" },
|
|
57
|
-
{ href: "/account/addresses", label: "Addresses" },
|
|
58
|
-
{ href: "/account/wallets", label: "Wallets" },
|
|
59
57
|
{ href: "/login", label: "Sign in" },
|
|
60
58
|
{ href: "/signup", label: "Create account" },
|
|
61
59
|
{ href: "/track-order", label: "Track an order" },
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import
|
|
5
|
-
import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
4
|
+
import { CimplifyUserButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
6
5
|
import { signInSilent } from "@cimplify/sdk";
|
|
7
6
|
|
|
8
7
|
const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
|
|
@@ -26,24 +25,12 @@ export function AccountPill() {
|
|
|
26
25
|
|
|
27
26
|
if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
|
|
28
27
|
|
|
29
|
-
if (session) {
|
|
30
|
-
const first = session.name?.split(/\s+/)[0] ?? "Account";
|
|
31
|
-
return (
|
|
32
|
-
<Link
|
|
33
|
-
href="/account"
|
|
34
|
-
className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
|
|
35
|
-
>
|
|
36
|
-
Hi, {first}
|
|
37
|
-
</Link>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
28
|
return (
|
|
42
|
-
<
|
|
29
|
+
<CimplifyUserButton
|
|
30
|
+
session={session}
|
|
43
31
|
clientId={CLIENT_ID}
|
|
44
32
|
redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
|
|
45
|
-
|
|
46
|
-
onSuccess={() => refresh()}
|
|
33
|
+
onSignIn={refresh}
|
|
47
34
|
/>
|
|
48
35
|
);
|
|
49
36
|
}
|
|
@@ -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
|
+
}
|
|
@@ -8,8 +8,6 @@ import type { NavItem } from "@cimplify/sdk/react";
|
|
|
8
8
|
export const ACCOUNT_NAV: NavItem[] = [
|
|
9
9
|
{ label: "Dashboard", href: "/account" },
|
|
10
10
|
{ label: "Orders", href: "/account/orders" },
|
|
11
|
-
{ label: "Addresses", href: "/account/addresses" },
|
|
12
|
-
{ label: "Wallets", href: "/account/wallets" },
|
|
13
11
|
{ label: "Cimplify identity", href: "https://link.cimplify.io", external: true },
|
|
14
12
|
];
|
|
15
13
|
|
|
@@ -33,8 +33,6 @@ app/
|
|
|
33
33
|
|
|
34
34
|
account/page.tsx <AccountDashboardPage /> (native, Server Component)
|
|
35
35
|
account/orders/page.tsx <AccountOrdersPage /> (native)
|
|
36
|
-
account/addresses/page.tsx Native list + Server Actions for CRUD
|
|
37
|
-
account/wallets/page.tsx Native list + Server Actions for CRUD
|
|
38
36
|
login/page.tsx, signup/page.tsx redirects → /account
|
|
39
37
|
|
|
40
38
|
contact/page.tsx, track-order/page.tsx
|
|
@@ -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
|
+
}
|
|
@@ -54,8 +54,6 @@ const STATIC_LINKS: { title: string; links: { href: string; label: string }[] }[
|
|
|
54
54
|
links: [
|
|
55
55
|
{ href: "/account", label: "Account" },
|
|
56
56
|
{ href: "/account/orders", label: "Orders" },
|
|
57
|
-
{ href: "/account/addresses", label: "Addresses" },
|
|
58
|
-
{ href: "/account/wallets", label: "Wallets" },
|
|
59
57
|
{ href: "/login", label: "Sign in" },
|
|
60
58
|
{ href: "/signup", label: "Create account" },
|
|
61
59
|
{ href: "/track-order", label: "Track an order" },
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import
|
|
5
|
-
import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
4
|
+
import { CimplifyUserButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
6
5
|
import { signInSilent } from "@cimplify/sdk";
|
|
7
6
|
|
|
8
7
|
const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
|
|
@@ -26,24 +25,12 @@ export function AccountPill() {
|
|
|
26
25
|
|
|
27
26
|
if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
|
|
28
27
|
|
|
29
|
-
if (session) {
|
|
30
|
-
const first = session.name?.split(/\s+/)[0] ?? "Account";
|
|
31
|
-
return (
|
|
32
|
-
<Link
|
|
33
|
-
href="/account"
|
|
34
|
-
className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
|
|
35
|
-
>
|
|
36
|
-
Hi, {first}
|
|
37
|
-
</Link>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
28
|
return (
|
|
42
|
-
<
|
|
29
|
+
<CimplifyUserButton
|
|
30
|
+
session={session}
|
|
43
31
|
clientId={CLIENT_ID}
|
|
44
32
|
redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
|
|
45
|
-
|
|
46
|
-
onSuccess={() => refresh()}
|
|
33
|
+
onSignIn={refresh}
|
|
47
34
|
/>
|
|
48
35
|
);
|
|
49
36
|
}
|
|
@@ -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
|
+
}
|
|
@@ -8,8 +8,6 @@ import type { NavItem } from "@cimplify/sdk/react";
|
|
|
8
8
|
export const ACCOUNT_NAV: NavItem[] = [
|
|
9
9
|
{ label: "Dashboard", href: "/account" },
|
|
10
10
|
{ label: "Orders", href: "/account/orders" },
|
|
11
|
-
{ label: "Addresses", href: "/account/addresses" },
|
|
12
|
-
{ label: "Wallets", href: "/account/wallets" },
|
|
13
11
|
{ label: "Cimplify identity", href: "https://link.cimplify.io", external: true },
|
|
14
12
|
];
|
|
15
13
|
|
|
@@ -34,8 +34,6 @@ app/
|
|
|
34
34
|
|
|
35
35
|
account/page.tsx <AccountDashboardPage /> (native, Server Component)
|
|
36
36
|
account/orders/page.tsx <AccountOrdersPage /> (native)
|
|
37
|
-
account/addresses/page.tsx Native list + Server Actions for CRUD
|
|
38
|
-
account/wallets/page.tsx Native list + Server Actions for CRUD
|
|
39
37
|
login/page.tsx, signup/page.tsx redirects → /account
|
|
40
38
|
|
|
41
39
|
contact/page.tsx Branded contact form
|
|
@@ -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
|
+
}
|
|
@@ -54,8 +54,6 @@ const STATIC_LINKS: { title: string; links: { href: string; label: string }[] }[
|
|
|
54
54
|
links: [
|
|
55
55
|
{ href: "/account", label: "Account" },
|
|
56
56
|
{ href: "/account/orders", label: "Orders" },
|
|
57
|
-
{ href: "/account/addresses", label: "Addresses" },
|
|
58
|
-
{ href: "/account/wallets", label: "Wallets" },
|
|
59
57
|
{ href: "/login", label: "Sign in" },
|
|
60
58
|
{ href: "/signup", label: "Create account" },
|
|
61
59
|
{ href: "/track-order", label: "Track an order" },
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import
|
|
5
|
-
import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
4
|
+
import { CimplifyUserButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
6
5
|
import { signInSilent } from "@cimplify/sdk";
|
|
7
6
|
|
|
8
7
|
const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
|
|
@@ -26,24 +25,12 @@ export function AccountPill() {
|
|
|
26
25
|
|
|
27
26
|
if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
|
|
28
27
|
|
|
29
|
-
if (session) {
|
|
30
|
-
const first = session.name?.split(/\s+/)[0] ?? "Account";
|
|
31
|
-
return (
|
|
32
|
-
<Link
|
|
33
|
-
href="/account"
|
|
34
|
-
className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
|
|
35
|
-
>
|
|
36
|
-
Hi, {first}
|
|
37
|
-
</Link>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
28
|
return (
|
|
42
|
-
<
|
|
29
|
+
<CimplifyUserButton
|
|
30
|
+
session={session}
|
|
43
31
|
clientId={CLIENT_ID}
|
|
44
32
|
redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
|
|
45
|
-
|
|
46
|
-
onSuccess={() => refresh()}
|
|
33
|
+
onSignIn={refresh}
|
|
47
34
|
/>
|
|
48
35
|
);
|
|
49
36
|
}
|
|
@@ -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
|
+
}
|
|
@@ -8,8 +8,6 @@ import type { NavItem } from "@cimplify/sdk/react";
|
|
|
8
8
|
export const ACCOUNT_NAV: NavItem[] = [
|
|
9
9
|
{ label: "Dashboard", href: "/account" },
|
|
10
10
|
{ label: "Orders", href: "/account/orders" },
|
|
11
|
-
{ label: "Addresses", href: "/account/addresses" },
|
|
12
|
-
{ label: "Wallets", href: "/account/wallets" },
|
|
13
11
|
{ label: "Cimplify identity", href: "https://link.cimplify.io", external: true },
|
|
14
12
|
];
|
|
15
13
|
|
|
@@ -34,8 +34,6 @@ app/
|
|
|
34
34
|
|
|
35
35
|
account/page.tsx <AccountDashboardPage /> (native, Server Component)
|
|
36
36
|
account/orders/page.tsx <AccountOrdersPage /> (native)
|
|
37
|
-
account/addresses/page.tsx Native list + Server Actions for CRUD
|
|
38
|
-
account/wallets/page.tsx Native list + Server Actions for CRUD
|
|
39
37
|
login/page.tsx, signup/page.tsx redirects → /account
|
|
40
38
|
|
|
41
39
|
contact/page.tsx, track-order/page.tsx (find a booking)
|
|
@@ -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
|
+
}
|
|
@@ -54,8 +54,6 @@ const STATIC_LINKS: { title: string; links: { href: string; label: string }[] }[
|
|
|
54
54
|
links: [
|
|
55
55
|
{ href: "/account", label: "Account" },
|
|
56
56
|
{ href: "/account/orders", label: "Orders" },
|
|
57
|
-
{ href: "/account/addresses", label: "Addresses" },
|
|
58
|
-
{ href: "/account/wallets", label: "Wallets" },
|
|
59
57
|
{ href: "/login", label: "Sign in" },
|
|
60
58
|
{ href: "/signup", label: "Create account" },
|
|
61
59
|
{ href: "/track-order", label: "Track an order" },
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import
|
|
5
|
-
import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
4
|
+
import { CimplifyUserButton, useCimplifySession } from "@cimplify/sdk/react";
|
|
6
5
|
import { signInSilent } from "@cimplify/sdk";
|
|
7
6
|
|
|
8
7
|
const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
|
|
@@ -26,24 +25,12 @@ export function AccountPill() {
|
|
|
26
25
|
|
|
27
26
|
if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
|
|
28
27
|
|
|
29
|
-
if (session) {
|
|
30
|
-
const first = session.name?.split(/\s+/)[0] ?? "Account";
|
|
31
|
-
return (
|
|
32
|
-
<Link
|
|
33
|
-
href="/account"
|
|
34
|
-
className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
|
|
35
|
-
>
|
|
36
|
-
Hi, {first}
|
|
37
|
-
</Link>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
28
|
return (
|
|
42
|
-
<
|
|
29
|
+
<CimplifyUserButton
|
|
30
|
+
session={session}
|
|
43
31
|
clientId={CLIENT_ID}
|
|
44
32
|
redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
|
|
45
|
-
|
|
46
|
-
onSuccess={() => refresh()}
|
|
33
|
+
onSignIn={refresh}
|
|
47
34
|
/>
|
|
48
35
|
);
|
|
49
36
|
}
|
|
@@ -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
|
+
}
|
|
@@ -8,8 +8,6 @@ import type { NavItem } from "@cimplify/sdk/react";
|
|
|
8
8
|
export const ACCOUNT_NAV: NavItem[] = [
|
|
9
9
|
{ label: "Dashboard", href: "/account" },
|
|
10
10
|
{ label: "Orders", href: "/account/orders" },
|
|
11
|
-
{ label: "Addresses", href: "/account/addresses" },
|
|
12
|
-
{ label: "Wallets", href: "/account/wallets" },
|
|
13
11
|
{ label: "Cimplify identity", href: "https://link.cimplify.io", external: true },
|
|
14
12
|
];
|
|
15
13
|
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
|
|
3
|
-
import { revalidatePath } from "next/cache";
|
|
4
|
-
import { apiFetch, serverAccessToken } from "@/lib/cimplify-server";
|
|
5
|
-
import type { CustomerAddress } from "@cimplify/sdk";
|
|
6
|
-
|
|
7
|
-
const ACCOUNT_ADDRESSES = "/account/addresses";
|
|
8
|
-
|
|
9
|
-
function required(form: FormData, key: string): string {
|
|
10
|
-
const value = String(form.get(key) ?? "").trim();
|
|
11
|
-
if (!value) throw new Error(`Missing required field: ${key}`);
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function optional(form: FormData, key: string): string | undefined {
|
|
16
|
-
const value = String(form.get(key) ?? "").trim();
|
|
17
|
-
return value || undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function createAddressAction(form: FormData): Promise<void> {
|
|
21
|
-
const bearer = await serverAccessToken();
|
|
22
|
-
await apiFetch<CustomerAddress>("/v1/link/addresses", {
|
|
23
|
-
bearer,
|
|
24
|
-
method: "POST",
|
|
25
|
-
body: JSON.stringify({
|
|
26
|
-
label: optional(form, "label"),
|
|
27
|
-
street_address: required(form, "street_address"),
|
|
28
|
-
apartment: optional(form, "apartment"),
|
|
29
|
-
city: required(form, "city"),
|
|
30
|
-
region: optional(form, "region"),
|
|
31
|
-
postal_code: optional(form, "postal_code"),
|
|
32
|
-
country: optional(form, "country"),
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
revalidatePath(ACCOUNT_ADDRESSES);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function deleteAddressAction(form: FormData): Promise<void> {
|
|
39
|
-
const bearer = await serverAccessToken();
|
|
40
|
-
const id = required(form, "address_id");
|
|
41
|
-
await apiFetch<unknown>(`/v1/link/addresses/${encodeURIComponent(id)}`, {
|
|
42
|
-
bearer,
|
|
43
|
-
method: "DELETE",
|
|
44
|
-
});
|
|
45
|
-
revalidatePath(ACCOUNT_ADDRESSES);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export async function setDefaultAddressAction(form: FormData): Promise<void> {
|
|
49
|
-
const bearer = await serverAccessToken();
|
|
50
|
-
const id = required(form, "address_id");
|
|
51
|
-
await apiFetch<unknown>(`/v1/link/addresses/${encodeURIComponent(id)}/default`, {
|
|
52
|
-
bearer,
|
|
53
|
-
method: "POST",
|
|
54
|
-
});
|
|
55
|
-
revalidatePath(ACCOUNT_ADDRESSES);
|
|
56
|
-
}
|