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