@feedmepos/mf-hrm-portal 1.1.0-dev → 1.1.1-dev

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 (96) hide show
  1. package/dist/AuditLogList-D62QRWN-.js +232 -0
  2. package/dist/{EmployeeList-tmUqs5a6.js → EmployeeList-CMUbRS7j.js} +156 -150
  3. package/dist/Main-BbZ-t-pu.js +85 -0
  4. package/dist/{main-DOtgCRZe.js → Main-un3v_g6p.js} +1500 -1532
  5. package/dist/{PageLayout.vue_vue_type_script_setup_true_lang-DuwNwJDM.js → PageLayout.vue_vue_type_script_setup_true_lang-HKK4cbW8.js} +2 -2
  6. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CZKBfM_R.js +3119 -0
  7. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +38 -0
  8. package/dist/{RoleList-C5xG7LHg.js → RoleList-mlTepnhN.js} +52 -50
  9. package/dist/RolePermissionList-tR-Kmlu7.js +285 -0
  10. package/dist/TeamMemberList-BkRQl6x8.js +948 -0
  11. package/dist/{TimesheetList-CZfo4Dua.js → TimesheetList-i5yaAzhB.js} +21 -21
  12. package/dist/api/audit-log/index.d.ts +10 -0
  13. package/dist/api/index.d.ts +1 -3
  14. package/dist/api/permission-assignment/index.d.ts +10 -0
  15. package/dist/api/permission-set/index.d.ts +8 -0
  16. package/dist/api/team/index.d.ts +2 -1
  17. package/dist/app-4LaGLcWC.js +2305 -0
  18. package/dist/app.js +1 -1
  19. package/dist/components/AppForm.vue.d.ts +3 -2
  20. package/dist/components/CheckboxInput.vue.d.ts +10 -4
  21. package/dist/components/CollapsibleWrapper.vue.d.ts +3 -2
  22. package/dist/components/form/SelectFilter.vue.d.ts +3 -2
  23. package/dist/components/layout/FormColumn.vue.d.ts +6 -3
  24. package/dist/components/layout/FormItem.vue.d.ts +2 -1
  25. package/dist/components/layout/FormSection.vue.d.ts +2 -1
  26. package/dist/components/layout/FullWrapper.vue.d.ts +6 -3
  27. package/dist/components/layout/PageLayout.vue.d.ts +2 -1
  28. package/dist/components/menu/BottomSheetMenu.vue.d.ts +2 -1
  29. package/dist/components/menu/BottomSheetMenuItem.vue.d.ts +6 -3
  30. package/dist/components/table/EmptyDataTemplate/index.vue.d.ts +6 -3
  31. package/dist/composables/useAppStore.d.ts +6 -6
  32. package/dist/composables/useDateRange.d.ts +1 -1
  33. package/dist/composables/useRestaurantMap.d.ts +4 -8
  34. package/dist/composables/useSheet.d.ts +1 -1
  35. package/dist/{employee-BQc7Wgpu.js → employee-BZTntAR0.js} +9 -9
  36. package/dist/helpers/permission-set.d.ts +32 -0
  37. package/dist/helpers/portal-user.d.ts +8 -0
  38. package/dist/helpers/rule.d.ts +4 -3
  39. package/dist/index-BsEM84j5.js +8440 -0
  40. package/dist/{empty-placeholder-ey8LJtN1.js → index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js} +43 -2
  41. package/dist/{lodash-DNzKT_gG.js → lodash-DYaYvsmp.js} +326 -343
  42. package/dist/router/shared.d.ts +3 -1
  43. package/dist/stores/employee.d.ts +4 -4
  44. package/dist/stores/permission-assignment.d.ts +277 -0
  45. package/dist/stores/permission-set.d.ts +250 -0
  46. package/dist/stores/role.d.ts +4 -4
  47. package/dist/stores/team.d.ts +288 -0
  48. package/dist/stores/timesheet.d.ts +19 -19
  49. package/dist/team-eo_yQh1g.js +26 -0
  50. package/dist/{timesheet-B4M1nCIm.js → timesheet-CfPIK52Q.js} +14 -15
  51. package/dist/tsconfig.app.tsbuildinfo +1 -1
  52. package/dist/types/audit-log.d.ts +18 -0
  53. package/dist/types/permission-assignment.d.ts +20 -0
  54. package/dist/types/permission-set.d.ts +20 -0
  55. package/dist/types/permission.d.ts +4 -3
  56. package/dist/types/team.d.ts +13 -3
  57. package/dist/useAppStore-D0F-tWJO.js +180 -0
  58. package/dist/useLoading-DpbOtToC.js +99 -0
  59. package/dist/useRestaurantMap-D5BNPLKh.js +107 -0
  60. package/dist/{useSearch-C25VELOk.js → useSearch-C6gRA62e.js} +8 -8
  61. package/dist/views/hr/employee/{components/EmployeeForm.vue.d.ts → EmployeeForm.vue.d.ts} +10 -7
  62. package/dist/views/hr/locales/index.d.ts +0 -214
  63. package/dist/views/team/components/BasePermission.vue.d.ts +76 -0
  64. package/dist/views/team/components/{TeamMemberConditionPermission.vue.d.ts → ConditionPermission.vue.d.ts} +14 -1
  65. package/dist/views/team/components/InheritPermissionTooltip.vue.d.ts +14 -0
  66. package/dist/views/team/components/PermissionWithTooltip.vue.d.ts +14 -0
  67. package/dist/views/team/components/PortalPermissionEditor.vue.d.ts +68 -28
  68. package/dist/views/team/components/{TeamMemberRolePermission.vue.d.ts → PosRolePermission.vue.d.ts} +14 -1
  69. package/dist/views/team/locales/index.d.ts +176 -4
  70. package/dist/views/team/{components → member}/AddMemberForm.vue.d.ts +1 -0
  71. package/dist/views/team/member/TeamMemberList.vue.d.ts +4 -0
  72. package/dist/views/team/member/TeamMemberMasterUser.vue.d.ts +55 -0
  73. package/dist/views/team/role/RolePermissionForm.vue.d.ts +19 -0
  74. package/dist/views/{hr/grant-user/GrantUserList.vue.d.ts → team/role/RolePermissionList.vue.d.ts} +0 -12
  75. package/package.json +14 -9
  76. package/dist/FormSection.vue_vue_type_script_setup_true_lang-BY9VGOoM.js +0 -71
  77. package/dist/HorizontalSplitter-B9DVYJIM.js +0 -12
  78. package/dist/Main-ebQsujY3.js +0 -600
  79. package/dist/TeamMemberList-09_3YTHe.js +0 -1509
  80. package/dist/api/grant-user/index.d.ts +0 -8
  81. package/dist/app-B4KDGOw1.js +0 -1432
  82. package/dist/index-CSG8t9Dl.js +0 -58
  83. package/dist/role-DGAu9X1X.js +0 -9728
  84. package/dist/rule-CSj0p2P3.js +0 -450
  85. package/dist/stores/grant-user.d.ts +0 -86
  86. package/dist/types/grant-user.d.ts +0 -17
  87. package/dist/useAppStore-CKmMR-gI.js +0 -93
  88. package/dist/useLoading-v4m-6mEy.js +0 -141
  89. package/dist/useRestaurantMap-e9fQJiLC.js +0 -39
  90. package/dist/views/hr/grant-user/components/GrantUserForm.vue.d.ts +0 -14
  91. package/dist/views/team/components/TeamMemberBasePermission.vue.d.ts +0 -36
  92. package/dist/views/team/components/TeamMemberMasterUser.vue.d.ts +0 -718
  93. /package/dist/views/hr/{grant-user/Main.vue.d.ts → Main.vue.d.ts} +0 -0
  94. /package/dist/views/hr/{main.vue.d.ts → audit-log/AuditLogList.vue.d.ts} +0 -0
  95. /package/dist/views/team/{TeamMemberList.vue.d.ts → Main.vue.d.ts} +0 -0
  96. /package/dist/views/team/{components → member}/MemberInfo.vue.d.ts +0 -0
