@feedmepos/mf-miniprogram-v2 0.2.2-dev.12 → 0.2.2-dev.14

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.
@@ -0,0 +1,299 @@
1
+ import { defineComponent as W, ref as r, computed as E, resolveComponent as h, openBlock as n, createBlock as S, withCtx as I, createVNode as d, createElementVNode as s, toDisplayString as c, createCommentVNode as F, unref as le, createElementBlock as v, onMounted as oe, onScopeDispose as ne, createTextVNode as k, Fragment as H, renderList as se } from "vue";
2
+ import { a as A } from "./routes-DXQSkGM7.js";
3
+ import { useDialog as ie } from "@feedmepos/ui-library";
4
+ import { c as P, e as $ } from "./controlPlane-CoEgf9BA.js";
5
+ import { _ as re } from "./StatusBadge.vue_vue_type_script_setup_true_lang-Bh9Eoe_H.js";
6
+ import { _ as Y } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
+ const de = ["qsr", "coffee", "tea"], J = [
8
+ // `label` and `description` are MERCHANT-FACING: the portal's picker renders
9
+ // them, and they are the only thing a merchant chooses on. Say what the app does
10
+ // for their customers, never which package it is built from — the SDK is real and
11
+ // load-bearing and means nothing to the person making this decision.
12
+ {
13
+ id: "miniprogram-vue",
14
+ label: "Phone ordering app",
15
+ description: "Menu browsing, cart and checkout, membership and rewards, and order history — for customers ordering on their own phone.",
16
+ industries: [],
17
+ environments: ["dev", "prod"],
18
+ default: !0
19
+ },
20
+ {
21
+ id: "miniprogram-vue-v2",
22
+ label: "Phone, kiosk and tablet",
23
+ description: "Everything in the phone app, plus self-order kiosk and in-store tablet surfaces sharing the same menu, cart and membership.",
24
+ industries: [],
25
+ // Dev only, deliberately. It has never been provisioned end-to-end: the
26
+ // preview proxy, the component-library unpack and the release build have
27
+ // only been exercised locally. Add 'prod' after a real merchant has run
28
+ // through all three.
29
+ environments: ["dev"]
30
+ }
31
+ ], ue = {
32
+ key: 2,
33
+ class: "portal-error",
34
+ role: "alert"
35
+ }, K = "miniprogram-vue-v2", ce = /* @__PURE__ */ W({
36
+ __name: "TemplateChoiceDialog",
37
+ props: {
38
+ choice: {}
39
+ },
40
+ emits: ["saved", "close"],
41
+ setup(x, { emit: g }) {
42
+ var B, L, R, U, O, z, M;
43
+ const i = x, C = g, m = r(((B = i.choice) == null ? void 0 : B.id) ?? ""), b = r(((L = i.choice) == null ? void 0 : L.appTemplateId) ?? K), _ = r(((R = i.choice) == null ? void 0 : R.restaurantStyle) ?? "qsr"), f = r(((U = i.choice) == null ? void 0 : U.label) ?? ""), y = r(((O = i.choice) == null ? void 0 : O.description) ?? ""), T = r((((z = i.choice) == null ? void 0 : z.industries) ?? []).join(", ")), V = r(((M = i.choice) == null ? void 0 : M.default) ?? !1), e = r(!1), u = r(""), l = E(() => !!i.choice), t = E(
44
+ () => (l.value ? J : J.filter((p) => p.id === K)).map((p) => ({ label: p.label, value: p.id }))
45
+ ), w = E(() => b.value === "miniprogram-vue-v2"), Q = de.map((p) => ({ label: p, value: p })), N = E(
46
+ () => !e.value && f.value.trim().length > 0 && y.value.trim().length > 0 && (l.value ? !0 : /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(m.value.trim()))
47
+ );
48
+ async function X() {
49
+ if (!N.value) return;
50
+ e.value = !0, u.value = "";
51
+ const p = {
52
+ ...l.value ? {} : { id: m.value.trim() },
53
+ appTemplateId: b.value,
54
+ label: f.value.trim(),
55
+ description: y.value.trim(),
56
+ industries: T.value.split(",").map((a) => a.trim()).filter(Boolean),
57
+ default: V.value,
58
+ ...w.value ? { restaurantStyle: _.value } : {}
59
+ };
60
+ try {
61
+ await P(
62
+ l.value ? A.appTemplateChoice(i.choice.id) : A.appTemplateChoices(),
63
+ { method: l.value ? "PATCH" : "POST", body: JSON.stringify(p) }
64
+ ), C("saved");
65
+ } catch (a) {
66
+ u.value = $(a);
67
+ } finally {
68
+ e.value = !1;
69
+ }
70
+ }
71
+ return (p, a) => {
72
+ const D = h("FmTextField"), j = h("FmSelect"), Z = h("FmTextarea"), ee = h("FmSwitch"), q = h("FmButton"), te = h("FmCard"), ae = h("FmForm");
73
+ return n(), S(ae, { onValidationSuccess: X }, {
74
+ default: I(() => [
75
+ d(te, { class: "template-choice-dialog" }, {
76
+ default: I(() => {
77
+ var G;
78
+ return [
79
+ s("h2", null, c(l.value ? `Edit ${(G = x.choice) == null ? void 0 : G.label}` : "New template choice"), 1),
80
+ l.value ? F("", !0) : (n(), S(D, {
81
+ key: 0,
82
+ modelValue: m.value,
83
+ "onUpdate:modelValue": a[0] || (a[0] = (o) => m.value = o),
84
+ label: "Choice id",
85
+ placeholder: "e.g. miniprogram-vue-v2-bakery",
86
+ "helper-text": "Lowercase, kebab-case. Cannot be changed after creation.",
87
+ disabled: e.value,
88
+ rules: [(o) => /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(o.trim()) || "Lowercase kebab-case, e.g. miniprogram-vue-v2-bakery"]
89
+ }, null, 8, ["modelValue", "disabled", "rules"])),
90
+ d(j, {
91
+ modelValue: b.value,
92
+ "onUpdate:modelValue": a[1] || (a[1] = (o) => b.value = o),
93
+ label: "Physical template",
94
+ items: t.value,
95
+ disabled: e.value || l.value || t.value.length <= 1
96
+ }, null, 8, ["modelValue", "items", "disabled"]),
97
+ w.value ? (n(), S(j, {
98
+ key: 1,
99
+ modelValue: _.value,
100
+ "onUpdate:modelValue": a[2] || (a[2] = (o) => _.value = o),
101
+ label: "Restaurant style",
102
+ "helper-text": "Only styles templates/miniprogram-vue-v2/src/brand/recipes.ts already implements.",
103
+ items: le(Q),
104
+ disabled: e.value
105
+ }, null, 8, ["modelValue", "items", "disabled"])) : F("", !0),
106
+ d(D, {
107
+ modelValue: f.value,
108
+ "onUpdate:modelValue": a[3] || (a[3] = (o) => f.value = o),
109
+ label: "Label",
110
+ placeholder: "Shown to merchants in the picker",
111
+ disabled: e.value
112
+ }, null, 8, ["modelValue", "disabled"]),
113
+ d(Z, {
114
+ modelValue: y.value,
115
+ "onUpdate:modelValue": a[4] || (a[4] = (o) => y.value = o),
116
+ label: "Description",
117
+ placeholder: "One or two sentences on what the merchant gets",
118
+ disabled: e.value
119
+ }, null, 8, ["modelValue", "disabled"]),
120
+ d(D, {
121
+ modelValue: T.value,
122
+ "onUpdate:modelValue": a[5] || (a[5] = (o) => T.value = o),
123
+ label: "Industries (comma-separated)",
124
+ placeholder: "e.g. Food & beverage",
125
+ disabled: e.value
126
+ }, null, 8, ["modelValue", "disabled"]),
127
+ d(ee, {
128
+ modelValue: V.value,
129
+ "onUpdate:modelValue": a[6] || (a[6] = (o) => V.value = o),
130
+ label: "Default choice",
131
+ sublabel: "Used when a provision request names none",
132
+ disabled: e.value
133
+ }, null, 8, ["modelValue", "disabled"]),
134
+ u.value ? (n(), v("p", ue, c(u.value), 1)) : F("", !0),
135
+ s("footer", null, [
136
+ d(q, {
137
+ label: "Cancel",
138
+ variant: "tertiary",
139
+ disabled: e.value,
140
+ onClick: a[7] || (a[7] = (o) => C("close"))
141
+ }, null, 8, ["disabled"]),
142
+ d(q, {
143
+ label: l.value ? "Save" : "Create",
144
+ type: "submit",
145
+ loading: e.value,
146
+ disabled: !N.value
147
+ }, null, 8, ["label", "loading", "disabled"])
148
+ ])
149
+ ];
150
+ }),
151
+ _: 1
152
+ })
153
+ ]),
154
+ _: 1
155
+ });
156
+ };
157
+ }
158
+ }), me = /* @__PURE__ */ Y(ce, [["__scopeId", "data-v-9346a740"]]), pe = { class: "portal-page" }, ve = { class: "portal-page-inner" }, be = { class: "portal-page-heading" }, _e = {
159
+ key: 0,
160
+ class: "portal-error",
161
+ role: "alert"
162
+ }, he = {
163
+ key: 1,
164
+ role: "status"
165
+ }, fe = {
166
+ key: 2,
167
+ class: "template-choices__list",
168
+ "aria-label": "Template choices"
169
+ }, ye = { class: "template-choices__name" }, ge = { class: "template-choices__label" }, Ce = { key: 0 }, ke = { class: "template-choices__id" }, Te = { class: "template-choices__meta" }, Ve = ["datetime"], we = { class: "template-choices__actions" }, Se = /* @__PURE__ */ W({
170
+ __name: "TemplateCenterView",
171
+ setup(x) {
172
+ const g = ie(), i = r([]), C = r(!0), m = r(""), b = new AbortController();
173
+ async function _() {
174
+ C.value = !0, m.value = "";
175
+ try {
176
+ const e = await P(A.appTemplateChoices(), {
177
+ signal: b.signal
178
+ });
179
+ i.value = e.choices;
180
+ } catch (e) {
181
+ b.signal.aborted || (m.value = $(e));
182
+ } finally {
183
+ C.value = !1;
184
+ }
185
+ }
186
+ function f(e) {
187
+ g.open({
188
+ title: e ? `Edit ${e.label}` : "New template choice",
189
+ dialogComponent: me,
190
+ dialogComponentProps: {
191
+ choice: e,
192
+ onClose: () => g.close(),
193
+ onSaved: () => {
194
+ g.close(), _();
195
+ }
196
+ }
197
+ });
198
+ }
199
+ async function y(e, u) {
200
+ try {
201
+ await P(
202
+ u === "archived" ? A.appTemplateChoiceArchive(e.id) : A.appTemplateChoiceRestore(e.id),
203
+ { method: "POST" }
204
+ ), await _();
205
+ } catch (l) {
206
+ m.value = $(l);
207
+ }
208
+ }
209
+ function T(e) {
210
+ g.open({
211
+ title: `Archive ${e.label}?`,
212
+ message: "It stops appearing for new projects. Merchants already provisioned from it are unaffected — it is never consulted again after provisioning.",
213
+ primaryActions: { text: "Archive", close: !0, variant: "primary" },
214
+ secondaryActions: { text: "Cancel", close: !0, variant: "tertiary" }
215
+ }).onPrimary(() => void y(e, "archived"));
216
+ }
217
+ function V(e) {
218
+ return new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short" }).format(new Date(e));
219
+ }
220
+ return oe(() => void _()), ne(() => b.abort()), (e, u) => {
221
+ const l = h("FmButton");
222
+ return n(), v("div", pe, [
223
+ s("div", ve, [
224
+ s("header", be, [
225
+ u[1] || (u[1] = s("div", null, [
226
+ s("p", { class: "portal-eyebrow" }, "Internal"),
227
+ s("h1", null, "Template Center")
228
+ ], -1)),
229
+ d(l, {
230
+ label: "New choice",
231
+ icon: "add",
232
+ onClick: u[0] || (u[0] = (t) => f())
233
+ })
234
+ ]),
235
+ m.value ? (n(), v("p", _e, [
236
+ k(c(m.value) + " ", 1),
237
+ d(l, {
238
+ label: "Retry",
239
+ variant: "tertiary",
240
+ onClick: _
241
+ })
242
+ ])) : C.value ? (n(), v("p", he, "Loading template choices…")) : (n(), v("section", fe, [
243
+ (n(!0), v(H, null, se(i.value, (t) => (n(), v("article", {
244
+ key: t.id,
245
+ class: "template-choices__row"
246
+ }, [
247
+ s("div", ye, [
248
+ s("span", ge, [
249
+ k(c(t.label), 1),
250
+ t.default ? (n(), v("span", Ce, " · Default")) : F("", !0)
251
+ ]),
252
+ s("span", ke, c(t.id), 1),
253
+ s("span", Te, [
254
+ k(c(t.appTemplateId), 1),
255
+ t.restaurantStyle ? (n(), v(H, { key: 0 }, [
256
+ k(" · " + c(t.restaurantStyle), 1)
257
+ ], 64)) : F("", !0),
258
+ k(" · " + c(t.industries.join(", ") || "General-purpose") + " · " + c((t.environments ?? []).join(", ")), 1)
259
+ ])
260
+ ]),
261
+ d(re, {
262
+ variant: t.status === "active" ? "success" : "neutral"
263
+ }, {
264
+ default: I(() => [
265
+ k(c(t.status === "active" ? "Active" : "Archived"), 1)
266
+ ]),
267
+ _: 2
268
+ }, 1032, ["variant"]),
269
+ s("time", {
270
+ datetime: t.updatedAt
271
+ }, c(V(t.updatedAt)), 9, Ve),
272
+ s("div", we, [
273
+ d(l, {
274
+ label: "Edit",
275
+ variant: "secondary",
276
+ onClick: (w) => f(t)
277
+ }, null, 8, ["onClick"]),
278
+ t.status === "active" ? (n(), S(l, {
279
+ key: 0,
280
+ label: "Archive",
281
+ variant: "tertiary",
282
+ onClick: (w) => T(t)
283
+ }, null, 8, ["onClick"])) : (n(), S(l, {
284
+ key: 1,
285
+ label: "Restore",
286
+ variant: "tertiary",
287
+ onClick: (w) => y(t, "active")
288
+ }, null, 8, ["onClick"]))
289
+ ])
290
+ ]))), 128))
291
+ ]))
292
+ ])
293
+ ]);
294
+ };
295
+ }
296
+ }), Pe = /* @__PURE__ */ Y(Se, [["__scopeId", "data-v-da7cd846"]]);
297
+ export {
298
+ Pe as default
299
+ };
package/dist/app.js CHANGED
@@ -70,7 +70,7 @@ const o = [
70
70
  path: "/internal/template-center",
71
71
  name: "miniprogram-v2-template-center",
72
72
  meta: { title: "Template Center", requiresAdmin: !0 },
73
- component: () => import("./TemplateCenterView-QFMGVcnE.js")
73
+ component: () => import("./TemplateCenterView-B_Yvaeza.js")
74
74
  },
75
75
  {
76
76
  path: "/:pathMatch(.*)*",
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/mf-miniprogram-v2",
3
- "version": "0.2.2-dev.12",
3
+ "version": "0.2.2-dev.14",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",