@feedmepos/mf-order-setting 0.0.75-prod → 0.0.76

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 (29) hide show
  1. package/dist/{KioskDevicesView-B1dsUMwh.js → KioskDevicesView-H7stMDFu.js} +1 -1
  2. package/dist/{KioskDevicesView.vue_vue_type_script_setup_true_lang-BmCrSZnS.js → KioskDevicesView.vue_vue_type_script_setup_true_lang-DgpV4oKE.js} +3 -3
  3. package/dist/{KioskSettingView-DUUr39PJ.js → KioskSettingView-fF6k9s_q.js} +3 -3
  4. package/dist/KioskView-Cxcc1UL1.js +420 -0
  5. package/dist/{OrderSettingsView-AY0L3EfF.js → OrderSettingsView-Ds2L_rbu.js} +7717 -7871
  6. package/dist/{app-DzO7wZsC.js → app-BDlPjU4y.js} +9 -5
  7. package/dist/app.js +1 -1
  8. package/dist/{dayjs.min-BNHTbbaJ.js → dayjs.min-OJf1trOq.js} +1 -1
  9. package/dist/frontend/mf-order/src/app.d.ts +4 -0
  10. package/dist/frontend/mf-order/src/main.d.ts +4 -0
  11. package/dist/frontend/mf-order/src/views/order-settings/pickup/PickUpSetting.vue.d.ts +0 -17
  12. package/dist/frontend/mf-order/src/views/order-settings/pickup/PickUpSettingDialogContent.vue.d.ts +9 -0
  13. package/dist/frontend/mf-order/tsconfig.app.tsbuildinfo +1 -1
  14. package/dist/{index-DQA37h5T.js → index-Bid9lO2x.js} +2 -2
  15. package/dist/index-gGOpbnY3.js +23 -0
  16. package/dist/{lineman-settings.dto-BMG_DnTF.js → lineman-settings.dto-Cny_fF4n.js} +1 -1
  17. package/package.json +1 -1
  18. package/src/locales/en-US.json +1 -0
  19. package/src/locales/ja-JP.json +1 -0
  20. package/src/locales/th-TH.json +1 -0
  21. package/src/locales/zh-CN.json +1 -0
  22. package/src/views/order-settings/pickup/PickUpSetting.vue +124 -195
  23. package/src/views/order-settings/pickup/PickUpSettingDialogContent.vue +24 -1
  24. package/dist/KioskView-4_Kl607M.js +0 -362
  25. package/dist/frontend/mf-order/src/views/order-settings/pickup/PickUpSettingDialog.vue.d.ts +0 -16
  26. package/dist/frontend/mf-order/src/views/order-settings/pickup/PickupList.vue.d.ts +0 -16
  27. package/dist/index-BP0fOlVh.js +0 -86
  28. package/src/views/order-settings/pickup/PickUpSettingDialog.vue +0 -118
  29. package/src/views/order-settings/pickup/PickupList.vue +0 -49