@@ -1,1509 +0,0 @@
1
- import { defineComponent as z, ref as j, resolveComponent as M, openBlock as m, createBlock as I, withCtx as q, createElementVNode as u, renderSlot as Q, withModifiers as Re, createCommentVNode as O, nextTick as _e, createElementBlock as P, normalizeClass as oe, createTextVNode as xe, toDisplayString as A, computed as R, Fragment as ne, renderList as pe, createVNode as v, unref as d, useSlots as Ae, normalizeStyle as de, onMounted as Me, onUnmounted as Ie, watch as Ve, isRef as ye, createSlots as De } from "vue";
2
- import { useI18n as ee, Permission as G, useCoreStore as re, fullPermission as ce, baseClientInstance as Fe, RestaurantSelector as $e } from "@feedmepos/mf-common";
3
- import { useBreakpoints as Be, useSnackbar as we, useDialog as qe, components as Ee } from "@feedmepos/ui-library";
4
- import { u as je, _ as Le, S as Ue } from "./useSearch-C25VELOk.js";
5
- import { _ as Te } from "./app-B4KDGOw1.js";
6
- import { _ as ze } from "./PageLayout.vue_vue_type_script_setup_true_lang-DuwNwJDM.js";
7
- import { E as We } from "./empty-placeholder-ey8LJtN1.js";
8
- import { c as Z, g as ge, b as Ke, u as Oe } from "./role-DGAu9X1X.js";
9
- import { p as ue, t as me } from "./index-CSG8t9Dl.js";
10
- import { i as ke, g as Ge, u as Se } from "./rule-CSj0p2P3.js";
11
- const Je = /* @__PURE__ */ z({
12
- __name: "BottomSheetMenu",
13
- setup(t) {
14
- const l = j(!1);
15
- async function e() {
16
- await _e(), l.value = !l.value;
17
- }
18
- return (i, r) => {
19
- const n = M("FmButton"), k = M("FmBottomSheet");
20
- return m(), I(k, {
21
- modelValue: l.value,
22
- "onUpdate:modelValue": r[1] || (r[1] = ($) => l.value = $),
23
- "dismiss-away": "",
24
- "no-header": "",
25
- "z-index": 110
26
- }, {
27
- "bottom-sheet-button": q(() => [
28
- i.$slots.button ? O("", !0) : (m(), I(n, {
29
- key: 0,
30
- icon: "more_vert",
31
- variant: "tertiary",
32
- onClick: Re(e, ["stop"])
33
- })),
34
- Q(i.$slots, "button")
35
- ]),
36
- default: q(() => [
37
- u("div", {
38
- onClick: r[0] || (r[0] = ($) => l.value = !1)
39
- }, [
40
- Q(i.$slots, "default")
41
- ])
42
- ]),
43
- _: 3
44
- }, 8, ["modelValue"]);
45
- };
46
- }
47
- }), He = { class: "py-8 px-12 hover:bg-fm-color-neutral-gray-100" }, Ye = /* @__PURE__ */ z({
48
- __name: "BottomSheetMenuItem",
49
- props: {
50
- label: {},
51
- icon: {},
52
- disabled: { type: Boolean },
53
- itemClass: {}
54
- },
55
- setup(t) {
56
- const l = t;
57
- return (e, i) => {
58
- const r = M("FmIcon");
59
- return m(), P("div", He, [
60
- e.$slots.content ? O("", !0) : (m(), P("div", {
61
- key: 0,
62
- class: oe(["flex items-center", {
63
- "text-fm-color-typo-disabled": l.disabled,
64
- "cursor-pointer": !l.disabled,
65
- "cursor-not-allowed": l.disabled,
66
- [l.itemClass || ""]: l.itemClass && !l.disabled
67
- }])
68
- }, [
69
- t.icon ? (m(), I(r, {
70
- key: 0,
71
- name: t.icon
72
- }, null, 8, ["name"])) : O("", !0),
73
- xe(" " + A(t.label), 1)
74
- ], 2)),
75
- Q(e.$slots, "content")
76
- ]);
77
- };
78
- }
79
- }), Qe = /* @__PURE__ */ z({
80
- __name: "ResponsiveContextMenu",
81
- props: {
82
- items: {}
83
- },
84
- setup(t) {
85
- const l = Be(), e = R(() => l.breakpoints.value.xs);
86
- return (i, r) => {
87
- const n = M("FmButton"), k = M("FmMenuItem"), $ = M("FmMenu");
88
- return e.value ? (m(), I(Je, { key: 0 }, {
89
- default: q(() => [
90
- (m(!0), P(ne, null, pe(t.items, ({ icon: p, label: y, disabled: F, itemClass: s, onClick: _ }) => (m(), I(Ye, {
91
- key: y,
92
- icon: p,
93
- label: y,
94
- disabled: F,
95
- itemClass: s,
96
- onClick: () => {
97
- !F && (_ == null || _());
98
- }
99
- }, null, 8, ["icon", "label", "disabled", "itemClass", "onClick"]))), 128))
100
- ]),
101
- _: 1
102
- })) : (m(), I($, {
103
- key: 1,
104
- "stop-click-propagation": "",
105
- shift: !0
106
- }, {
107
- "menu-button": q(() => [
108
- v(n, {
109
- type: "button",
110
- variant: "tertiary",
111
- icon: "more_vert",
112
- "text-color": "neutral-gray-400",
113
- size: "md"
114
- })
115
- ]),
116
- default: q(() => [
117
- (m(!0), P(ne, null, pe(t.items, ({ label: p, disabled: y, itemClass: F, onClick: s }) => (m(), I(k, {
118
- key: p,
119
- disabled: y,
120
- label: p,
121
- onClick: () => {
122
- !y && (s == null || s());
123
- }
124
- }, {
125
- label: q(() => [
126
- u("span", {
127
- class: oe(y ? "text-fm-color-typo-disabled" : F)
128
- }, A(p), 3)
129
- ]),
130
- _: 2
131
- }, 1032, ["disabled", "label", "onClick"]))), 128))
132
- ]),
133
- _: 1
134
- }));
135
- };
136
- }
137
- });
138
- var ae = /* @__PURE__ */ ((t) => (t.Update = "Update", t.Remove = "Remove", t))(ae || {});
139
- const Xe = { class: "w-full flex flex-col gap-16" }, Ze = { class: "flex items-center gap-16" }, et = { class: "space-y-4 min-w-0 flex-1" }, tt = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, lt = { class: "fm-typo-en-body-lg-600 truncate" }, st = { class: "w-full flex gap-16 items-center" }, at = { class: "flex-1 flex flex-col gap-4 min-w-0" }, ot = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, nt = { class: "fm-typo-en-body-lg-600 truncate" }, rt = { class: "flex-1 flex flex-col gap-4 min-w-0" }, it = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, ut = { class: "fm-typo-en-body-lg-600 truncate" }, mt = /* @__PURE__ */ z({
140
- __name: "MemberInfo",
141
- props: {
142
- data: {}
143
- },
144
- setup(t) {
145
- const { t: l } = ee();
146
- return (e, i) => {
147
- const r = M("FmAvatar");
148
- return m(), P("div", Xe, [
149
- u("div", Ze, [
150
- v(r, {
151
- size: "xl",
152
- initials: t.data.name
153
- }, null, 8, ["initials"]),
154
- u("div", et, [
155
- u("p", tt, A(d(l)("team.memberForm.memberInfo.memberName")), 1),
156
- u("p", lt, A(t.data.name || "--"), 1)
157
- ])
158
- ]),
159
- u("div", st, [
160
- u("div", at, [
161
- u("p", ot, A(d(l)("team.memberForm.memberInfo.mobileNumber")), 1),
162
- u("p", nt, A(t.data.phoneNumber || "--"), 1)
163
- ]),
164
- u("div", rt, [
165
- u("p", it, A(d(l)("team.memberForm.memberInfo.emailAddress")), 1),
166
- u("p", ut, A(t.data.email || "--"), 1)
167
- ])
168
- ])
169
- ]);
170
- };
171
- }
172
- }), dt = { class: "space-y-16" }, ct = {
173
- key: 0,
174
- class: "flex fm-typo-en-title-sm-600"
175
- }, pt = {
176
- key: 0,
177
- class: "q-mr-xs text-red col"
178
- }, ft = { class: "form-input" }, vt = /* @__PURE__ */ z({
179
- __name: "AppForm",
180
- props: {
181
- title: {
182
- type: String,
183
- default: void 0
184
- },
185
- required: {
186
- type: [Boolean, String],
187
- default: !1
188
- },
189
- inline: {
190
- type: Boolean,
191
- default: !1
192
- }
193
- },
194
- setup(t) {
195
- const l = t;
196
- return (e, i) => (m(), P("div", dt, [
197
- Q(e.$slots, "top", {}, () => [
198
- l.title ? (m(), P("div", ct, [
199
- u("div", null, [
200
- l.required ? (m(), P("span", pt, "*")) : O("", !0),
201
- xe(A(l.title), 1)
202
- ]),
203
- Q(e.$slots, "title-right")
204
- ])) : O("", !0)
205
- ]),
206
- u("div", ft, [
207
- Q(e.$slots, "default")
208
- ])
209
- ]));
210
- }
211
- });
212
- function bt(t, l) {
213
- let e = "", i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
214
- const r = i.length;
215
- for (let n = 0; n < t; n++)
216
- e += i.charAt(Math.floor(Math.random() * r));
217
- return e;
218
- }
219
- const ht = { class: "col flex items-center" }, yt = {
220
- key: 1,
221
- class: "q-pa-sm form-error-message text-error"
222
- }, ie = /* @__PURE__ */ z({
223
- __name: "CheckboxInput",
224
- props: {
225
- options: {
226
- type: Array,
227
- required: !0
228
- },
229
- title: {
230
- type: String,
231
- required: !0
232
- },
233
- modelValue: {
234
- type: Array,
235
- required: !0
236
- },
237
- showAllToggle: {
238
- type: [Boolean, String],
239
- default: !0
240
- },
241
- includeDisabledOptionsWhenSelectAll: {
242
- type: Boolean,
243
- default: !1
244
- },
245
- disable: {
246
- type: Boolean,
247
- default: !1
248
- },
249
- min: {
250
- type: Number,
251
- default: 0
252
- },
253
- max: {
254
- type: Number,
255
- default: void 0
256
- },
257
- showIntermediate: {
258
- type: Boolean,
259
- default: !0
260
- },
261
- gutter: {
262
- type: Number,
263
- default: void 0
264
- },
265
- falsyShowSlot: {
266
- type: Boolean,
267
- default: !1
268
- },
269
- bottomSlotIndent: {
270
- type: String,
271
- default: "36px"
272
- },
273
- alignCenter: {
274
- type: Boolean,
275
- default: !0
276
- }
277
- },
278
- emits: ["update:model-value"],
279
- setup(t, { emit: l }) {
280
- const e = t, i = l, { t: r } = ee(), n = j(!1), k = Ae(), $ = R(() => e.modelValue.length < e.min ? `Min selection ${e.min}` : e.max !== void 0 && e.modelValue.length > e.max ? `Max selection ${e.max}` : !0), p = `checkbox-${bt(6)}`, y = R(() => $.value !== !0), F = R(
281
- () => e.modelValue.filter((V) => e.options.some((U) => U.value === V))
282
- ), s = R(
283
- () => typeof e.showAllToggle == "boolean" ? r("team.labels.all") : e.showAllToggle
284
- ), _ = R(() => e.options.length > 0 && e.options.length === F.value.length);
285
- function N() {
286
- const V = e.modelValue.filter((U) => !F.value.includes(U));
287
- if (_.value === !0)
288
- i("update:model-value", V);
289
- else {
290
- const U = e.includeDisabledOptionsWhenSelectAll ? e.options.map((C) => C.value) : e.options.filter((C) => !C.disabled).map((C) => C.value);
291
- i("update:model-value", [...V, ...U]);
292
- }
293
- }
294
- function B(V, U) {
295
- let C = Z(e.modelValue);
296
- U ? C.every((b) => b !== V) && C.push(V) : C = C.filter((b) => b !== V), i("update:model-value", C);
297
- }
298
- return (V, U) => {
299
- const C = M("FmCheckbox");
300
- return m(), I(vt, {
301
- id: p,
302
- title: t.title,
303
- required: !1
304
- }, {
305
- top: q(() => [
306
- Q(V.$slots, "top")
307
- ]),
308
- default: q(() => [
309
- e.showAllToggle ? (m(), I(C, {
310
- key: 0,
311
- "model-value": _.value,
312
- disabled: t.disable,
313
- label: s.value,
314
- style: de(`margin-bottom: ${e.gutter}px`),
315
- size: "sm",
316
- dense: "",
317
- value: s.value,
318
- "onUpdate:modelValue": N
319
- }, null, 8, ["model-value", "disabled", "label", "style", "value"])) : O("", !0),
320
- (m(!0), P(ne, null, pe(t.options, (b, c) => (m(), P("div", {
321
- key: b.value,
322
- style: de(`margin-bottom: ${c < t.options.length - 1 ? e.gutter : 0}px`),
323
- class: oe(c < t.options.length - 1 ? "q-mb-sm" : "")
324
- }, [
325
- u("div", {
326
- class: oe(["row justify-between", t.alignCenter ? "items-center" : "items-start"])
327
- }, [
328
- u("div", ht, [
329
- v(C, {
330
- "model-value": t.modelValue.includes(b.value),
331
- disabled: t.disable || b.disabled,
332
- size: "sm",
333
- label: b.label,
334
- value: b.label,
335
- "onUpdate:modelValue": (h) => B(b.value, h)
336
- }, null, 8, ["model-value", "disabled", "label", "value", "onUpdate:modelValue"])
337
- ]),
338
- d(k)[`checkbox-${b.key || b.value}-end`] && (t.modelValue.includes(b.value) || t.falsyShowSlot) ? (m(), P("div", {
339
- key: 0,
340
- class: oe([{ "q-checkbox disabled": t.disable || b.disabled }, "col"])
341
- }, [
342
- Q(V.$slots, `checkbox-${b.key || b.value}-end`, {
343
- option: b,
344
- value: t.modelValue.includes(b.value),
345
- disable: t.disable || b.disabled
346
- })
347
- ], 2)) : O("", !0)
348
- ], 2),
349
- d(k)[`checkbox-${b.key || b.value}-bottom`] && (t.modelValue.includes(b.value) || t.falsyShowSlot) ? (m(), P("div", {
350
- key: 0,
351
- class: oe(["q-mt-sm", { "q-checkbox disabled": t.disable || b.disabled }]),
352
- style: de(`margin-left: ${t.bottomSlotIndent}`)
353
- }, [
354
- Q(V.$slots, `checkbox-${b.key || b.value}-bottom`, {
355
- option: b,
356
- disable: t.disable || b.disabled,
357
- value: t.modelValue.includes(b.value)
358
- })
359
- ], 6)) : O("", !0)
360
- ], 6))), 128)),
361
- n.value && y.value ? (m(), P("div", yt, A($.value), 1)) : O("", !0)
362
- ]),
363
- _: 3
364
- }, 8, ["title"]);
365
- };
366
- }
367
- }), gt = { class: "flex flex-col gap-16" }, _t = /* @__PURE__ */ z({
368
- __name: "TeamMemberBasePermission",
369
- props: {
370
- modelValue: {
371
- type: Array,
372
- required: !0
373
- },
374
- disable: {
375
- type: Boolean,
376
- default: !1
377
- },
378
- excludedSubjects: {
379
- type: Array,
380
- required: !0
381
- }
382
- },
383
- emits: ["update:model-value"],
384
- setup(t, { emit: l }) {
385
- const e = t, i = l, { t: r } = ee(), n = R(() => ue.filter((s) => !e.excludedSubjects.includes(s.subject)).filter((s) => !ke.includes(s.subject)).map((s) => ({
386
- label: s.label,
387
- value: s.subject
388
- }))), k = R(() => ue.filter((s) => ke.includes(s.subject)).map((s) => ({
389
- label: s.label,
390
- value: s.subject
391
- }))), $ = R(() => e.modelValue.filter((s) => n.value.some((_) => _.value === s.subject)).map((s) => s.subject)), p = R(() => e.modelValue.filter((s) => k.value.some((_) => _.value === s.subject)).map((s) => s.subject));
392
- function y(s) {
393
- i("update:model-value", [
394
- // Keep non-general permissions unchanged
395
- ...e.modelValue.filter((_) => !n.value.some((N) => N.value === _.subject)),
396
- // Add selected general permissions
397
- ...ue.filter((_) => s.includes(_.subject))
398
- ]);
399
- }
400
- function F(s) {
401
- i("update:model-value", [
402
- // Keep non-inventory permissions unchanged
403
- ...e.modelValue.filter(
404
- (_) => !k.value.some((N) => N.value === _.subject)
405
- ),
406
- // Add selected inventory permissions
407
- ...ue.filter((_) => s.includes(_.subject))
408
- ]);
409
- }
410
- return (s, _) => (m(), P("div", gt, [
411
- v(ie, {
412
- "model-value": $.value,
413
- options: n.value,
414
- disable: t.disable,
415
- title: d(r)("team.memberForm.permissions.general"),
416
- "onUpdate:modelValue": y
417
- }, null, 8, ["model-value", "options", "disable", "title"]),
418
- k.value.length > 0 ? (m(), I(ie, {
419
- key: 0,
420
- "model-value": p.value,
421
- options: k.value,
422
- disable: t.disable,
423
- title: d(r)("team.memberForm.permissions.stock"),
424
- "onUpdate:modelValue": F
425
- }, null, 8, ["model-value", "options", "disable", "title"])) : O("", !0)
426
- ]));
427
- }
428
- }), xt = { class: "flex items-center" }, Vt = { class: "ml-auto" }, wt = /* @__PURE__ */ z({
429
- __name: "CollapsibleWrapper",
430
- props: {
431
- title: { default: "" },
432
- initiallyCollapsed: { type: Boolean, default: !1 }
433
- },
434
- setup(t) {
435
- const e = j(t.initiallyCollapsed), i = j(), r = j(0);
436
- let n;
437
- function k() {
438
- e.value = !e.value;
439
- }
440
- function $() {
441
- i.value && (r.value = i.value.scrollHeight);
442
- }
443
- return Me(async () => {
444
- await _e(), i.value && (n = new ResizeObserver(() => {
445
- $();
446
- }), n.observe(i.value));
447
- }), Ie(() => {
448
- n == null || n.disconnect();
449
- }), (p, y) => {
450
- const F = M("FmButton");
451
- return m(), P(ne, null, [
452
- u("div", { onClick: k }, [
453
- u("div", xt, [
454
- Q(p.$slots, "title"),
455
- u("div", Vt, [
456
- v(F, {
457
- icon: e.value ? "keyboard_arrow_down" : "keyboard_arrow_up",
458
- "text-color": "neutral-gray-400",
459
- variant: "tertiary",
460
- size: "md"
461
- }, null, 8, ["icon"])
462
- ])
463
- ])
464
- ]),
465
- u("div", {
466
- ref_key: "contentRef",
467
- ref: i,
468
- class: "transition-all duration-300 ease-in-out overflow-hidden",
469
- style: de({ maxHeight: e.value ? "0" : r.value + "px" })
470
- }, [
471
- Q(p.$slots, "default")
472
- ], 4)
473
- ], 64);
474
- };
475
- }
476
- }), Ft = { class: "fm-typo-en-title-sm-600" }, ve = "includedFuture", Ce = /* @__PURE__ */ z({
477
- __name: "TeamMemberConditionPermission",
478
- props: {
479
- modelValue: {
480
- type: Array,
481
- default: null
482
- },
483
- options: {
484
- type: Array,
485
- required: !0
486
- },
487
- disable: {
488
- type: Boolean,
489
- default: !1
490
- },
491
- context: {
492
- type: String,
493
- required: !0
494
- }
495
- },
496
- emits: ["update:model-value"],
497
- setup(t, { emit: l }) {
498
- const e = t, i = l, { t: r } = ee(), n = R(() => [
499
- {
500
- label: r("team.memberForm.permissions.includedFuture", { context: e.context }),
501
- value: ve,
502
- // Can only be selected if all other options are selected
503
- disable: !!e.modelValue && e.options.length > e.modelValue.length
504
- },
505
- ...e.options.filter(
506
- (y) => y.label.toLocaleLowerCase().includes(p.value.toLocaleLowerCase())
507
- )
508
- ]), k = R(() => e.modelValue ? e.modelValue : [ve, ...e.options.map((y) => y.value)]);
509
- function $(y) {
510
- const F = y.length === n.value.length;
511
- i("update:model-value", F ? null : y.filter((s) => s !== ve));
512
- }
513
- const p = j("");
514
- return (y, F) => {
515
- const s = M("fm-search");
516
- return m(), I(wt, null, {
517
- title: q(() => [
518
- u("p", Ft, A(d(r)("team.memberForm.permissions.manageable", { context: t.context })), 1)
519
- ]),
520
- default: q(() => [
521
- t.options.length > 1 ? (m(), I(s, {
522
- key: 0,
523
- modelValue: p.value,
524
- "onUpdate:modelValue": F[0] || (F[0] = (_) => p.value = _),
525
- class: "mt-16",
526
- placeholder: d(r)("team.memberForm.permissions.search", { context: t.context })
527
- }, null, 8, ["modelValue", "placeholder"])) : O("", !0),
528
- v(ie, {
529
- "model-value": k.value,
530
- options: n.value,
531
- "show-intermediate": !1,
532
- "show-all-toggle": !0,
533
- disable: t.disable,
534
- "include-disabled-options-when-select-all": !0,
535
- title: "",
536
- class: "mt-16",
537
- "onUpdate:modelValue": $
538
- }, null, 8, ["model-value", "options", "disable"])
539
- ]),
540
- _: 1
541
- });
542
- };
543
- }
544
- }), $t = { class: "flex flex-col gap-40" }, Ut = { class: "flex items-center" }, kt = { class: "flex-1 flex flex-col" }, St = { class: "fm-typo-en-title-sm-600" }, Ct = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Pt = { class: "flex flex-row gap-16" }, Rt = { class: "flex flex-col gap-8" }, Mt = { class: "fm-typo-en-body-lg-400" }, Bt = { class: "p-16 fm-corner-radius-lg border border-fm-color-neutral-gray-200" }, be = 4, jt = /* @__PURE__ */ z({
545
- __name: "TeamMemberMasterUser",
546
- props: {
547
- modelValue: {
548
- type: Object,
549
- default: void 0
550
- },
551
- fallbackName: {
552
- type: String,
553
- required: !0
554
- },
555
- fallbackPasscode: {
556
- type: String,
557
- default: void 0
558
- },
559
- restaurants: {
560
- type: Array,
561
- required: !0
562
- },
563
- roles: {
564
- type: Array,
565
- required: !0
566
- }
567
- },
568
- emits: ["update:model-value"],
569
- setup(t, { emit: l }) {
570
- const e = t, i = l, { t: r } = ee(), { searchKey: n, filter: k } = je(""), $ = j(!0), p = j([]), y = R(() => {
571
- const c = {};
572
- return e.roles.forEach((h) => {
573
- c[h.value] = h.label;
574
- }), c;
575
- }), F = R(() => {
576
- var h;
577
- const c = {};
578
- return (h = e.modelValue) == null || h.roles.forEach((E) => {
579
- c[E.restaurantId] = E.roleId;
580
- }), c;
581
- }), s = R(() => e.restaurants.filter((c) => k([c.profile.name, c.profile.code, N(c._id)])).map((c) => ({
582
- label: `${c.profile.code ? c.profile.code + "-" : ""}${c.profile.name}`,
583
- value: c._id,
584
- slot: `checkbox-${c._id}-bottom`,
585
- disable: e.roles.filter((h) => !h.disabled).length === 0,
586
- roleOptions: e.roles
587
- }))), _ = R(() => {
588
- const c = e.roles.find((h) => !h.disabled);
589
- return c ? c.value : null;
590
- });
591
- function N(c) {
592
- const h = F.value[c] ?? "";
593
- return y.value[h] || "";
594
- }
595
- function B(c) {
596
- c ? e.modelValue || i("update:model-value", {
597
- code: "",
598
- name: e.fallbackName,
599
- roles: [],
600
- passcode: e.fallbackPasscode || ""
601
- }) : i("update:model-value", void 0);
602
- }
603
- function V(c, h) {
604
- if (!e.modelValue || c === "passcode" && e.modelValue.passcode === h)
605
- return;
606
- const E = Z(e.modelValue);
607
- E[c] = h, i("update:model-value", E);
608
- }
609
- function U(c) {
610
- V(
611
- "roles",
612
- c.map((h) => {
613
- var Y, g, a;
614
- const E = (g = (Y = s.value.find((w) => w.value === h)) == null ? void 0 : Y.roleOptions.find((w) => !w.disabled)) == null ? void 0 : g.value, L = (a = e.modelValue) == null ? void 0 : a.roles.find((w) => w.restaurantId === h);
615
- return {
616
- restaurantId: h,
617
- roleId: (L == null ? void 0 : L.roleId) || E
618
- };
619
- })
620
- );
621
- }
622
- function C(c, h) {
623
- V("roles", [
624
- ...e.modelValue.roles.filter(
625
- (E) => E.restaurantId !== c
626
- ),
627
- {
628
- restaurantId: c,
629
- roleId: h
630
- }
631
- ]);
632
- }
633
- function b() {
634
- $.value && ($.value = !1, p.value = [], V("passcode", ""));
635
- }
636
- return Ve(
637
- () => {
638
- var c;
639
- return (c = e.modelValue) == null ? void 0 : c.passcode;
640
- },
641
- (c) => {
642
- c && c.length === be ? (p.value = c.split(""), $.value = !0) : (p.value = [], $.value = !1);
643
- },
644
- { immediate: !0 }
645
- ), (c, h) => {
646
- const E = M("FmSwitch"), L = M("FmTextField"), Y = M("FmPinField"), g = M("FmFormGroup"), a = M("FmSearch"), w = M("FmSelect");
647
- return m(), P("div", $t, [
648
- u("div", Ut, [
649
- u("div", kt, [
650
- u("div", St, A(d(r)("team.memberForm.masterUser.title")), 1),
651
- u("div", Ct, A(d(r)("team.memberForm.masterUser.sublabel")), 1)
652
- ]),
653
- u("div", null, [
654
- v(E, {
655
- "model-value": !!t.modelValue,
656
- value: "master-user",
657
- "onUpdate:modelValue": B
658
- }, null, 8, ["model-value"])
659
- ])
660
- ]),
661
- t.modelValue ? (m(), P(ne, { key: 0 }, [
662
- u("div", Pt, [
663
- v(L, {
664
- "model-value": t.modelValue.code,
665
- label: d(r)("team.memberForm.masterUser.code"),
666
- "onUpdate:modelValue": h[0] || (h[0] = (f) => V("code", f))
667
- }, null, 8, ["model-value", "label"]),
668
- v(L, {
669
- "model-value": t.modelValue.name,
670
- class: "w-full",
671
- label: d(r)("team.memberForm.masterUser.name"),
672
- rules: [(f) => !!f || d(r)("team.memberForm.masterUser.nameEmptyError")],
673
- "onUpdate:modelValue": h[1] || (h[1] = (f) => V("name", f))
674
- }, null, 8, ["model-value", "label", "rules"])
675
- ]),
676
- u("div", Rt, [
677
- u("div", Mt, A(d(r)("team.memberForm.masterUser.passcode")), 1),
678
- v(g, {
679
- modelValue: p.value,
680
- "onUpdate:modelValue": h[4] || (h[4] = (f) => p.value = f),
681
- rules: [
682
- (f) => (f == null ? void 0 : f.filter((S) => !!S).length) !== be ? d(r)("team.memberForm.masterUser.passcodeRequired") : !0
683
- ]
684
- }, {
685
- default: q(() => [
686
- (m(), I(Y, {
687
- key: `pin-field-${$.value}`,
688
- modelValue: p.value,
689
- "onUpdate:modelValue": h[2] || (h[2] = (f) => p.value = f),
690
- length: be,
691
- masked: $.value,
692
- onComplete: h[3] || (h[3] = (f) => V("passcode", f)),
693
- onFocus: b
694
- }, null, 8, ["modelValue", "masked"]))
695
- ]),
696
- _: 1
697
- }, 8, ["modelValue", "rules"])
698
- ]),
699
- u("div", Bt, [
700
- v(a, {
701
- modelValue: d(n),
702
- "onUpdate:modelValue": h[5] || (h[5] = (f) => ye(n) ? n.value = f : null),
703
- placeholder: d(r)("team.memberForm.role.placeholder"),
704
- class: "mb-16"
705
- }, null, 8, ["modelValue", "placeholder"]),
706
- v(ie, {
707
- "model-value": t.modelValue.roles.map((f) => f.restaurantId),
708
- options: s.value,
709
- min: 1,
710
- title: d(r)("team.memberForm.masterUser.role"),
711
- "onUpdate:modelValue": U
712
- }, De({ _: 2 }, [
713
- pe(s.value, (f) => ({
714
- name: f.slot,
715
- fn: q(() => {
716
- var S;
717
- return [
718
- u("div", null, [
719
- v(w, {
720
- "model-value": ((S = t.modelValue.roles.find((D) => D.restaurantId === f.value)) == null ? void 0 : S.roleId) || _.value,
721
- items: f.roleOptions,
722
- "onUpdate:modelValue": (D) => C(f.value, D)
723
- }, null, 8, ["model-value", "items", "onUpdate:modelValue"])
724
- ])
725
- ];
726
- })
727
- }))
728
- ]), 1032, ["model-value", "options", "title"])
729
- ])
730
- ], 64)) : O("", !0)
731
- ]);
732
- };
733
- }
734
- }), he = "includedNewRole", Ot = /* @__PURE__ */ z({
735
- __name: "TeamMemberRolePermission",
736
- props: {
737
- modelValue: {
738
- type: Array,
739
- default: null
740
- },
741
- roles: {
742
- type: Array,
743
- required: !0
744
- },
745
- restaurantIds: {
746
- type: Array,
747
- default: null
748
- },
749
- disable: {
750
- type: Boolean,
751
- default: !1
752
- }
753
- },
754
- emits: ["update:model-value"],
755
- setup(t, { emit: l }) {
756
- const e = t, i = l, { t: r } = ee(), n = R(() => {
757
- const p = e.restaurantIds;
758
- return [
759
- {
760
- label: r("team.memberForm.permissions.includedNewRole"),
761
- value: he,
762
- disable: !!e.modelValue && e.roles.length > e.modelValue.length
763
- },
764
- ...e.roles.map((y) => ({
765
- label: y.name,
766
- value: y._id,
767
- disable: !!p && y.restaurants.every(({ id: F }) => !p.includes(F))
768
- }))
769
- ];
770
- }), k = R(() => e.modelValue ? e.modelValue : [he, ...e.roles.map((p) => p._id)]);
771
- function $(p) {
772
- const y = p.length === n.value.length;
773
- i("update:model-value", y ? null : p.filter((F) => F !== he));
774
- }
775
- return (p, y) => (m(), I(ie, {
776
- "model-value": k.value,
777
- options: n.value,
778
- "show-intermediate": !1,
779
- "show-all-toggle": !1,
780
- disable: t.disable,
781
- title: d(r)("team.memberForm.permissions.roles"),
782
- "onUpdate:modelValue": $
783
- }, null, 8, ["model-value", "options", "disable", "title"]));
784
- }
785
- }), Nt = {
786
- async readWarehouses() {
787
- return ge(await Ke().get("/warehouses"));
788
- }
789
- }, At = { class: "flex flex-col gap-40" }, It = {
790
- key: 0,
791
- class: "p-16 fm-corner-radius-lg border border-fm-color-neutral-gray-200"
792
- }, Dt = {
793
- key: 1,
794
- class: "p-16 fm-corner-radius-lg border border-fm-color-neutral-gray-200"
795
- }, qt = {
796
- key: 2,
797
- class: "p-16 fm-corner-radius-lg border border-fm-color-neutral-gray-200"
798
- }, Et = {
799
- key: 3,
800
- class: "p-16 fm-corner-radius-lg border border-fm-color-neutral-gray-200"
801
- }, Lt = /* @__PURE__ */ z({
802
- __name: "PortalPermissionEditor",
803
- props: {
804
- initialValue: {
805
- type: Object,
806
- default: void 0
807
- },
808
- username: {
809
- type: String,
810
- required: !0
811
- },
812
- disable: {
813
- type: Boolean,
814
- default: !1
815
- },
816
- isOwner: {
817
- type: Boolean,
818
- default: !1
819
- }
820
- },
821
- emits: ["permissionChanged"],
822
- setup(t, { emit: l }) {
823
- const e = t, i = l, { t: r } = ee(), n = j({
824
- permissions: []
825
- }), k = [
826
- G.Subject.Business.restaurant,
827
- G.Subject.Business.role,
828
- G.Subject.Business.stock,
829
- G.Subject.Restaurant.restaurant
830
- ], $ = R(() => {
831
- var a;
832
- const g = (a = n.value) == null ? void 0 : a.permissions.find(
833
- (w) => w.subject === G.Subject.Business.stock
834
- );
835
- return g ? g.conditions ? JSON.parse(g.conditions).warehouseId.$in : null : [];
836
- }), p = j([]);
837
- Me(async () => {
838
- e.initialValue && (n.value = e.initialValue), p.value = await Nt.readWarehouses();
839
- });
840
- function y(g) {
841
- const a = F(n.value.permissions, g);
842
- n.value = {
843
- ...n.value,
844
- permissions: a,
845
- posUser: h(n.value.posUser, a)
846
- };
847
- }
848
- function F(g, a) {
849
- let w = Z(
850
- g.filter((f) => f.subject !== G.Subject.Business.stock)
851
- );
852
- if (!a || a.length > 0) {
853
- const f = {
854
- actions: [G.Action.manage],
855
- subject: G.Subject.Business.stock
856
- };
857
- a && (f.conditions = JSON.stringify({ warehouseId: { $in: a } })), w.push(f);
858
- }
859
- return w;
860
- }
861
- const { restaurants: s } = re(), _ = Oe().roles, N = R(() => s.value.reduce((g, a) => (g[a._id] = _.value.filter((w) => w.restaurants.some((f) => f.id === a._id)).map((w) => w._id), g), {})), B = R(() => Ge(n.value.permissions));
862
- function V(g) {
863
- const a = C(n.value.permissions, g);
864
- n.value = {
865
- ...n.value,
866
- permissions: a,
867
- posUser: h(n.value.posUser, a)
868
- };
869
- }
870
- const U = R(() => Se(n.value.permissions));
871
- function C(g, a) {
872
- var S;
873
- let w = Z(
874
- g.filter(
875
- (D) => D.subject !== G.Subject.Business.restaurant && D.subject !== G.Subject.Restaurant.restaurant
876
- )
877
- );
878
- if (!a || a.length > 0) {
879
- w.push(ce.restaurant);
880
- const D = {
881
- actions: [G.Action.manage],
882
- subject: G.Subject.Restaurant.restaurant
883
- };
884
- a && (D.conditions = JSON.stringify({ restaurantId: { $in: a } })), w.push(D);
885
- }
886
- if (a) {
887
- const D = [
888
- ...new Set(a.map((W) => N.value[W]).flatMap((W) => W))
889
- ], te = _.value.map((W) => W._id);
890
- D.length !== te.length && (w = f(
891
- w,
892
- (S = U.value || te) == null ? void 0 : S.filter((W) => D.includes(W))
893
- ));
894
- }
895
- function f(D, te) {
896
- let W = Z(
897
- D.filter((fe) => fe.subject !== G.Subject.Business.role)
898
- );
899
- const se = Z(ce.role);
900
- return te && (se.conditions = JSON.stringify({ roleId: { $in: te } })), W.push(se), W;
901
- }
902
- return w;
903
- }
904
- function b(g) {
905
- const a = c(n.value.permissions, g);
906
- n.value = {
907
- ...n.value,
908
- permissions: a,
909
- posUser: h(n.value.posUser, a)
910
- };
911
- }
912
- function c(g, a) {
913
- let w = Z(
914
- g.filter((S) => S.subject !== G.Subject.Business.role)
915
- );
916
- const f = Z(ce.role);
917
- return a && (f.conditions = JSON.stringify({ roleId: { $in: a } })), w.push(f), w;
918
- }
919
- function h(g, a) {
920
- if (!g) return;
921
- const w = Se(a);
922
- if (!w) return g;
923
- const f = Z(g);
924
- return f.roles = f.roles.reduce((S, D) => (w.includes(D.roleId) && S.push(D), S), []), f;
925
- }
926
- const E = R(() => {
927
- const g = U.value;
928
- return _.value.map((a) => ({
929
- label: a.name,
930
- value: a._id,
931
- disabled: !!g && !g.includes(a._id)
932
- }));
933
- }), L = j();
934
- async function Y() {
935
- await _e(), L.value && L.value.$el.scrollIntoView({ behavior: "smooth", block: "start" });
936
- }
937
- return Ve(
938
- n,
939
- (g) => {
940
- i("permissionChanged", g);
941
- },
942
- { deep: !0 }
943
- ), (g, a) => {
944
- var w, f;
945
- return m(), P("div", At, [
946
- t.isOwner ? O("", !0) : (m(), P("div", It, [
947
- v(_t, {
948
- modelValue: n.value.permissions,
949
- "onUpdate:modelValue": a[0] || (a[0] = (S) => n.value.permissions = S),
950
- disable: t.isOwner,
951
- "excluded-subjects": k
952
- }, null, 8, ["modelValue", "disable"])
953
- ])),
954
- t.isOwner ? O("", !0) : (m(), P("div", Dt, [
955
- v(Ce, {
956
- "model-value": $.value,
957
- options: p.value.map((S) => ({
958
- label: S.profile.name,
959
- value: S._id
960
- })),
961
- context: d(r)("team.labels.warehouse"),
962
- "onUpdate:modelValue": y
963
- }, null, 8, ["model-value", "options", "context"])
964
- ])),
965
- t.isOwner ? O("", !0) : (m(), P("div", qt, [
966
- v(Ce, {
967
- "model-value": B.value,
968
- options: d(s).map((S) => ({
969
- label: `${S.profile.code ? S.profile.code + "-" : ""}${S.profile.name}`,
970
- value: S._id
971
- })),
972
- context: d(r)("team.labels.restaurant"),
973
- "onUpdate:modelValue": V
974
- }, null, 8, ["model-value", "options", "context"])
975
- ])),
976
- t.isOwner ? O("", !0) : (m(), P("div", Et, [
977
- v(Ot, {
978
- roles: d(_),
979
- "model-value": U.value,
980
- "restaurant-ids": B.value,
981
- "onUpdate:modelValue": b
982
- }, null, 8, ["roles", "model-value", "restaurant-ids"])
983
- ])),
984
- u("div", null, [
985
- v(jt, {
986
- ref_key: "masterUserContentRef",
987
- ref: L,
988
- modelValue: n.value.posUser,
989
- "onUpdate:modelValue": [
990
- a[1] || (a[1] = (S) => n.value.posUser = S),
991
- Y
992
- ],
993
- "fallback-name": t.username,
994
- "fallback-passcode": (f = (w = t.initialValue) == null ? void 0 : w.posUser) == null ? void 0 : f.passcode,
995
- restaurants: d(s),
996
- roles: E.value
997
- }, null, 8, ["modelValue", "fallback-name", "fallback-passcode", "restaurants", "roles"])
998
- ])
999
- ]);
1000
- };
1001
- }
1002
- }), Pe = {
1003
- async readPermissionUserByPhoneNo(t) {
1004
- var e;
1005
- const { currentBusiness: l } = re();
1006
- return ge(
1007
- await Fe("/").get(`/user/b/${(e = l.value) == null ? void 0 : e._id}/phone/${t}`)
1008
- );
1009
- },
1010
- async readPermissionUserByEmail(t) {
1011
- var e;
1012
- const { currentBusiness: l } = re();
1013
- return ge(
1014
- await Fe("/").get(`/user/b/${(e = l.value) == null ? void 0 : e._id}/email/${t}`)
1015
- );
1016
- }
1017
- }, Tt = { class: "flex flex-col gap-24 w-full" }, zt = {
1018
- key: 0,
1019
- class: "flex flex-col gap-8"
1020
- }, Wt = { class: "user-info-icon user-info-icon--lg" }, Kt = { class: "flex-1 overflow-hidden" }, Gt = { class: "profile-displayName" }, Jt = { class: "profile-email" }, Ht = { class: "profile-phone" }, Yt = { key: 2 }, Qt = /* @__PURE__ */ z({
1021
- __name: "PortalUserSearcher",
1022
- emits: ["invite"],
1023
- setup(t, { emit: l }) {
1024
- const e = l, { t: i } = ee(), r = we(), n = re(), k = j("phone"), $ = j(""), p = j(""), y = j();
1025
- async function F() {
1026
- if (!$.value && !p.value) {
1027
- r.open({
1028
- type: "error",
1029
- title: i("team.memberForm.searchUser.emptyError")
1030
- });
1031
- return;
1032
- }
1033
- const V = k.value === "phone" ? await Pe.readPermissionUserByPhoneNo($.value.replace(/ /g, "")) : await Pe.readPermissionUserByEmail(p.value);
1034
- V || r.open({
1035
- type: "error",
1036
- title: i("team.memberForm.searchUser.userNotFound")
1037
- }), y.value = V;
1038
- }
1039
- const s = R(() => {
1040
- var b;
1041
- let V = ((b = y.value) == null ? void 0 : b.displayName) ?? "";
1042
- V || (V = "Feed Me");
1043
- const [U, C] = V.split(" ");
1044
- return C ? `${U[0]}${C[0]}` : U.slice(0, 2);
1045
- }), _ = j(!1);
1046
- function N(V) {
1047
- e("invite", V), _.value = !0;
1048
- }
1049
- function B() {
1050
- _.value = !1;
1051
- }
1052
- return (V, U) => {
1053
- var L, Y, g;
1054
- const C = M("FmRadio"), b = M("FmPhoneNumber"), c = M("FmTextField"), h = M("FmRadioGroup"), E = M("FmButton");
1055
- return m(), P("div", Tt, [
1056
- _.value ? O("", !0) : (m(), P("div", zt, [
1057
- v(h, {
1058
- modelValue: k.value,
1059
- "onUpdate:modelValue": U[2] || (U[2] = (a) => k.value = a)
1060
- }, {
1061
- default: q(() => [
1062
- v(C, {
1063
- value: "phone",
1064
- label: d(i)("team.memberForm.searchUser.phoneNumber")
1065
- }, null, 8, ["label"]),
1066
- k.value === "phone" ? (m(), I(b, {
1067
- key: 0,
1068
- modelValue: $.value,
1069
- "onUpdate:modelValue": U[0] || (U[0] = (a) => $.value = a),
1070
- "extra-country-codes": d(n).enabledCountries.value,
1071
- class: "ml-8"
1072
- }, null, 8, ["modelValue", "extra-country-codes"])) : O("", !0),
1073
- v(C, {
1074
- value: "email",
1075
- label: d(i)("team.memberForm.searchUser.email")
1076
- }, null, 8, ["label"]),
1077
- k.value === "email" ? (m(), I(c, {
1078
- key: 1,
1079
- modelValue: p.value,
1080
- "onUpdate:modelValue": U[1] || (U[1] = (a) => p.value = a),
1081
- placeholder: d(i)("team.memberForm.searchUser.emailPlaceholder"),
1082
- class: "ml-8"
1083
- }, null, 8, ["modelValue", "placeholder"])) : O("", !0)
1084
- ]),
1085
- _: 1
1086
- }, 8, ["modelValue"]),
1087
- v(E, {
1088
- label: d(i)("team.memberForm.searchUser.search"),
1089
- variant: "secondary",
1090
- onClick: F
1091
- }, null, 8, ["label"])
1092
- ])),
1093
- y.value ? (m(), P("div", {
1094
- key: 1,
1095
- class: "profile-menu--profile cursor-pointer hover:bg-fm-color-opacity-sm",
1096
- onClick: U[3] || (U[3] = (a) => N(y.value))
1097
- }, [
1098
- u("div", Wt, A(s.value), 1),
1099
- u("div", Kt, [
1100
- u("p", Gt, A((L = y.value) == null ? void 0 : L.displayName), 1),
1101
- u("p", Jt, A((Y = y.value) == null ? void 0 : Y.email), 1),
1102
- u("p", Ht, A((g = y.value) == null ? void 0 : g.phoneNumber), 1)
1103
- ])
1104
- ])) : O("", !0),
1105
- _.value ? (m(), P("div", Yt, [
1106
- v(E, {
1107
- label: d(i)("team.memberForm.searchUser.changeUser"),
1108
- variant: "secondary",
1109
- onClick: B
1110
- }, null, 8, ["label"])
1111
- ])) : O("", !0)
1112
- ]);
1113
- };
1114
- }
1115
- }), Xt = /* @__PURE__ */ Le(Qt, [["__scopeId", "data-v-c2c7ed35"]]), Zt = { class: "flex w-full pb-24" }, el = /* @__PURE__ */ z({
1116
- __name: "AddMemberForm",
1117
- props: {
1118
- initialValue: {
1119
- type: Object
1120
- },
1121
- roleErrorMessage: {
1122
- type: String,
1123
- default: ""
1124
- }
1125
- },
1126
- setup(t, { expose: l }) {
1127
- const e = t, i = j(), r = j({
1128
- permissions: []
1129
- });
1130
- function n(F) {
1131
- i.value = F;
1132
- }
1133
- function k(F) {
1134
- r.value = { ...r.value, ...F };
1135
- }
1136
- function $() {
1137
- var F, s, _, N, B, V, U, C;
1138
- return {
1139
- email: ((F = i.value) == null ? void 0 : F.email) ?? void 0,
1140
- phoneNumber: ((s = i.value) == null ? void 0 : s.phoneNumber) ?? void 0,
1141
- permissions: r.value.permissions,
1142
- posUser: r.value.posUser ? {
1143
- ...r.value.posUser,
1144
- name: r.value.posUser.name || ((N = (_ = e.initialValue) == null ? void 0 : _.posUser) == null ? void 0 : N.name) || ((B = e.initialValue) == null ? void 0 : B.name) || ((V = i.value) == null ? void 0 : V.displayName) || "",
1145
- code: r.value.posUser.code || ((C = (U = e.initialValue) == null ? void 0 : U.posUser) == null ? void 0 : C.code) || "",
1146
- passcode: r.value.posUser.passcode,
1147
- roles: r.value.posUser.roles.filter((b) => !!b.roleId)
1148
- } : void 0
1149
- };
1150
- }
1151
- const p = j();
1152
- async function y() {
1153
- return (await p.value.validateInputsWithoutSubmit()).length ? null : $();
1154
- }
1155
- return l({
1156
- readFormData: $,
1157
- validate: y
1158
- }), (F, s) => {
1159
- const _ = M("FmForm");
1160
- return m(), I(_, {
1161
- ref_key: "formRef",
1162
- ref: p,
1163
- class: "mx-4 flex flex-col"
1164
- }, {
1165
- default: q(() => {
1166
- var N, B, V;
1167
- return [
1168
- u("div", Zt, [
1169
- e.initialValue ? (m(), I(mt, {
1170
- key: 1,
1171
- data: e.initialValue
1172
- }, null, 8, ["data"])) : (m(), I(Xt, {
1173
- key: 0,
1174
- onInvite: s[0] || (s[0] = (U) => n(U))
1175
- }))
1176
- ]),
1177
- i.value || t.initialValue ? (m(), I(Lt, {
1178
- key: 0,
1179
- username: ((N = t.initialValue) == null ? void 0 : N.name) || ((B = i.value) == null ? void 0 : B.displayName) || "",
1180
- initialValue: t.initialValue,
1181
- isOwner: (V = t.initialValue) == null ? void 0 : V.isOwner,
1182
- onPermissionChanged: s[1] || (s[1] = (U) => k(U))
1183
- }, null, 8, ["username", "initialValue", "isOwner"])) : O("", !0)
1184
- ];
1185
- }),
1186
- _: 1
1187
- }, 512);
1188
- };
1189
- }
1190
- });
1191
- function tl() {
1192
- const t = we();
1193
- function l(i) {
1194
- t.open({ title: i, type: "success" });
1195
- }
1196
- function e(i) {
1197
- t.open({ title: i, type: "error" });
1198
- }
1199
- return {
1200
- success: l,
1201
- error: e
1202
- };
1203
- }
1204
- const ll = {
1205
- class: "space-y-24"
1206
- }, sl = {
1207
- class: "space-y-8"
1208
- }, al = {
1209
- class: "xs:hidden flex w-full items-start justify-between px-16"
1210
- }, ol = {
1211
- class: "flex items-start gap-8"
1212
- }, nl = {
1213
- class: "space-y-4 hidden xs:block px-16"
1214
- }, rl = {
1215
- class: "flex items-start gap-8"
1216
- }, il = {
1217
- key: 0
1218
- }, ul = {
1219
- key: 1,
1220
- class: "bg-fm-color-neutral-white shadow-light-300 flex max-h-dvh items-center justify-center gap-24 self-stretch p-24"
1221
- }, ml = {
1222
- class: "flex flex-col items-center justify-center gap-16"
1223
- }, dl = ["src"], cl = {
1224
- class: "fm-typo-title-sm-700"
1225
- }, pl = {
1226
- class: "fm-typo-body-md-400 text-center text-gray-500"
1227
- }, fl = {
1228
- class: "flex items-center justify-start gap-8"
1229
- };
1230
- var H = /* @__PURE__ */ function(t) {
1231
- return t[t.ADD = 0] = "ADD", t[t.UPDATE = 1] = "UPDATE", t[t.CLOSED = 2] = "CLOSED", t;
1232
- }(H || {});
1233
- const $l = /* @__PURE__ */ z({
1234
- __name: "TeamMemberList",
1235
- setup(t) {
1236
- const {
1237
- t: l
1238
- } = ee(), e = re(), i = Oe(), {
1239
- success: r,
1240
- error: n
1241
- } = tl(), k = ({
1242
- member: o,
1243
- className: x = ""
1244
- }) => {
1245
- const K = {
1246
- label: l("common.update"),
1247
- onClick: () => s(ae.Update, o)
1248
- }, J = {
1249
- label: l("common.remove"),
1250
- onClick: () => s(ae.Remove, o),
1251
- itemClass: "text-fm-color-typo-error"
1252
- }, X = o.doc.isOwner ? [K] : [K, J];
1253
- return v(Qe, {
1254
- class: x,
1255
- items: X
1256
- }, null);
1257
- }, $ = (o) => o.doc.isOwner ? l("team.labels.businessOwner") : o.restaurants.join(", "), p = [{
1258
- accessorKey: "name",
1259
- header: () => l("team.table.columns.name"),
1260
- enableSorting: !1
1261
- }, {
1262
- accessorKey: "phoneNumber",
1263
- header: () => l("team.table.columns.phoneNumber"),
1264
- enableSorting: !1
1265
- }, {
1266
- accessorKey: "restaurant",
1267
- header: () => l("team.table.columns.restaurant"),
1268
- enableSorting: !1,
1269
- cell(o) {
1270
- const x = o.row.original;
1271
- return $(x);
1272
- }
1273
- }, {
1274
- accessorKey: "permission",
1275
- header: () => l("team.table.columns.permission"),
1276
- enableSorting: !1,
1277
- cell(o) {
1278
- const x = o.row.original;
1279
- return y(x);
1280
- },
1281
- meta: {
1282
- width: "200px"
1283
- }
1284
- }, {
1285
- id: "action",
1286
- meta: {
1287
- cellClass: "pl-16",
1288
- headerContentClass: "-mx-16"
1289
- },
1290
- cell(o) {
1291
- const x = o.row.original;
1292
- return k({
1293
- member: x,
1294
- className: "flex justify-end w-full"
1295
- });
1296
- },
1297
- enableSorting: !1
1298
- }];
1299
- function y(o) {
1300
- return o.doc.isOwner ? l("team.labels.businessOwner") : v("div", {
1301
- class: "flex flex-row items-center gap-8"
1302
- }, [v("span", null, [l("team.labels.allowed", {
1303
- count: o.permissions.length
1304
- })]), v(Ee.FmTooltip, {
1305
- variant: "plain",
1306
- placement: "top"
1307
- }, {
1308
- default: () => v(M("componentsFmIcon"), {
1309
- name: "info",
1310
- class: "cursor-pointer text-fm-color-neutral-gray-300"
1311
- }, null),
1312
- content: () => v("div", null, [l("team.labels.permission"), o.permissions.map((x) => v("div", null, [xe("- "), x]))])
1313
- })]);
1314
- }
1315
- function F(o) {
1316
- var x, K, J, X;
1317
- return {
1318
- id: o.id,
1319
- isOwner: o.doc.isOwner,
1320
- name: o.name,
1321
- phoneNumber: o.phoneNumber,
1322
- email: o.email,
1323
- permissions: o.doc.permissions,
1324
- posUser: o.doc.posUser ? {
1325
- code: ((x = o.doc.posUser) == null ? void 0 : x.code) ?? "",
1326
- name: ((K = o.doc.posUser) == null ? void 0 : K.name) ?? o.name,
1327
- passcode: ((J = o.doc.posUser) == null ? void 0 : J.passcode) ?? "",
1328
- roles: ((X = o.doc.posUser) == null ? void 0 : X.roles) ?? []
1329
- } : void 0
1330
- };
1331
- }
1332
- const s = (o, x) => {
1333
- if (o == ae.Update) {
1334
- const K = F(x);
1335
- b.value = K, B.value = H.UPDATE;
1336
- }
1337
- o == ae.Remove && L(x);
1338
- }, _ = we(), N = qe(), B = j(H.CLOSED), V = R(() => B.value !== H.CLOSED), U = R(() => B.value === H.ADD ? l("common.add") : l("common.update")), C = R(() => B.value === H.ADD ? l("team.actions.addMember") : l("team.actions.updateMember")), b = j();
1339
- function c(o) {
1340
- o || (B.value = H.CLOSED);
1341
- }
1342
- function h() {
1343
- B.value = H.CLOSED;
1344
- }
1345
- const {
1346
- breakpoints: E
1347
- } = Be(), L = (o) => {
1348
- N.open({
1349
- title: l("team.actions.removeMember"),
1350
- message: l("team.removeMember.confirmationMessage", {
1351
- memberName: o.name
1352
- }),
1353
- minWidth: E.value.lg ? 588 : 0,
1354
- primaryActions: {
1355
- text: "Remove",
1356
- close: !1,
1357
- variant: "destructive"
1358
- },
1359
- secondaryActions: {
1360
- text: "Cancel",
1361
- close: !0
1362
- }
1363
- }).onPrimary(async () => {
1364
- await me.deleteTeamMember(o.id).then(() => _.open({
1365
- message: l("team.removeMember.successMessage", {
1366
- memberName: o.name
1367
- }),
1368
- type: "success"
1369
- })).catch((x) => n(x)), N.close(), W();
1370
- });
1371
- }, Y = () => {
1372
- b.value = null, B.value = H.ADD;
1373
- }, g = j([]), a = j(), w = j(), f = R(() => Object.values(ce).map((o) => ({
1374
- label: o.label,
1375
- value: o.subject
1376
- }))), {
1377
- searchKey: S,
1378
- filter: D
1379
- } = je(""), te = R(() => g.value.filter((o) => {
1380
- var X;
1381
- const x = !a.value || o.managableRestaurantIds.some((le) => a.value.includes(le)), K = ((X = o.doc.permissions) == null ? void 0 : X.map((le) => le.subject).flat().filter(Boolean)) || [], J = !w.value || K.some((le) => w.value.includes(le));
1382
- return x && J && D([o.name, o.phoneNumber, $(o)]);
1383
- }));
1384
- async function W(o = !0) {
1385
- const x = await me.readTeamMembers();
1386
- g.value = x.sort((K, J) => K.doc.isOwner ? -1 : K.name.localeCompare(J.name)), o || await i.readRoles();
1387
- }
1388
- const se = j();
1389
- async function fe() {
1390
- if (se.value) {
1391
- const o = await se.value.validate();
1392
- if (!o) return;
1393
- try {
1394
- await (B.value === H.ADD ? me.createTeamMember(o) : me.updateTeamMember(b.value.id, o)), await W(), B.value === H.ADD ? r(l("team.addMember.successMessage", {
1395
- memberName: o.name
1396
- })) : r(l("team.updateMember.successMessage", {
1397
- memberName: o.name
1398
- }));
1399
- } catch (x) {
1400
- n(x);
1401
- }
1402
- }
1403
- B.value = H.CLOSED;
1404
- }
1405
- return Ve(e.currentBusiness, () => {
1406
- var o;
1407
- (o = e.currentBusiness.value) != null && o._id && W(!1);
1408
- }, {
1409
- immediate: !0
1410
- }), (o, x) => {
1411
- const K = M("FmSpacer"), J = M("FmButton"), X = M("FmSearch"), le = M("FmTable"), Ne = M("FmSideSheet");
1412
- return m(), P(ne, null, [v(ze, {
1413
- heading: d(l)("team.title")
1414
- }, {
1415
- "append-heading": q(() => [v(K), v(J, {
1416
- "prepend-icon": "add",
1417
- label: d(l)("team.actions.addMember"),
1418
- onClick: Y
1419
- }, null, 8, ["label"])]),
1420
- default: q(() => [u("div", ll, [u("div", sl, [u("div", al, [u("div", ol, [v(d($e), {
1421
- modelValue: a.value,
1422
- "onUpdate:modelValue": x[0] || (x[0] = (T) => a.value = T),
1423
- "managable-only": !1,
1424
- multiple: "",
1425
- variant: "dark",
1426
- class: "!w-auto"
1427
- }, null, 8, ["modelValue"]), v(Ue, {
1428
- modelValue: w.value,
1429
- "onUpdate:modelValue": x[1] || (x[1] = (T) => w.value = T),
1430
- multiple: "",
1431
- variant: "dark",
1432
- items: f.value,
1433
- "selected-prefix": d(l)("team.filter.selected_permission_prefix"),
1434
- placeholder: d(l)("team.filter.permission_placeholder")
1435
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), v(X, {
1436
- modelValue: d(S),
1437
- "onUpdate:modelValue": x[2] || (x[2] = (T) => ye(S) ? S.value = T : null),
1438
- class: "w-[320px] xs:w-full xs:mt-8",
1439
- autofocus: "",
1440
- placeholder: d(l)("team.search.placeholder")
1441
- }, null, 8, ["modelValue", "placeholder"])]), u("div", nl, [v(X, {
1442
- modelValue: d(S),
1443
- "onUpdate:modelValue": x[3] || (x[3] = (T) => ye(S) ? S.value = T : null),
1444
- class: "w-[320px] xs:w-full xs:mt-8",
1445
- autofocus: "",
1446
- placeholder: d(l)("team.search.placeholder")
1447
- }, null, 8, ["modelValue", "placeholder"]), u("div", rl, [v(d($e), {
1448
- modelValue: a.value,
1449
- "onUpdate:modelValue": x[4] || (x[4] = (T) => a.value = T),
1450
- "managable-only": !1,
1451
- multiple: "",
1452
- variant: "dark",
1453
- class: "!w-auto"
1454
- }, null, 8, ["modelValue"]), v(Ue, {
1455
- modelValue: w.value,
1456
- "onUpdate:modelValue": x[5] || (x[5] = (T) => w.value = T),
1457
- multiple: "",
1458
- variant: "dark",
1459
- items: f.value,
1460
- "selected-prefix": d(l)("team.filter.selected_permission_prefix"),
1461
- placeholder: d(l)("team.filter.permission_placeholder")
1462
- }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), g.value && g.value.length > 0 ? (m(), P("div", il, [v(Te, null, {
1463
- default: q(() => [v(le, {
1464
- "column-defs": p,
1465
- "row-data": te.value,
1466
- "page-size": te.value.length,
1467
- "pin-header-row": "",
1468
- "hide-footer": "",
1469
- "shrink-at": !1,
1470
- onRowClick: x[6] || (x[6] = (T) => s(d(ae).Update, T.original))
1471
- }, null, 8, ["row-data", "page-size"])]),
1472
- _: 1
1473
- })])) : (m(), P("div", ul, [u("div", ml, [u("div", null, [u("img", {
1474
- src: d(We),
1475
- alt: "List is empty"
1476
- }, null, 8, dl)]), u("p", cl, A(d(l)("team.emptyState.title")), 1), u("p", pl, A(d(l)("team.emptyState.description")), 1)])]))])])]),
1477
- _: 1
1478
- }, 8, ["heading"]), v(Ne, {
1479
- header: C.value,
1480
- "model-value": V.value,
1481
- "max-width": 560,
1482
- "dismiss-away": "",
1483
- "onUpdate:modelValue": x[7] || (x[7] = (T) => c(T))
1484
- }, {
1485
- "side-sheet-footer": q(() => [u("div", fl, [v(J, {
1486
- label: U.value,
1487
- size: "md",
1488
- variant: "primary",
1489
- onClick: Re(fe, ["prevent"])
1490
- }, null, 8, ["label"]), v(J, {
1491
- label: d(l)("common.cancel"),
1492
- size: "md",
1493
- variant: "secondary",
1494
- onClick: h
1495
- }, null, 8, ["label"])])]),
1496
- default: q(() => [v(el, {
1497
- ref_key: "memberForm",
1498
- ref: se,
1499
- initialValue: b.value,
1500
- class: "gap-8"
1501
- }, null, 8, ["initialValue"])]),
1502
- _: 1
1503
- }, 8, ["header", "model-value"])], 64);
1504
- };
1505
- }
1506
- });
1507
- export {
1508
- $l as default
1509
- };