@cimplify/cli 0.7.15 → 0.7.16

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 (82) hide show
  1. package/dist/{add-A5PYZXDS.mjs → add-YRLROMEN.mjs} +1 -1
  2. package/dist/{chunk-WNVMNOW7.mjs → chunk-7CCC37ER.mjs} +1 -1
  3. package/dist/{chunk-U7L3GR3Y.mjs → chunk-7PNEG4JY.mjs} +16 -24
  4. package/dist/{chunk-DY5TIVWB.mjs → chunk-ATCBAM44.mjs} +1 -1
  5. package/dist/dispatcher.mjs +9 -9
  6. package/dist/{doctor-W2BBP6OL.mjs → doctor-UMTO3BI6.mjs} +2 -2
  7. package/dist/{explain-N6DBSJHA.mjs → explain-2VWT5OFP.mjs} +1 -1
  8. package/dist/{introspect-ED3XKT4A.mjs → introspect-PCLYGIDK.mjs} +2 -2
  9. package/dist/{list-X3D3GABS.mjs → list-6FUJKW7D.mjs} +1 -1
  10. package/dist/{update-2SWGQJR2.mjs → update-CCNTKRPV.mjs} +1 -1
  11. package/package.json +1 -1
  12. package/templates/storefront-auto/app/sitemap-page/page.tsx +0 -2
  13. package/templates/storefront-auto/components/account-pill.tsx +4 -17
  14. package/templates/storefront-auto/lib/brand.ts +0 -1
  15. package/templates/storefront-auto/lib/cimplify-server.ts +0 -2
  16. package/templates/storefront-bakery/AGENTS.md +0 -2
  17. package/templates/storefront-bakery/app/sitemap-page/page.tsx +0 -2
  18. package/templates/storefront-bakery/components/account-pill.tsx +4 -17
  19. package/templates/storefront-bakery/lib/brand.ts +0 -1
  20. package/templates/storefront-bakery/lib/cimplify-server.ts +0 -2
  21. package/templates/storefront-fashion/AGENTS.md +0 -2
  22. package/templates/storefront-fashion/app/sitemap-page/page.tsx +0 -2
  23. package/templates/storefront-fashion/components/account-pill.tsx +4 -17
  24. package/templates/storefront-fashion/lib/brand.ts +0 -1
  25. package/templates/storefront-fashion/lib/cimplify-server.ts +0 -2
  26. package/templates/storefront-grocery/AGENTS.md +0 -2
  27. package/templates/storefront-grocery/app/sitemap-page/page.tsx +0 -2
  28. package/templates/storefront-grocery/components/account-pill.tsx +4 -17
  29. package/templates/storefront-grocery/lib/brand.ts +0 -1
  30. package/templates/storefront-grocery/lib/cimplify-server.ts +0 -2
  31. package/templates/storefront-pharmacy/AGENTS.md +0 -2
  32. package/templates/storefront-pharmacy/app/sitemap-page/page.tsx +0 -2
  33. package/templates/storefront-pharmacy/components/account-pill.tsx +4 -17
  34. package/templates/storefront-pharmacy/lib/brand.ts +0 -1
  35. package/templates/storefront-pharmacy/lib/cimplify-server.ts +0 -2
  36. package/templates/storefront-restaurant/AGENTS.md +0 -2
  37. package/templates/storefront-restaurant/app/sitemap-page/page.tsx +0 -2
  38. package/templates/storefront-restaurant/components/account-pill.tsx +4 -17
  39. package/templates/storefront-restaurant/lib/brand.ts +0 -1
  40. package/templates/storefront-restaurant/lib/cimplify-server.ts +0 -2
  41. package/templates/storefront-retail/AGENTS.md +0 -2
  42. package/templates/storefront-retail/app/sitemap-page/page.tsx +0 -2
  43. package/templates/storefront-retail/components/account-pill.tsx +4 -17
  44. package/templates/storefront-retail/lib/brand.ts +0 -1
  45. package/templates/storefront-retail/lib/cimplify-server.ts +0 -2
  46. package/templates/storefront-services/AGENTS.md +0 -2
  47. package/templates/storefront-services/app/sitemap-page/page.tsx +0 -2
  48. package/templates/storefront-services/components/account-pill.tsx +4 -17
  49. package/templates/storefront-services/lib/brand.ts +0 -1
  50. package/templates/storefront-services/lib/cimplify-server.ts +0 -2
  51. package/templates/storefront-auto/app/account/addresses/actions.ts +0 -56
  52. package/templates/storefront-auto/app/account/addresses/page.tsx +0 -184
  53. package/templates/storefront-auto/app/account/wallets/actions.ts +0 -52
  54. package/templates/storefront-auto/app/account/wallets/page.tsx +0 -185
  55. package/templates/storefront-bakery/app/account/addresses/actions.ts +0 -56
  56. package/templates/storefront-bakery/app/account/addresses/page.tsx +0 -184
  57. package/templates/storefront-bakery/app/account/wallets/actions.ts +0 -52
  58. package/templates/storefront-bakery/app/account/wallets/page.tsx +0 -185
  59. package/templates/storefront-fashion/app/account/addresses/actions.ts +0 -56
  60. package/templates/storefront-fashion/app/account/addresses/page.tsx +0 -184
  61. package/templates/storefront-fashion/app/account/wallets/actions.ts +0 -52
  62. package/templates/storefront-fashion/app/account/wallets/page.tsx +0 -185
  63. package/templates/storefront-grocery/app/account/addresses/actions.ts +0 -56
  64. package/templates/storefront-grocery/app/account/addresses/page.tsx +0 -184
  65. package/templates/storefront-grocery/app/account/wallets/actions.ts +0 -52
  66. package/templates/storefront-grocery/app/account/wallets/page.tsx +0 -185
  67. package/templates/storefront-pharmacy/app/account/addresses/actions.ts +0 -56
  68. package/templates/storefront-pharmacy/app/account/addresses/page.tsx +0 -184
  69. package/templates/storefront-pharmacy/app/account/wallets/actions.ts +0 -52
  70. package/templates/storefront-pharmacy/app/account/wallets/page.tsx +0 -185
  71. package/templates/storefront-restaurant/app/account/addresses/actions.ts +0 -56
  72. package/templates/storefront-restaurant/app/account/addresses/page.tsx +0 -184
  73. package/templates/storefront-restaurant/app/account/wallets/actions.ts +0 -52
  74. package/templates/storefront-restaurant/app/account/wallets/page.tsx +0 -185
  75. package/templates/storefront-retail/app/account/addresses/actions.ts +0 -56
  76. package/templates/storefront-retail/app/account/addresses/page.tsx +0 -184
  77. package/templates/storefront-retail/app/account/wallets/actions.ts +0 -52
  78. package/templates/storefront-retail/app/account/wallets/page.tsx +0 -185
  79. package/templates/storefront-services/app/account/addresses/actions.ts +0 -56
  80. package/templates/storefront-services/app/account/addresses/page.tsx +0 -184
  81. package/templates/storefront-services/app/account/wallets/actions.ts +0 -52
  82. package/templates/storefront-services/app/account/wallets/page.tsx +0 -185