@@ -1,362 +0,0 @@
1
- import { defineComponent as B, openBlock as P, createElementBlock as E, createElementVNode as m, toDisplayString as w, unref as d, ref as v, defineAsyncComponent as O, computed as x, onMounted as g, watch as S, resolveComponent as K, createVNode as T, createBlock as V, createCommentVNode as L } from "vue";
2
- import { u as k, _ as ee } from "./KioskDevicesView.vue_vue_type_script_setup_true_lang-BmCrSZnS.js";
3
- import { useDialog as ae, useSnackbar as te } from "@feedmepos/ui-library";
4
- import { useI18n as H, useCoreStore as ne } from "@feedmepos/mf-common";
5
- import { F as le, a as ue, S as M } from "./lineman-settings.dto-BMG_DnTF.js";
6
- import { defineStore as oe } from "pinia";
7
- import { O as N, c as re } from "./index-BP0fOlVh.js";
8
- import { u as ce } from "./app-DzO7wZsC.js";
9
- const se = { class: "flex flex-col gap-5 pb-6" }, pe = { class: "fm-typo-en-body-md-400 block" }, de = { class: "fm-typo-en-title-md-600" }, me = /* @__PURE__ */ B({
10
- __name: "KioskOtpDialog",
11
- props: {
12
- otp: {}
13
- },
14
- setup(e) {
15
- const { t: a } = H();
16
- return (u, c) => (P(), E("div", se, [
17
- m("span", pe, w(d(a)("order.bindDeviceMessage")), 1),
18
- m("div", de, w(e.otp), 1)
19
- ]));
20
- }
21
- }), W = {
22
- enabled: !1,
23
- prefix: null,
24
- padDigit: 0,
25
- standSlotRange: {
26
- min: 1,
27
- max: 10
28
- },
29
- enablePaxDialog: !1,
30
- submitOrderInstruction: {
31
- payAtCounter: null,
32
- paid: null
33
- }
34
- }, ie = {
35
- enabled: !1,
36
- submitOrderInstruction: {
37
- payAtCounter: null,
38
- paid: null
39
- }
40
- }, Q = {
41
- enabled: !1,
42
- submitOrderInstruction: {
43
- payAtCounter: null,
44
- paid: null
45
- },
46
- enablePaxDialog: !1
47
- }, ye = {
48
- dineIn: {
49
- enabled: !1,
50
- pickUp: Q,
51
- sequenceNumber: le.parse({}),
52
- displayStand: W
53
- },
54
- takeaway: ie,
55
- paymentSetting: {
56
- paymentTypes: [],
57
- offlinePaymentTypes: [],
58
- ePaymentTypes: {
59
- terminal: !1,
60
- card: {
61
- terminal: !1,
62
- nfc: !1
63
- },
64
- eWallet: {
65
- terminalQrPay: !1,
66
- terminalScanPay: !1,
67
- qrPay: !1,
68
- scanPay: !1
69
- }
70
- }
71
- },
72
- menuItem: {
73
- showAllOnly: !1
74
- },
75
- coverImageLandscape: null,
76
- coverImagePortrait: null,
77
- otaChannel: ""
78
- }, U = {
79
- payAtCounter: null,
80
- paid: null
81
- }, fe = (e) => {
82
- var a;
83
- return {
84
- kiosk: ve(e.kioskSettings, (a = e.sequenceSettings) == null ? void 0 : a.kioskDineIn)
85
- };
86
- }, ve = (e, a) => {
87
- var u, c, t, l, o, p, r, s, b, f, i;
88
- return {
89
- dineIn: be(
90
- a ?? {
91
- current: 0,
92
- prefix: "#K"
93
- },
94
- (e == null ? void 0 : e.dineIn) ?? void 0
95
- ),
96
- takeaway: {
97
- enabled: (e == null ? void 0 : e.canTakeaway) ?? !1,
98
- submitOrderInstruction: (u = e == null ? void 0 : e.takeaway) != null && u.submitOrderInstruction ? {
99
- payAtCounter: ((l = (t = (c = e == null ? void 0 : e.takeaway) == null ? void 0 : c.submitOrderInstruction) == null ? void 0 : t.payAtCounter) == null ? void 0 : l.en) ?? null,
100
- paid: ((r = (p = (o = e == null ? void 0 : e.takeaway) == null ? void 0 : o.submitOrderInstruction) == null ? void 0 : p.paid) == null ? void 0 : r.en) ?? null
101
- } : U
102
- },
103
- paymentSetting: {
104
- paymentTypes: ((s = e == null ? void 0 : e.paymentSetting) == null ? void 0 : s.paymentTypes) ?? [],
105
- offlinePaymentTypes: ((b = e == null ? void 0 : e.paymentSetting) == null ? void 0 : b.offlinePaymentTypes) ?? [],
106
- ePaymentTypes: ((f = e == null ? void 0 : e.paymentSetting) == null ? void 0 : f.ePaymentTypes) ?? ue.parse({
107
- card: {
108
- terminal: !1,
109
- nfc: !1
110
- },
111
- eWallet: {
112
- qrPay: !1,
113
- scanPay: !1
114
- }
115
- })
116
- },
117
- menuItem: {
118
- showAllOnly: ((i = e == null ? void 0 : e.menuItem) == null ? void 0 : i.showAllOnly) ?? !1
119
- },
120
- otaChannel: (e == null ? void 0 : e.otaChannel) ?? "",
121
- coverImageLandscape: (e == null ? void 0 : e.coverImageLandscape) ?? null,
122
- coverImagePortrait: (e == null ? void 0 : e.coverImagePortrait) ?? null
123
- };
124
- }, be = (e, a) => {
125
- var u, c, t, l, o, p, r, s;
126
- return {
127
- enabled: !!a,
128
- sequenceNumber: e,
129
- pickUp: a != null && a.pickUp ? {
130
- ...a.pickUp,
131
- submitOrderInstruction: a.pickUp.submitOrderInstruction ? {
132
- payAtCounter: ((c = (u = a.pickUp.submitOrderInstruction) == null ? void 0 : u.payAtCounter) == null ? void 0 : c.en) ?? null,
133
- paid: ((l = (t = a.pickUp.submitOrderInstruction) == null ? void 0 : t.paid) == null ? void 0 : l.en) ?? null
134
- } : U,
135
- enablePaxDialog: a.pickUp.enablePaxDialog ? a.pickUp.enablePaxDialog : !1
136
- } : Q,
137
- displayStand: a != null && a.displayStand ? {
138
- enabled: a.displayStand.enabled,
139
- standSlotRange: a.displayStand.standSlotRange,
140
- prefix: a.displayStand.prefix,
141
- padDigit: a.displayStand.padDigit,
142
- enablePaxDialog: a.displayStand.enablePaxDialog ?? !1,
143
- submitOrderInstruction: a.displayStand.submitOrderInstruction ? {
144
- payAtCounter: ((p = (o = a.displayStand.submitOrderInstruction) == null ? void 0 : o.payAtCounter) == null ? void 0 : p.en) ?? null,
145
- paid: ((s = (r = a.displayStand.submitOrderInstruction) == null ? void 0 : r.paid) == null ? void 0 : s.en) ?? null
146
- } : U
147
- } : W
148
- };
149
- }, _e = (e) => {
150
- const a = (t) => {
151
- var l, o, p, r;
152
- return {
153
- requiredSlot: !!t.displayStand,
154
- displayStand: {
155
- ...t.displayStand,
156
- submitOrderInstruction: {
157
- payAtCounter: (l = t.displayStand.submitOrderInstruction) != null && l.payAtCounter ? {
158
- en: t.displayStand.submitOrderInstruction.payAtCounter
159
- } : null,
160
- paid: (o = t.displayStand.submitOrderInstruction) != null && o.paid ? {
161
- en: t.displayStand.submitOrderInstruction.paid
162
- } : null
163
- }
164
- },
165
- pickUp: {
166
- ...t.pickUp,
167
- submitOrderInstruction: {
168
- payAtCounter: (p = t.pickUp.submitOrderInstruction) != null && p.payAtCounter ? {
169
- en: t.pickUp.submitOrderInstruction.payAtCounter
170
- } : null,
171
- paid: (r = t.pickUp.submitOrderInstruction) != null && r.paid ? {
172
- en: t.pickUp.submitOrderInstruction.paid
173
- } : null
174
- }
175
- }
176
- };
177
- }, u = (t) => ({
178
- canTakeaway: e.takeaway.enabled,
179
- dineIn: t,
180
- menuItem: e.menuItem,
181
- coverImageLandscape: e.coverImageLandscape,
182
- coverImagePortrait: e.coverImagePortrait,
183
- otaChannel: e.otaChannel || void 0,
184
- paymentSetting: c(e.paymentSetting),
185
- takeaway: e.takeaway.submitOrderInstruction ? {
186
- submitOrderInstruction: {
187
- payAtCounter: e.takeaway.submitOrderInstruction.payAtCounter ? {
188
- en: e.takeaway.submitOrderInstruction.payAtCounter
189
- } : null,
190
- paid: e.takeaway.submitOrderInstruction.paid ? {
191
- en: e.takeaway.submitOrderInstruction.paid
192
- } : null
193
- }
194
- } : void 0
195
- }), c = (t) => ({
196
- paymentTypes: t.paymentTypes,
197
- offlinePaymentTypes: t.offlinePaymentTypes,
198
- ePaymentTypes: t.ePaymentTypes
199
- });
200
- return e.dineIn.enabled ? {
201
- kioskSettings: u(a(e.dineIn)),
202
- kioskDineIn: e.dineIn.sequenceNumber
203
- } : {
204
- kioskSettings: u()
205
- };
206
- }, $ = {
207
- convertOrderSettingDto: fe,
208
- toOrderKioskSettingsDto: _e
209
- }, Pe = oe("orderSetting", () => {
210
- const e = v({});
211
- async function a() {
212
- const l = await N.getOrderSetting();
213
- c(l);
214
- }
215
- async function u() {
216
- if (e.value.orderSetting && e.value.kiosk) {
217
- const { _id: l, ...o } = e.value.orderSetting, p = $.toOrderKioskSettingsDto(e.value.kiosk), r = {
218
- ...o,
219
- kioskSettings: p.kioskSettings
220
- }, s = await N.updateOrderSetting(r);
221
- c(s);
222
- }
223
- }
224
- function c(l) {
225
- e.value.orderSetting = l, e.value.kiosk = $.convertOrderSettingDto(l).kiosk;
226
- }
227
- function t(l) {
228
- e.value.kiosk = l;
229
- }
230
- return {
231
- state: e.value,
232
- getSetting: a,
233
- updateKioskSetting: u,
234
- setKioskOrderSetting: t
235
- };
236
- }), we = { class: "py-[1.5rem]" }, Ce = { class: "px-[1.5rem]" }, Ie = { class: "pt-[1.5rem]" }, he = { class: "flex flex-col gap-10" }, Ae = { class: "flex flex-col gap-2" }, xe = { class: "fm-typo-en-title-sm-600" }, Ke = { class: "fm-typo-en-title-sm-400" }, Me = /* @__PURE__ */ B({
237
- __name: "KioskView",
238
- setup(e) {
239
- var R, D;
240
- const { t: a } = H(), { canManageOrderSetting: u } = ce(), c = O(
241
- () => import("./KioskSettingView-DUUr39PJ.js")
242
- ), t = v("device"), l = k(), o = Pe(), p = ae(), { currentRestaurant: r, restaurants: s, changeRestaurant: b } = ne(), f = te(), i = v(((R = r.value) == null ? void 0 : R._id) ?? void 0), C = v(null), j = x(() => s.value.map((n) => ({
243
- label: n.profile.name,
244
- value: n._id
245
- }))), _ = v(((D = r.value) == null ? void 0 : D._id) ?? "");
246
- async function F(n) {
247
- const y = s.value.find((h) => h._id == n);
248
- await b(y), await q(), i.value = n, _.value = n;
249
- }
250
- async function q() {
251
- if (u.value)
252
- try {
253
- await o.getSetting();
254
- } catch {
255
- }
256
- await I();
257
- }
258
- async function I() {
259
- C.value = null;
260
- try {
261
- await l.getDevices();
262
- } catch (n) {
263
- C.value = n instanceof M && n.status === 403 ? "forbidden" : "error";
264
- }
265
- }
266
- const z = x(() => {
267
- const n = [{ label: a("order.deviceBinding"), value: "device" }];
268
- return u.value && n.push({ label: a("order.settings"), value: "setting" }), n;
269
- }), G = x(() => l.state.devices);
270
- async function J() {
271
- try {
272
- await l.requestOtp();
273
- } catch (n) {
274
- f.open({
275
- title: n instanceof M && n.status === 403 ? a("order.bindDevicePermissionDenied") : a("order.bindDeviceFailed"),
276
- type: "error"
277
- });
278
- return;
279
- }
280
- p.open({
281
- title: re(a("order.bindDevice")),
282
- contentComponent: me,
283
- contentComponentProps: {
284
- otp: l.state.otp
285
- }
286
- }).onClose(async () => {
287
- await I();
288
- });
289
- }
290
- async function X(n) {
291
- try {
292
- o.setKioskOrderSetting(n), await o.updateKioskSetting(), f.open({
293
- title: a("order.kioskSettingSuccess"),
294
- type: "success"
295
- });
296
- } catch {
297
- f.open({
298
- title: a("order.kioskSettingFailed"),
299
- type: "error"
300
- });
301
- }
302
- }
303
- return g(async () => {
304
- var n;
305
- (n = r.value) != null && n._id && (_.value = r.value._id, await q());
306
- }), S(
307
- () => s.value.length,
308
- async (n) => {
309
- i.value === void 0 && s.value.length > 0 && await F(s.value[0]._id);
310
- },
311
- { immediate: !0 }
312
- ), (n, y) => {
313
- const h = K("FmPageHead"), Y = K("FmTabs"), Z = K("FmSelect");
314
- return P(), E("div", we, [
315
- T(h, {
316
- title: d(a)("order.kiosk")
317
- }, null, 8, ["title"]),
318
- m("div", Ce, [
319
- T(Y, {
320
- "model-value": t.value,
321
- "onUpdate:modelValue": y[0] || (y[0] = (A) => t.value = A),
322
- items: z.value
323
- }, null, 8, ["model-value", "items"]),
324
- m("div", Ie, [
325
- m("div", he, [
326
- m("div", Ae, [
327
- m("span", xe, w(d(a)("order.activateLocation")), 1),
328
- m("span", Ke, w(d(a)("order.selectRestaurant")) + ": ", 1),
329
- T(Z, {
330
- class: "w-1/2",
331
- modelValue: i.value,
332
- "onUpdate:modelValue": [
333
- y[1] || (y[1] = (A) => i.value = A),
334
- F
335
- ],
336
- items: j.value,
337
- placeholder: d(a)("order.selectItem")
338
- }, null, 8, ["modelValue", "items", "placeholder"])
339
- ]),
340
- t.value == "device" ? (P(), V(ee, {
341
- key: 0,
342
- devices: G.value,
343
- "load-error": C.value,
344
- onRequestOtp: J,
345
- onRetry: I
346
- }, null, 8, ["devices", "load-error"])) : L("", !0),
347
- t.value == "setting" && d(u) ? (P(), V(d(c), {
348
- key: `KioskSettingView-${_.value}`,
349
- "restaurant-id": _.value,
350
- onUpdateKioskOrderSetting: X,
351
- form: d(o).state.kiosk ?? d(ye)
352
- }, null, 8, ["restaurant-id", "form"])) : L("", !0)
353
- ])
354
- ])
355
- ])
356
- ]);
357
- };
358
- }
359
- });
360
- export {
361
- Me as default
362
- };
@@ -1,16 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
- showPickupDialog: {
3
- type: BooleanConstructor;
4
- required: true;
5
- };
6
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
- "close-side-sheet": (v?: boolean | undefined) => any;
8
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
- showPickupDialog: {
10
- type: BooleanConstructor;
11
- required: true;
12
- };
13
- }>> & Readonly<{
14
- "onClose-side-sheet"?: ((v?: boolean | undefined) => any) | undefined;
15
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
16
- export default _default;
@@ -1,16 +0,0 @@
1
- import { type PropType } from 'vue';
2
- import { type PickupSettingData } from './PickUpSetting.vue';
3
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
- pickupSettingData: {
5
- type: PropType<PickupSettingData[]>;
6
- };
7
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
8
- toggleSideSheet: (ev: any) => any;
9
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
10
- pickupSettingData: {
11
- type: PropType<PickupSettingData[]>;
12
- };
13
- }>> & Readonly<{
14
- onToggleSideSheet?: ((ev: any) => any) | undefined;
15
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
16
- export default _default;
@@ -1,86 +0,0 @@
1
- import { g as i, v as _, w as C, r as g } from "./lineman-settings.dto-BMG_DnTF.js";
2
- async function R() {
3
- const r = await g().get("/order-settings");
4
- return i(r);
5
- }
6
- async function p(r) {
7
- const e = await g().put("/order-settings", r);
8
- return i(e);
9
- }
10
- const U = {
11
- getOrderSetting: R,
12
- updateOrderSetting: p
13
- };
14
- async function w() {
15
- return i(await _().get(`balance/${C.getBusinessId()}`));
16
- }
17
- const y = {
18
- read: w
19
- }, A = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), S = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), m = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), I = /[^\p{L}\d]+/giu, f = "$1\0$2", d = "";
20
- function o(r) {
21
- let e = r.trim();
22
- e = e.replace(A, f).replace(S, f), e = e.replace(I, "\0");
23
- let t = 0, c = e.length;
24
- for (; e.charAt(t) === "\0"; )
25
- t++;
26
- if (t === c)
27
- return [];
28
- for (; e.charAt(c - 1) === "\0"; )
29
- c--;
30
- return e.slice(t, c).split(/\0/g);
31
- }
32
- function T(r) {
33
- const e = o(r);
34
- for (let t = 0; t < e.length; t++) {
35
- const c = e[t], s = m.exec(c);
36
- if (s) {
37
- const a = s.index + (s[1] ?? s[2]).length;
38
- e.splice(t, 1, c.slice(0, a), c.slice(a));
39
- }
40
- }
41
- return e;
42
- }
43
- function b(r, e) {
44
- const [t, c, s] = x(r, e), a = h(e == null ? void 0 : e.locale), n = L(e == null ? void 0 : e.locale);
45
- return t + c.map(E(a, n)).join(" ") + s;
46
- }
47
- function O(r, e) {
48
- const [t, c, s] = x(r, e), a = h(e == null ? void 0 : e.locale), n = L(e == null ? void 0 : e.locale), l = E(a, n);
49
- return t + c.map((u, P) => P === 0 ? l(u) : a(u)).join(" ") + s;
50
- }
51
- function h(r) {
52
- return (e) => e.toLocaleLowerCase(r);
53
- }
54
- function L(r) {
55
- return (e) => e.toLocaleUpperCase(r);
56
- }
57
- function E(r, e) {
58
- return (t) => `${e(t[0])}${r(t.slice(1))}`;
59
- }
60
- function x(r, e = {}) {
61
- const t = e.split ?? (e.separateNumbers ? T : o), c = e.prefixCharacters ?? d, s = e.suffixCharacters ?? d;
62
- let a = 0, n = r.length;
63
- for (; a < r.length; ) {
64
- const l = r.charAt(a);
65
- if (!c.includes(l))
66
- break;
67
- a++;
68
- }
69
- for (; n > a; ) {
70
- const l = n - 1, u = r.charAt(l);
71
- if (!s.includes(u))
72
- break;
73
- n = l;
74
- }
75
- return [
76
- r.slice(0, a),
77
- t(r.slice(a, n)),
78
- r.slice(n)
79
- ];
80
- }
81
- export {
82
- U as O,
83
- y as a,
84
- b as c,
85
- O as s
86
- };
@@ -1,118 +0,0 @@
1
- <template>
2
- <FmSideSheet :header="t('order.updatePickupSetting')" dismiss-away class="w-full fm-typo-en-title-md-600" :maxWidth="600"
3
- :model-value="props.showPickupDialog" @update:model-value="togglePickupDialog">
4
- <PickUpSettingDialogContent
5
- @update-pickup="updatePickupSetting"
6
- @update-order-settings="updateOrderPickupSettings"
7
- :pickup="pickupSetting"
8
- :order-pickup-settings="orderPickupSettings"
9
- />
10
- <template #side-sheet-footer>
11
- <div class="flex gap-8 items-center justify-start">
12
- <FmButton variant="primary" :label="t('order.apply')" size="lg" @click="onSave" />
13
- <FmButton variant="secondary" :label="t('order.cancel')" size="lg" @click="togglePickupDialog" />
14
- </div>
15
- </template>
16
- </FmSideSheet>
17
- </template>
18
-
19
- <script setup lang="ts">
20
- import PickUpSettingDialogContent from './PickUpSettingDialogContent.vue'
21
- import { MAX_PREORDER_DAYS } from './Preorder.vue'
22
- import { ref, watch } from 'vue'
23
- import { useCoreStore } from '@feedmepos/mf-common'
24
- import { useLoading } from '@/composables/loading'
25
- import { useRestaurantStore } from '@/stores/restaurant'
26
- import { useSnackbarFunctions } from '@/components/snackbar'
27
- import { F_ORDER_PAYMENT_TYPE, FdoRestaurantPickup } from '@feedmepos/core/entity'
28
- import { useI18n } from '@feedmepos/mf-common'
29
- import { OrderSettingApi } from '@/api/order-setting'
30
- import type { OrderPickupSettingsDto, OrderSettingsDto } from '@entity'
31
-
32
- const { t } = useI18n()
33
-
34
- const { currentRestaurant } = useCoreStore()
35
- const { startAsyncCallWithErr } = useLoading()
36
- const restaurantStore = useRestaurantStore()
37
- const { showSuccess, showError } = useSnackbarFunctions()
38
-
39
- const pickupSetting = ref<FdoRestaurantPickup>(initDefaultPickupSetting())
40
- // `orderSetting.pickupSettings` (bill auto-close / receipt-print) is a separate doc
41
- // from the restaurant-level pickup setting; loaded/saved alongside it here.
42
- const orderSetting = ref<OrderSettingsDto | undefined>(undefined)
43
- const orderPickupSettings = ref<OrderPickupSettingsDto>({})
44
- const props = defineProps({
45
- showPickupDialog: {
46
- type: Boolean,
47
- required: true
48
- }
49
- })
50
-
51
- function initDefaultPickupSetting(): FdoRestaurantPickup {
52
- return {
53
- offlinePaymentTypes: [],
54
- paymentTypes: [F_ORDER_PAYMENT_TYPE.enum.cash]
55
- }
56
- }
57
-
58
- const emits = defineEmits<{
59
- (event: 'close-side-sheet', v?: boolean): void
60
- }>()
61
-
62
- function togglePickupDialog(open: boolean) {
63
- if (!open) {
64
- emits('close-side-sheet')
65
- }
66
- }
67
-
68
- function updatePickupSetting(value: FdoRestaurantPickup) {
69
- pickupSetting.value = value
70
- }
71
-
72
- function updateOrderPickupSettings(value: OrderPickupSettingsDto) {
73
- orderPickupSettings.value = value
74
- }
75
-
76
- async function onSave() {
77
- const pickupTime = pickupSetting.value.pickupTime
78
- if (pickupTime) {
79
- const { min, max } = pickupTime.day
80
- if (max <= min || max - min > MAX_PREORDER_DAYS) {
81
- showError(t('order.preOrderMaxDaysError', { days: MAX_PREORDER_DAYS }))
82
- return
83
- }
84
- }
85
- await startAsyncCallWithErr(async () => {
86
- const id = currentRestaurant.value?._id ?? ''
87
- await restaurantStore.updatePickupSetting(pickupSetting.value)
88
- if (currentRestaurant.value) {
89
- currentRestaurant.value.pickup = pickupSetting.value
90
- }
91
- if (orderSetting.value) {
92
- orderSetting.value = await OrderSettingApi.updateOrderSetting({
93
- ...orderSetting.value,
94
- pickupSettings: orderPickupSettings.value
95
- })
96
- }
97
- showSuccess('Pickup setting updated. ')
98
- })
99
- await emits('close-side-sheet', true)
100
- await restaurantStore.readRestaurantSetting(currentRestaurant.value?._id || '')
101
- }
102
-
103
- watch(
104
- () => props.showPickupDialog,
105
- async (show) => {
106
- if (currentRestaurant.value) {
107
- pickupSetting.value = currentRestaurant.value.pickup ?? initDefaultPickupSetting()
108
- }
109
- if (show && currentRestaurant.value) {
110
- await startAsyncCallWithErr(async () => {
111
- const setting = await OrderSettingApi.getOrderSetting()
112
- orderSetting.value = setting
113
- orderPickupSettings.value = setting.pickupSettings ?? {}
114
- })
115
- }
116
- }
117
- )
118
- </script>
@@ -1,49 +0,0 @@
1
- <template>
2
- <ul class="list-none p-0">
3
- <div v-for="(data, index) in pickupSettingData" :key="index" class="my-3">
4
- <li class="ml-5" @click="() => toggleSideSheet(data)">
5
- <div class="flex items-center text-sm text-gray-500">
6
- <span>{{ data.pickuppoint }}</span>
7
- <span class="ml-2 px-2 py-0.5 rounded-full text-xs font-medium" :class="getClassForStatus(data.online)">
8
- {{ data.online }}
9
- </span>
10
- </div>
11
- <h3 class="text-lg font-semibold mb-1">{{ data.restaurant }}</h3>
12
- <p class="text-sm text-gray-500">Payment type: {{ data.paymentmethod || '-' }}</p>
13
- <p class="text-sm text-gray-500">Preorder: {{ data.preorder || '-' }}</p>
14
- </li>
15
- <div v-if="!!pickupSettingData && index !== pickupSettingData.length - 1" class="border-b border-gray-200 mt-3">
16
- </div>
17
- </div>
18
- </ul>
19
- </template>
20
-
21
- <script setup lang="ts">
22
- import { type PropType } from 'vue'
23
- import { type PickupSettingData } from './PickUpSetting.vue'
24
-
25
- const props = defineProps({
26
- pickupSettingData: {
27
- type: Array as PropType<PickupSettingData[]>
28
- }
29
- })
30
-
31
- const emits = defineEmits<{
32
- (event: 'toggleSideSheet', ev: any): void
33
- }>()
34
-
35
- function toggleSideSheet(data: any) {
36
- emits('toggleSideSheet', data)
37
- }
38
-
39
- const getClassForStatus = (enabled: string): string => {
40
- switch (enabled) {
41
- case 'Inactive':
42
- return ' bg-fm-color-system-info-100 fm-typo-en-body-md-600 border fm-corner-radius-lg w-max gap-8 p-4 text-fm-color-typo-info'
43
- case 'Activated':
44
- return ' bg-fm-color-system-success-100 fm-typo-en-body-md-600 border fm-corner-radius-lg w-max gap-8 p-4 text-fm-color-typo-success'
45
- default:
46
- return ''
47
- }
48
- }
49
- </script>