@feedmepos/mf-order-setting 0.0.16-alpha.1 → 0.0.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.
@@ -0,0 +1,289 @@
1
+ import { defineComponent as O, computed as _, openBlock as c, createElementBlock as k, createElementVNode as n, toDisplayString as l, unref as o, Fragment as L, renderList as j, createCommentVNode as f, ref as b, defineAsyncComponent as z, watch as G, resolveComponent as I, createVNode as S, createBlock as R } from "vue";
2
+ import { u as J, _ as Q } from "./KioskDevicesView.vue_vue_type_script_setup_true_lang-uz5kCfDz.js";
3
+ import { useI18n as $, useCoreStore as W } from "@feedmepos/mf-common";
4
+ import { useDialog as X, useSnackbar as Y } from "@feedmepos/ui-library";
5
+ import { defineStore as Z } from "pinia";
6
+ import { O as N, c as ee } from "./index-CpFXjGaf.js";
7
+ import { F as te } from "./dayjs.min-vPr9KJUN.js";
8
+ const se = { class: "p-[1.5rem] border fm-corner-radius-lg flex flex-col gap-5" }, ne = { class: "fm-typo-en-title-sm-600" }, oe = { class: "flex flex-col gap-1" }, ae = { class: "flex flex-col gap-1" }, ie = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, re = { class: "fm-typo-en-body-lg-600" }, de = { key: 0 }, le = { key: 1 }, ce = { key: 0 }, ue = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, pe = { class: "fm-typo-en-body-lg-600 block" }, me = { key: 1 }, ke = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ve = { class: "fm-typo-en-body-lg-600 block" }, _e = { key: 2 }, fe = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, ye = { class: "fm-typo-en-body-lg-600 block" }, ge = /* @__PURE__ */ O({
9
+ __name: "KioskSummary",
10
+ props: {
11
+ restaurantId: {},
12
+ devices: {},
13
+ kioskOrderSetting: {}
14
+ },
15
+ setup(t) {
16
+ const { t: e } = $(), i = t, s = _(() => {
17
+ var r;
18
+ return (r = i.kioskOrderSetting) != null && r.dineIn.enabled ? e("order.activated") : e("order.deactivated");
19
+ }), d = _(() => {
20
+ var r;
21
+ return (r = i.kioskOrderSetting) != null && r.takeaway.enabled ? e("order.activated") : e("order.deactivated");
22
+ }), a = _(() => {
23
+ var r, u;
24
+ return (r = i.kioskOrderSetting) != null && r.dineIn.displayStand ? e("order.tableService") : (u = i.kioskOrderSetting) != null && u.dineIn && !i.kioskOrderSetting.dineIn.displayStand ? e("order.pickAtCounter") : e("order.unknown");
25
+ });
26
+ return (r, u) => (c(), k("div", se, [
27
+ n("span", ne, l(o(e)("order.kioskSummary")), 1),
28
+ u[0] || (u[0] = n("hr", { class: "my-[0.25rem]" }, null, -1)),
29
+ n("div", oe, [
30
+ n("div", ae, [
31
+ n("span", ie, l(o(e)("order.kioskDisplay")), 1),
32
+ n("div", re, [
33
+ r.devices.length > 0 ? (c(), k("div", de, [
34
+ (c(!0), k(L, null, j(r.devices, (p) => (c(), k("li", {
35
+ class: "block",
36
+ key: p.machineId
37
+ }, l(p.name), 1))), 128))
38
+ ])) : (c(), k("div", le, "-"))
39
+ ]),
40
+ s.value === o(e)("order.activated") ? (c(), k("div", ce, [
41
+ n("span", ue, l(o(e)("order.dineIn")), 1),
42
+ n("div", pe, [
43
+ n("div", null, l(s.value), 1)
44
+ ])
45
+ ])) : f("", !0),
46
+ s.value === o(e)("order.activated") && a.value !== o(e)("order.unknown") ? (c(), k("div", me, [
47
+ n("span", ke, l(o(e)("order.dineInType")), 1),
48
+ n("div", ve, [
49
+ n("div", null, l(a.value), 1)
50
+ ])
51
+ ])) : f("", !0),
52
+ d.value === o(e)("order.activated") ? (c(), k("div", _e, [
53
+ n("span", fe, l(o(e)("order.takeaway")), 1),
54
+ n("div", ye, [
55
+ n("div", null, l(d.value), 1)
56
+ ])
57
+ ])) : f("", !0)
58
+ ])
59
+ ])
60
+ ]));
61
+ }
62
+ }), Se = { class: "flex flex-col gap-5 pb-6" }, be = { class: "fm-typo-en-body-md-400 block" }, he = { class: "fm-typo-en-title-md-600" }, xe = /* @__PURE__ */ O({
63
+ __name: "KioskOtpDialog",
64
+ props: {
65
+ otp: {}
66
+ },
67
+ setup(t) {
68
+ const { t: e } = $();
69
+ return (i, s) => (c(), k("div", Se, [
70
+ n("span", be, l(o(e)("order.bindDeviceMessage")), 1),
71
+ n("div", he, l(i.otp), 1)
72
+ ]));
73
+ }
74
+ }), D = {
75
+ enabled: !1,
76
+ prefix: null,
77
+ padDigit: 0,
78
+ standSlotRange: {
79
+ min: 1,
80
+ max: 10
81
+ }
82
+ }, K = {
83
+ enabled: !1
84
+ }, we = {
85
+ dineIn: {
86
+ enabled: !1,
87
+ pickUp: K,
88
+ sequenceNumber: te.parse({}),
89
+ displayStand: D
90
+ },
91
+ takeaway: {
92
+ enabled: !1
93
+ }
94
+ }, Ie = (t) => {
95
+ var e;
96
+ return {
97
+ kiosk: De(t.kioskSettings, (e = t.sequenceSettings) == null ? void 0 : e.kioskDineIn)
98
+ };
99
+ }, De = (t, e) => ({
100
+ dineIn: Ke(e ?? {
101
+ current: 0,
102
+ prefix: "#K"
103
+ }, t.dineIn ?? void 0),
104
+ takeaway: {
105
+ enabled: (t == null ? void 0 : t.canTakeaway) ?? !1
106
+ }
107
+ }), Ke = (t, e) => {
108
+ if (e) {
109
+ const s = e.displayStand, d = e.pickUp ?? K;
110
+ return {
111
+ enabled: !0,
112
+ sequenceNumber: t,
113
+ pickUp: d,
114
+ displayStand: s ? {
115
+ enabled: s.enabled,
116
+ standSlotRange: s.standSlotRange,
117
+ prefix: s.prefix,
118
+ padDigit: s.padDigit
119
+ } : D
120
+ };
121
+ } else
122
+ return {
123
+ enabled: !1,
124
+ sequenceNumber: t,
125
+ displayStand: D,
126
+ pickUp: K
127
+ };
128
+ }, Oe = (t) => {
129
+ const i = ((s) => {
130
+ if (s.enabled)
131
+ return {
132
+ dineIn: {
133
+ requiredSlot: !!s.displayStand,
134
+ displayStand: s.displayStand,
135
+ pickUp: s.pickUp
136
+ },
137
+ kioskDineIn: s.sequenceNumber
138
+ };
139
+ })(t.dineIn);
140
+ if (i) {
141
+ const { dineIn: s, kioskDineIn: d } = i;
142
+ return {
143
+ kioskSettings: {
144
+ canTakeaway: t.takeaway.enabled,
145
+ dineIn: s
146
+ },
147
+ kioskDineIn: d
148
+ };
149
+ } else
150
+ return {
151
+ kioskSettings: {
152
+ canTakeaway: t.takeaway.enabled,
153
+ dineIn: void 0
154
+ }
155
+ };
156
+ }, T = {
157
+ convertOrderSettingDto: Ie,
158
+ toOrderKioskSettingsDto: Oe
159
+ }, $e = Z("orderSetting", () => {
160
+ const t = b({});
161
+ async function e() {
162
+ const a = await N.getOrderSetting();
163
+ s(a);
164
+ }
165
+ async function i() {
166
+ if (t.value.orderSetting && t.value.kiosk) {
167
+ const { _id: a, ...r } = t.value.orderSetting, u = T.toOrderKioskSettingsDto(t.value.kiosk), p = {
168
+ ...r,
169
+ kioskSettings: u.kioskSettings
170
+ }, h = await N.updateOrderSetting(p);
171
+ s(h);
172
+ }
173
+ }
174
+ function s(a) {
175
+ t.value.orderSetting = a, t.value.kiosk = T.convertOrderSettingDto(a).kiosk;
176
+ }
177
+ function d(a) {
178
+ t.value.kiosk = a;
179
+ }
180
+ return {
181
+ state: t,
182
+ getSetting: e,
183
+ updateKioskSetting: i,
184
+ setKioskOrderSetting: d
185
+ };
186
+ }), Fe = { class: "py-[1.5rem]" }, Ue = { class: "flex px-[1.5rem]" }, Ve = { class: "flex-[2_2_0%]" }, qe = { class: "pt-[1.5rem]" }, Ce = { class: "flex flex-col gap-10" }, Re = { class: "flex flex-col gap-2" }, Ne = { class: "fm-typo-en-title-sm-600" }, Te = { class: "fm-typo-en-title-sm-400" }, Be = { class: "flex-[1_1_0%]" }, ze = /* @__PURE__ */ O({
187
+ __name: "KioskView",
188
+ setup(t) {
189
+ var q, C;
190
+ const { t: e } = $(), i = z(() => import("./KioskSettingView-6Q0qwSTl.js")), s = b("device"), d = J(), a = $e(), r = X(), { currentRestaurant: u, restaurants: p, changeRestaurant: h } = W(), F = Y(), y = b(((q = u.value) == null ? void 0 : q._id) ?? void 0), B = _(() => p.value.map((m) => ({
191
+ label: m.profile.name,
192
+ value: m._id
193
+ }))), g = b(((C = u.value) == null ? void 0 : C._id) ?? "");
194
+ async function U(m) {
195
+ const v = p.value.find((x) => x._id == m);
196
+ await h(v), await a.getSetting(), await d.getDevices(), y.value = m, g.value = m;
197
+ }
198
+ const A = _(() => [
199
+ {
200
+ label: e("order.deviceBinding"),
201
+ value: "device"
202
+ },
203
+ {
204
+ label: e("order.settings"),
205
+ value: "setting"
206
+ }
207
+ ]), V = _(() => d.state.devices);
208
+ async function P() {
209
+ await d.requestOtp(), r.open({
210
+ title: ee(e("order.bindDevice")),
211
+ contentComponent: xe,
212
+ contentComponentProps: {
213
+ otp: d.state.otp
214
+ }
215
+ });
216
+ }
217
+ async function M(m) {
218
+ try {
219
+ a.setKioskOrderSetting(m), await a.updateKioskSetting(), F.open({
220
+ title: e("order.kioskSettingSuccess"),
221
+ type: "success"
222
+ });
223
+ } catch {
224
+ F.open({
225
+ title: e("order.kioskSettingFailed"),
226
+ type: "error"
227
+ });
228
+ }
229
+ }
230
+ return G(() => p.value.length, async (m) => {
231
+ y.value === void 0 && p.value.length > 0 && await U(p.value[0]._id);
232
+ }, { immediate: !0 }), (m, v) => {
233
+ const x = I("FmPageHead"), E = I("FmTabs"), H = I("FmSelect");
234
+ return c(), k("div", Fe, [
235
+ S(x, {
236
+ title: o(e)("order.kiosk")
237
+ }, null, 8, ["title"]),
238
+ n("div", Ue, [
239
+ n("div", Ve, [
240
+ S(E, {
241
+ "model-value": s.value,
242
+ "onUpdate:modelValue": v[0] || (v[0] = (w) => s.value = w),
243
+ items: A.value
244
+ }, null, 8, ["model-value", "items"]),
245
+ n("div", qe, [
246
+ n("div", Ce, [
247
+ n("div", Re, [
248
+ n("span", Ne, l(o(e)("order.activateLocation")), 1),
249
+ n("span", Te, l(o(e)("order.selectRestaurant")) + ": ", 1),
250
+ S(H, {
251
+ class: "w-1/2",
252
+ modelValue: y.value,
253
+ "onUpdate:modelValue": [
254
+ v[1] || (v[1] = (w) => y.value = w),
255
+ U
256
+ ],
257
+ items: B.value,
258
+ placeholder: o(e)("order.selectItem")
259
+ }, null, 8, ["modelValue", "items", "placeholder"])
260
+ ]),
261
+ s.value == "device" ? (c(), R(Q, {
262
+ key: 0,
263
+ devices: V.value,
264
+ "request-otp": P
265
+ }, null, 8, ["devices"])) : f("", !0),
266
+ s.value == "setting" ? (c(), R(o(i), {
267
+ key: `KioskSettingView-${g.value}`,
268
+ "restaurant-id": g.value,
269
+ onUpdateKioskOrderSetting: M,
270
+ form: o(a).state.kiosk ?? o(we)
271
+ }, null, 8, ["restaurant-id", "form"])) : f("", !0)
272
+ ])
273
+ ])
274
+ ]),
275
+ n("div", Be, [
276
+ S(ge, {
277
+ "restaurant-id": g.value,
278
+ devices: V.value,
279
+ "kiosk-order-setting": o(a).state.kiosk
280
+ }, null, 8, ["restaurant-id", "devices", "kiosk-order-setting"])
281
+ ])
282
+ ])
283
+ ]);
284
+ };
285
+ }
286
+ });
287
+ export {
288
+ ze as default
289
+ };