@@ -1,52 +0,0 @@
1
- "use server";
2
-
3
- import { revalidatePath } from "next/cache";
4
- import { apiFetch, serverAccessToken } from "@/lib/cimplify-server";
5
- import type { CustomerMobileMoney, MobileMoneyProvider } from "@cimplify/sdk";
6
-
7
- const ACCOUNT_WALLETS = "/account/wallets";
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 createWalletAction(form: FormData): Promise<void> {
21
- const bearer = await serverAccessToken();
22
- await apiFetch<CustomerMobileMoney>("/v1/link/mobile-money", {
23
- bearer,
24
- method: "POST",
25
- body: JSON.stringify({
26
- phone_number: required(form, "phone_number"),
27
- provider: required(form, "provider") as MobileMoneyProvider,
28
- label: optional(form, "label"),
29
- }),
30
- });
31
- revalidatePath(ACCOUNT_WALLETS);
32
- }
33
-
34
- export async function deleteWalletAction(form: FormData): Promise<void> {
35
- const bearer = await serverAccessToken();
36
- const id = required(form, "mobile_money_id");
37
- await apiFetch<unknown>(`/v1/link/mobile-money/${encodeURIComponent(id)}`, {
38
- bearer,
39
- method: "DELETE",
40
- });
41
- revalidatePath(ACCOUNT_WALLETS);
42
- }
43
-
44
- export async function setDefaultWalletAction(form: FormData): Promise<void> {
45
- const bearer = await serverAccessToken();
46
- const id = required(form, "mobile_money_id");
47
- await apiFetch<unknown>(`/v1/link/mobile-money/${encodeURIComponent(id)}/default`, {
48
- bearer,
49
- method: "POST",
50
- });
51
- revalidatePath(ACCOUNT_WALLETS);
52
- }
@@ -1,185 +0,0 @@
1
- import {
2
- AccountContent,
3
- AccountHero,
4
- AccountNav,
5
- AccountShell,
6
- AccountSidebar,
7
- AccountSignedOutPrompt,
8
- Button,
9
- EmptyState,
10
- Section,
11
- } from "@cimplify/sdk/react";
12
- import type { CustomerMobileMoney } from "@cimplify/sdk";
13
- import { MOBILE_MONEY_PROVIDER } from "@cimplify/sdk";
14
- import { brand } from "@/lib/brand";
15
- import { ACCOUNT_NAV, apiFetch, serverAccessToken, serverSession } from "@/lib/cimplify-server";
16
- import {
17
- createWalletAction,
18
- deleteWalletAction,
19
- setDefaultWalletAction,
20
- } from "./actions";
21
-
22
- const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
23
- const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
24
-
25
- const PROVIDER_LABEL: Record<string, string> = {
26
- [MOBILE_MONEY_PROVIDER.MTN]: "MTN",
27
- [MOBILE_MONEY_PROVIDER.VODAFONE]: "Vodafone",
28
- [MOBILE_MONEY_PROVIDER.TELECEL]: "Telecel",
29
- [MOBILE_MONEY_PROVIDER.AIRTEL]: "Airtel",
30
- [MOBILE_MONEY_PROVIDER.AIRTELTIGO]: "AirtelTigo",
31
- [MOBILE_MONEY_PROVIDER.MPESA]: "M-Pesa",
32
- };
33
-
34
- function maskedPhone(phone: string): string {
35
- const digits = phone.replace(/\D/g, "");
36
- if (digits.length < 4) return phone;
37
- return `${phone.slice(0, 4)} ••• ${digits.slice(-3)}`;
38
- }
39
-
40
- function WalletCard({ wallet }: { wallet: CustomerMobileMoney }) {
41
- const isDefault = wallet.is_default === true;
42
- const providerLabel = PROVIDER_LABEL[wallet.provider] ?? wallet.provider;
43
- return (
44
- <div className="flex items-start justify-between gap-4 rounded-[14px] border border-border bg-card p-5">
45
- <div className="min-w-0">
46
- <div className="flex items-center gap-2 mb-1.5">
47
- <span className="text-[14px] font-medium text-foreground">
48
- {wallet.label || providerLabel}
49
- </span>
50
- {isDefault && (
51
- <span className="text-[10px] font-medium tracking-[0.08em] uppercase text-foreground/60 bg-foreground/5 px-2 py-0.5 rounded-full">
52
- Default
53
- </span>
54
- )}
55
- </div>
56
- <p className="text-[13px] text-foreground/70 leading-relaxed">
57
- {providerLabel} · {maskedPhone(wallet.phone_number)}
58
- </p>
59
- </div>
60
- <div className="flex items-center gap-2 shrink-0">
61
- {!isDefault && (
62
- <form action={setDefaultWalletAction}>
63
- <input type="hidden" name="mobile_money_id" value={wallet.id} />
64
- <button
65
- type="submit"
66
- className="text-[12px] font-medium text-foreground/70 hover:text-foreground px-2 py-1"
67
- >
68
- Make default
69
- </button>
70
- </form>
71
- )}
72
- <form action={deleteWalletAction}>
73
- <input type="hidden" name="mobile_money_id" value={wallet.id} />
74
- <button
75
- type="submit"
76
- className="text-[12px] font-medium text-destructive/80 hover:text-destructive px-2 py-1"
77
- >
78
- Remove
79
- </button>
80
- </form>
81
- </div>
82
- </div>
83
- );
84
- }
85
-
86
- function AddWalletForm() {
87
- return (
88
- <form
89
- action={createWalletAction}
90
- className="rounded-[14px] border border-dashed border-border bg-card p-5 space-y-3"
91
- >
92
- <h3 className="text-[13px] font-semibold tracking-[0.02em] text-foreground">
93
- Add a mobile money wallet
94
- </h3>
95
- <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
96
- <select
97
- name="provider"
98
- required
99
- defaultValue=""
100
- className="rounded-[10px] border border-border bg-background px-3 h-10 text-[13px]"
101
- >
102
- <option value="" disabled>
103
- Provider
104
- </option>
105
- {Object.entries(PROVIDER_LABEL).map(([value, label]) => (
106
- <option key={value} value={value}>
107
- {label}
108
- </option>
109
- ))}
110
- </select>
111
- <input
112
- name="phone_number"
113
- required
114
- type="tel"
115
- inputMode="tel"
116
- autoComplete="tel"
117
- placeholder="+233 24 400 0000"
118
- className="rounded-[10px] border border-border bg-background px-3 h-10 text-[13px]"
119
- />
120
- </div>
121
- <input
122
- name="label"
123
- placeholder="Label (Personal, Business — optional)"
124
- className="rounded-[10px] border border-border bg-background px-3 h-10 text-[13px] w-full"
125
- />
126
- <div className="flex justify-end">
127
- <Button type="submit" variant="primary">
128
- Save wallet
129
- </Button>
130
- </div>
131
- </form>
132
- );
133
- }
134
-
135
- export default async function WalletsPage() {
136
- const session = await serverSession();
137
- if (!session) {
138
- return (
139
- <AccountSignedOutPrompt
140
- clientId={CLIENT_ID}
141
- redirectUri={REDIRECT_URI}
142
- eyebrow={brand.account.loginEyebrow}
143
- title={brand.account.loginTitle}
144
- description={brand.account.loginSubtitle}
145
- />
146
- );
147
- }
148
-
149
- const bearer = await serverAccessToken();
150
- const wallets =
151
- (await apiFetch<CustomerMobileMoney[]>("/v1/link/mobile-money", { bearer })) ?? [];
152
-
153
- return (
154
- <AccountShell
155
- sidebar={
156
- <AccountSidebar>
157
- <AccountNav items={ACCOUNT_NAV} activeHref="/account/wallets" />
158
- </AccountSidebar>
159
- }
160
- >
161
- <AccountHero
162
- eyebrow="Wallets"
163
- title="How would you like to pay?"
164
- subtitle="Saved wallets work across every Cimplify shop you use."
165
- />
166
- <AccountContent>
167
- <Section title="Your wallets" meta={`${wallets.length} saved`}>
168
- <div className="space-y-3">
169
- {wallets.length === 0 ? (
170
- <EmptyState
171
- title="No wallets yet"
172
- description="Add a mobile money wallet to skip the number entry next checkout."
173
- />
174
- ) : (
175
- wallets.map((wallet) => <WalletCard key={wallet.id} wallet={wallet} />)
176
- )}
177
- </div>
178
- </Section>
179
- <Section title="Add another">
180
- <AddWalletForm />
181
- </Section>
182
- </AccountContent>
183
- </AccountShell>
184
- );
185
- }