@feedmepos/mf-hrm-portal 2.0.19 → 2.0.20-dev.2

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 (66) hide show
  1. package/dist/AuditLogList-ChxAzO74.js +1037 -0
  2. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +58 -0
  3. package/dist/EmployeeList-Cs-Mn6UA.js +843 -0
  4. package/dist/FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js +45 -0
  5. package/dist/FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js +49 -0
  6. package/dist/{Main-BPM7QyFL.js → Main-B9_TyRDo.js} +2009 -2005
  7. package/dist/Main-CdHW4UkN.js +90 -0
  8. package/dist/Main-DcvmP7s-.js +574 -0
  9. package/dist/PermissionSetList-VFVS0g0v.js +347 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Dr3R9JjS.js +3444 -0
  11. package/dist/RoleList-BZ6RZvm2.js +556 -0
  12. package/dist/TeamMemberList-C-zhFauD.js +1115 -0
  13. package/dist/{TimesheetList-CdWXksIf.js → TimesheetList-CZex54an.js} +129 -115
  14. package/dist/{app-D6OxaCEx.js → app-CLL3p27X.js} +699 -653
  15. package/dist/app.js +1 -1
  16. package/dist/{dayjs.min-C0I-OiL6.js → dayjs.min-CDt1i9vl.js} +1 -1
  17. package/dist/employee-BpRvjWNh.js +200 -0
  18. package/dist/{iteration-CcZFMm5X.js → iteration-BVjUzYL5.js} +9314 -9272
  19. package/dist/{lodash-CW7MBjcM.js → lodash-CrwgACp2.js} +1 -1
  20. package/dist/{rule-6Lg9M_3I.js → rule-BlQ5YZ9Z.js} +274 -275
  21. package/dist/src/api/audit-log/index.d.ts +9 -0
  22. package/dist/src/api/index.d.ts +0 -1
  23. package/dist/src/api/restaurant/index.d.ts +5 -0
  24. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  25. package/dist/src/components/CollapsibleWrapper.vue.d.ts +2 -0
  26. package/dist/src/components/Skeleton.vue.d.ts +7 -0
  27. package/dist/src/composables/useBasePermission.d.ts +1 -0
  28. package/dist/src/composables/useRestaurantMap.d.ts +2 -329
  29. package/dist/src/stores/restaurant.d.ts +181 -0
  30. package/dist/src/stores/role.d.ts +7 -7
  31. package/dist/src/stores/team.d.ts +6 -6
  32. package/dist/src/types/restaurant.d.ts +11 -0
  33. package/dist/src/types/team.d.ts +2 -1
  34. package/dist/src/views/hr/locales/index.d.ts +16 -0
  35. package/dist/src/views/team/components/BasePermission.vue.d.ts +3 -7
  36. package/dist/src/views/team/components/PosRolePermission.vue.d.ts +2 -2
  37. package/dist/src/views/team/locales/index.d.ts +32 -0
  38. package/dist/src/views/team/member/AddMemberForm.vue.d.ts +5 -3
  39. package/dist/src/views/team/member/TeamMemberMasterUser.vue.d.ts +3 -3
  40. package/dist/style.css +1 -1
  41. package/dist/{timesheet-CaSIm-Rv.js → timesheet-jFs4GTAL.js} +2 -2
  42. package/dist/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/useAppStore-DMAL8VFY.js +169 -0
  44. package/dist/useDebounce-CWb5QR9G.js +28 -0
  45. package/dist/useDiscardConfirm-DPhEV6v0.js +157 -0
  46. package/dist/{useLoading-cnpr1-pP.js → useLoading-AFTjRLyO.js} +1 -1
  47. package/dist/{useReportPermissions-CNr0AdOf.js → useReportPermissions-hODG0Xx3.js} +3 -3
  48. package/package.json +1 -1
  49. package/dist/AuditLogList-Bw3sRBhW.js +0 -980
  50. package/dist/EmployeeList-C4tVWPJE.js +0 -736
  51. package/dist/FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js +0 -71
  52. package/dist/HorizontalSplitter-o860F4xM.js +0 -12
  53. package/dist/Main-BC20s7cs.js +0 -560
  54. package/dist/Main-eN8MDWpv.js +0 -85
  55. package/dist/PermissionSetList-CPSRrCsu.js +0 -341
  56. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CXt721Zo.js +0 -3480
  57. package/dist/RoleList-tRu19xyl.js +0 -530
  58. package/dist/TeamMemberList-CvitYIKw.js +0 -1114
  59. package/dist/TeamMemberList.vue_vue_type_style_index_0_scoped_473cbd86_lang-BDjrD45a.js +0 -34
  60. package/dist/employee-yT17VCCS.js +0 -204
  61. package/dist/src/api/account/index.d.ts +0 -4
  62. package/dist/src/composables/useSupportedCountries.d.ts +0 -5
  63. package/dist/useAppStore-CONZvtGc.js +0 -171
  64. package/dist/useDebounce-B8ZPVS5C.js +0 -15
  65. package/dist/useDiscardConfirm-BHni0LNu.js +0 -28
  66. package/dist/useSearch-B6WK1LBB.js +0 -15
@@ -0,0 +1,90 @@
1
+ import { defineComponent as T, ref as R, computed as m, resolveComponent as s, createBlock as i, openBlock as c, withCtx as p, createElementVNode as A, createVNode as d, resolveDynamicComponent as C, createCommentVNode as S } from "vue";
2
+ import { useRouter as y, useRoute as g } from "vue-router";
3
+ import { useI18n as k } from "@feedmepos/mf-common";
4
+ import { _ as F } from "./ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js";
5
+ import { _ as N } from "./PageLayout.vue_vue_type_script_setup_true_lang-HKK4cbW8.js";
6
+ import { u as h } from "./iteration-BVjUzYL5.js";
7
+ import "@feedmepos/ui-library";
8
+ import "./rule-BlQ5YZ9Z.js";
9
+ import "./lodash-CrwgACp2.js";
10
+ import "./useAppStore-DMAL8VFY.js";
11
+ import { R as v } from "./app-CLL3p27X.js";
12
+ /* empty css */
13
+ /* empty css */
14
+ const w = { class: "space-y-24" }, Q = /* @__PURE__ */ T({
15
+ __name: "Main",
16
+ setup(x) {
17
+ const { t: a } = k(), _ = y(), B = g(), { readRestaurants: L } = h(), f = R(), b = R(), o = m({
18
+ get: () => B.name === v.TEAM_ROLE ? "role" : "member",
19
+ set: (e) => {
20
+ _.push({
21
+ name: e === "role" ? v.TEAM_ROLE : v.TEAM_MEMBER,
22
+ query: _.currentRoute.value.query
23
+ });
24
+ }
25
+ });
26
+ L();
27
+ const r = m(() => l.value.find((e) => e.value === o.value) || l.value[0]), l = m(() => [
28
+ {
29
+ label: a("team.title"),
30
+ value: "member",
31
+ createButtonLabel: a("team.actions.addMember"),
32
+ createButtonAction: () => {
33
+ var e;
34
+ (e = f.value) == null || e.create();
35
+ }
36
+ },
37
+ {
38
+ label: a("permissionSet.title"),
39
+ value: "role",
40
+ createButtonLabel: a("permissionSet.createButtonLabel"),
41
+ createButtonAction: () => {
42
+ var e;
43
+ (e = b.value) == null || e.create();
44
+ }
45
+ }
46
+ ]);
47
+ return (e, n) => {
48
+ const E = s("FmSpacer"), M = s("FmTabs"), V = s("RouterView");
49
+ return c(), i(N, {
50
+ heading: r.value.label
51
+ }, {
52
+ "append-heading": p(() => {
53
+ var t;
54
+ return [
55
+ d(E),
56
+ (t = r.value) != null && t.createButtonLabel ? (c(), i(F, {
57
+ key: 0,
58
+ icon: "add",
59
+ label: r.value.createButtonLabel,
60
+ onClick: n[0] || (n[0] = (u) => r.value.createButtonAction())
61
+ }, null, 8, ["label"])) : S("", !0)
62
+ ];
63
+ }),
64
+ default: p(() => [
65
+ A("div", w, [
66
+ d(M, {
67
+ modelValue: o.value,
68
+ "onUpdate:modelValue": n[1] || (n[1] = (t) => o.value = t),
69
+ items: l.value
70
+ }, null, 8, ["modelValue", "items"]),
71
+ d(V, null, {
72
+ default: p(({ Component: t }) => [
73
+ (c(), i(C(t), {
74
+ ref: (u) => {
75
+ o.value === "member" && (f.value = u), o.value === "role" && (b.value = u);
76
+ }
77
+ }, null, 512))
78
+ ]),
79
+ _: 1
80
+ })
81
+ ])
82
+ ]),
83
+ _: 1
84
+ }, 8, ["heading"]);
85
+ };
86
+ }
87
+ });
88
+ export {
89
+ Q as default
90
+ };
@@ -0,0 +1,574 @@
1
+ import { ref as I, defineComponent as Q, computed as F, watch as ie, resolveComponent as h, createElementBlock as E, openBlock as S, Fragment as J, renderSlot as ge, createVNode as n, unref as r, withCtx as x, createElementVNode as c, toDisplayString as w, createBlock as K, isRef as oe, renderList as fe, createCommentVNode as ve, withModifiers as ne, createTextVNode as le, normalizeClass as _e, h as _ } from "vue";
2
+ import { useI18n as X, useCoreStore as ye } from "@feedmepos/mf-common";
3
+ import { useSnackbar as Y, components as M, useDialog as Ue, useBreakpoints as he, FmButtonVariant as q } from "@feedmepos/ui-library";
4
+ import { _ as xe } from "./PageLayout.vue_vue_type_script_setup_true_lang-HKK4cbW8.js";
5
+ import { u as Z } from "./useAppStore-DMAL8VFY.js";
6
+ import { g as z, a as be, b as H, u as ee } from "./iteration-BVjUzYL5.js";
7
+ import { defineStore as ke } from "pinia";
8
+ import { S as D } from "./SelectFilter-DUj7GBtT.js";
9
+ import { _ as we } from "./app-CLL3p27X.js";
10
+ import { _ as ce, u as Fe, H as Ve } from "./FormItem.vue_vue_type_script_setup_true_lang-D3MOFOUI.js";
11
+ import { _ as Se } from "./index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js";
12
+ import { u as ue } from "./useLoading-AFTjRLyO.js";
13
+ import { _ as Ie } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
14
+ const W = {
15
+ async getGrantUsers() {
16
+ return z(await H("grant").get(""));
17
+ },
18
+ async createGrantUser(m) {
19
+ return z(await H("grant").post("", m));
20
+ },
21
+ async revokeGrantUser(m, y) {
22
+ return z(
23
+ await H("grant").patch(`/revoke/${m}`, null, {
24
+ params: { restaurantId: y }
25
+ })
26
+ );
27
+ },
28
+ // Test grant validation
29
+ async validatePasscode(m, y) {
30
+ return z(
31
+ await be().post("", {
32
+ passcode: m,
33
+ restaurantId: y
34
+ })
35
+ );
36
+ }
37
+ }, Ce = ke("grantUser", () => {
38
+ const m = I([]), y = I(!1);
39
+ async function a() {
40
+ y.value = !0;
41
+ try {
42
+ m.value = (await W.getGrantUsers()).sort(
43
+ (u, p) => u.createdAt < p.createdAt ? 1 : -1
44
+ );
45
+ } catch (u) {
46
+ throw console.error("Error reading grant users:", u), u;
47
+ } finally {
48
+ y.value = !1;
49
+ }
50
+ }
51
+ async function U(u) {
52
+ try {
53
+ const p = await W.createGrantUser(u);
54
+ return m.value = [p, ...m.value], p;
55
+ } catch (p) {
56
+ throw console.error("Error creating grant user:", p), p;
57
+ }
58
+ }
59
+ async function b(u, p) {
60
+ try {
61
+ const l = await W.revokeGrantUser(u, p), i = m.value.findIndex((s) => s._id === u);
62
+ i !== -1 && (m.value[i] = l);
63
+ } catch (l) {
64
+ throw console.error("Error revoking grant user:", l), l;
65
+ }
66
+ }
67
+ return {
68
+ grantUsers: m,
69
+ isLoading: y,
70
+ readGrantUsers: a,
71
+ createGrantUser: U,
72
+ revokeGrantUser: b
73
+ };
74
+ }), te = Ce, Be = { class: "fm-typo-en-title-md-600" }, $e = { class: "space-y-40" }, Ge = { class: "flex gap-8 items-center justify-start" }, Re = /* @__PURE__ */ Q({
75
+ __name: "GrantUserForm",
76
+ setup(m, { expose: y }) {
77
+ const a = te(), U = Z(), b = ee(), u = Y(), p = ue(u), { t: l } = X(), i = I(!1), s = I({
78
+ name: "",
79
+ restaurantId: "",
80
+ roleId: ""
81
+ }), k = () => {
82
+ s.value = {
83
+ name: "",
84
+ restaurantId: "",
85
+ roleId: ""
86
+ }, i.value = !0;
87
+ }, V = F(() => l("grantUser.form.title")), C = F(() => l("common.create")), B = F(() => b.restaurants.value.map((d) => ({
88
+ label: `${d.profile.code ? d.profile.code + " - " : ""}${d.profile.name}`,
89
+ value: d._id
90
+ }))), R = F(() => s.value.restaurantId ? U.roles.value.filter((d) => d.restaurants.some((g) => g.id === s.value.restaurantId)).map((d) => ({
91
+ label: d.name,
92
+ value: d._id,
93
+ disabled: !d.isUsable
94
+ })) : []);
95
+ ie(
96
+ () => s.value.restaurantId,
97
+ () => {
98
+ s.value.roleId = "";
99
+ }
100
+ );
101
+ async function P() {
102
+ await p.minor(async () => {
103
+ const d = await a.createGrantUser(s.value);
104
+ u.open({
105
+ message: l("grantUser.create.successMessage", {
106
+ passcode: d.passcode
107
+ }),
108
+ type: "success"
109
+ });
110
+ }), i.value = !1;
111
+ }
112
+ return y({
113
+ show: i,
114
+ trigger: k
115
+ }), (d, g) => {
116
+ const T = h("FmTextField"), G = h("FmSelect"), L = h("fm-button"), N = h("fm-side-sheet");
117
+ return S(), E(J, null, [
118
+ ge(d.$slots, "default", { trigger: k }),
119
+ n(N, {
120
+ id: "grant-user-form",
121
+ modelValue: i.value,
122
+ "onUpdate:modelValue": g[4] || (g[4] = (f) => i.value = f),
123
+ "is-container": r(M).FmForm,
124
+ "is-container-props": {
125
+ onValidationSuccess: P,
126
+ blameFormChildOnValidationFailed: !0
127
+ },
128
+ "max-width": 560
129
+ }, {
130
+ "side-sheet-header": x(() => [
131
+ c("p", Be, w(V.value), 1)
132
+ ]),
133
+ "side-sheet-footer": x(() => [
134
+ c("div", Ge, [
135
+ n(L, {
136
+ label: C.value,
137
+ size: "lg",
138
+ type: "submit",
139
+ variant: "primary"
140
+ }, null, 8, ["label"]),
141
+ n(L, {
142
+ label: r(l)("common.cancel"),
143
+ size: "lg",
144
+ variant: "tertiary",
145
+ onClick: g[3] || (g[3] = () => i.value = !1)
146
+ }, null, 8, ["label"])
147
+ ])
148
+ ]),
149
+ default: x(() => [
150
+ c("div", $e, [
151
+ n(Ie, {
152
+ title: r(l)("grantUser.form.section")
153
+ }, {
154
+ default: x(() => [
155
+ n(T, {
156
+ modelValue: s.value.name,
157
+ "onUpdate:modelValue": g[0] || (g[0] = (f) => s.value.name = f),
158
+ label: r(l)("grantUser.form.name"),
159
+ rules: [(f) => !!f || r(l)("grantUser.form.nameRequired")]
160
+ }, null, 8, ["modelValue", "label", "rules"]),
161
+ n(ce, {
162
+ label: r(l)("grantUser.form.restaurant")
163
+ }, {
164
+ default: x(() => [
165
+ n(G, {
166
+ modelValue: s.value.restaurantId,
167
+ "onUpdate:modelValue": g[1] || (g[1] = (f) => s.value.restaurantId = f),
168
+ items: B.value,
169
+ placeholder: r(l)("grantUser.form.selectRestaurant"),
170
+ rules: [(f) => !!f || r(l)("grantUser.form.restaurantRequired")]
171
+ }, null, 8, ["modelValue", "items", "placeholder", "rules"])
172
+ ]),
173
+ _: 1
174
+ }, 8, ["label"]),
175
+ n(ce, {
176
+ label: r(l)("grantUser.form.role")
177
+ }, {
178
+ default: x(() => [
179
+ n(G, {
180
+ modelValue: s.value.roleId,
181
+ "onUpdate:modelValue": g[2] || (g[2] = (f) => s.value.roleId = f),
182
+ items: R.value,
183
+ placeholder: r(l)("grantUser.form.selectRole"),
184
+ disabled: !s.value.restaurantId,
185
+ rules: [(f) => !!f || r(l)("grantUser.form.roleRequired")]
186
+ }, null, 8, ["modelValue", "items", "placeholder", "disabled", "rules"])
187
+ ]),
188
+ _: 1
189
+ }, 8, ["label"])
190
+ ]),
191
+ _: 1
192
+ }, 8, ["title"])
193
+ ])
194
+ ]),
195
+ _: 1
196
+ }, 8, ["modelValue", "is-container", "is-container-props"])
197
+ ], 64);
198
+ };
199
+ }
200
+ }), Le = {
201
+ class: "space-y-8"
202
+ }, Ne = {
203
+ class: "xs:hidden flex w-full items-start justify-between"
204
+ }, Ae = {
205
+ class: "flex items-start gap-8"
206
+ }, ze = {
207
+ class: "space-y-4 hidden xs:block"
208
+ }, De = {
209
+ class: "px-16"
210
+ }, Ee = {
211
+ class: "px-16 flex items-start gap-8"
212
+ }, Ke = {
213
+ class: "pb-64 hidden xs:block"
214
+ }, Me = {
215
+ class: "space-y-4"
216
+ }, Pe = {
217
+ class: "flex items-center gap-8"
218
+ }, Te = {
219
+ class: "fm-typo-en-body-lg-600"
220
+ }, Oe = {
221
+ class: "font-mono text-lg font-bold mr-4"
222
+ }, je = {
223
+ class: "text-fm-color-typo-secondary"
224
+ }, qe = {
225
+ class: "text-xs"
226
+ }, He = {
227
+ class: "mt-4 space-y-2"
228
+ }, We = {
229
+ class: "text-xs"
230
+ }, Je = {
231
+ class: "text-xs"
232
+ }, Qe = {
233
+ key: 0,
234
+ class: "flex flex-col gap-4"
235
+ }, Xe = /* @__PURE__ */ Q({
236
+ __name: "GrantUserList",
237
+ setup(m, {
238
+ expose: y
239
+ }) {
240
+ const {
241
+ t: a
242
+ } = X(), U = I(), b = te(), {
243
+ restaurants: u
244
+ } = ee(), {
245
+ roles: p
246
+ } = Z(), l = F(() => b.grantUsers), {
247
+ searchKey: i,
248
+ filter: s
249
+ } = Fe(), k = F(() => {
250
+ var e;
251
+ return (e = l.value) == null ? void 0 : e.filter((t) => {
252
+ const v = !U.value || U.value.includes(t.restaurantId), O = !$.value || $.value.includes(t.status), A = V.value[t.restaurantId] || "", j = C.value[t.roleId] || "";
253
+ return v && O && s([t.passcode, t.name, A, j, t.grantByName]);
254
+ });
255
+ }), V = F(() => {
256
+ const e = {};
257
+ return u.value.forEach((t) => {
258
+ e[t._id] = t.profile.name;
259
+ }), e;
260
+ }), C = F(() => {
261
+ const e = {};
262
+ return p.value.forEach((t) => {
263
+ e[t._id] = t.name;
264
+ }), e;
265
+ }), B = (e) => {
266
+ switch (e) {
267
+ case "active":
268
+ return "bg-fm-color-system-success-100 text-fm-color-typo-success";
269
+ case "used":
270
+ return "bg-fm-color-typo-tertiary text-fm-color-typo-primary";
271
+ case "revoked":
272
+ return "bg-fm-color-system-error-100 text-fm-color-typo-error";
273
+ default:
274
+ return "bg-fm-color-typo-secondary text-fm-color-typo-primary";
275
+ }
276
+ }, R = (e) => a(`grantUser.status.${e}`), P = [{
277
+ accessorKey: "passcode",
278
+ size: 120,
279
+ maxSize: 120,
280
+ minSize: 120,
281
+ header: () => a("grantUser.columns.passcode"),
282
+ cell(e) {
283
+ const t = e.row.original.passcode;
284
+ return _("div", {
285
+ class: "flex items-center gap-8"
286
+ }, [_(M.FmButton, {
287
+ variant: q.Tertiary,
288
+ textColor: "neutral-gray-400",
289
+ icon: "content_copy",
290
+ onClick: (v) => {
291
+ v.stopPropagation(), se(t);
292
+ }
293
+ }), _("span", {
294
+ class: "font-mono text-lg font-bold"
295
+ }, t)]);
296
+ }
297
+ }, {
298
+ accessorKey: "name",
299
+ header: () => a("grantUser.columns.name")
300
+ }, {
301
+ accessorKey: "restaurantName",
302
+ accessorFn: (e) => V.value[e.restaurantId],
303
+ header: () => a("grantUser.columns.restaurant"),
304
+ meta: {
305
+ width: "250px"
306
+ },
307
+ cell(e) {
308
+ const t = e.row.original.restaurantId, v = V.value[t] || "-";
309
+ return _("div", [_("div", v), _("div", {
310
+ class: "text-fm-color-typo-secondary text-sm"
311
+ }, `${t}`)]);
312
+ }
313
+ }, {
314
+ accessorKey: "roleName",
315
+ accessorFn: (e) => C.value[e.roleId],
316
+ header: () => a("grantUser.columns.role"),
317
+ cell(e) {
318
+ const t = e.row.original.roleId, v = C.value[t] || "-";
319
+ return _("div", v);
320
+ }
321
+ }, {
322
+ accessorKey: "status",
323
+ header: () => a("grantUser.columns.status"),
324
+ meta: {
325
+ maxWidth: "120px"
326
+ },
327
+ cell(e) {
328
+ const t = e.row.original.status;
329
+ return _(M.FmChip, {
330
+ label: R(t),
331
+ class: B(t)
332
+ });
333
+ }
334
+ }, {
335
+ accessorKey: "grantByName",
336
+ header: () => a("grantUser.columns.grantedBy"),
337
+ cell(e) {
338
+ const t = e.row.original.grantById, v = e.row.original.grantByName;
339
+ return _("div", [_("div", v), _("div", {
340
+ class: "text-fm-color-typo-secondary text-sm"
341
+ }, `${t}`)]);
342
+ }
343
+ }, {
344
+ accessorKey: "createdAt",
345
+ header: () => a("grantUser.columns.createdAt"),
346
+ cell(e) {
347
+ const t = e.row.original.createdAt;
348
+ return _("div", new Date(t).toLocaleString());
349
+ }
350
+ }, {
351
+ id: "action",
352
+ size: 180,
353
+ meta: {
354
+ cellClass: "p-16",
355
+ headerContentClass: "-mx-16"
356
+ },
357
+ cell: (e) => {
358
+ const t = e.row.original;
359
+ return t.status !== "active" ? null : _("div", {
360
+ class: "w-full flex justify-end items-center gap-4"
361
+ }, [_(M.FmButton, {
362
+ label: a("grantUser.actions.revoke"),
363
+ variant: q.Secondary,
364
+ onClick: (v) => {
365
+ v.stopPropagation(), N(t);
366
+ }
367
+ })]);
368
+ }
369
+ }], d = Y(), g = Ue(), T = ue(d), G = I(), {
370
+ breakpoints: L
371
+ } = he(), N = (e) => {
372
+ g.open({
373
+ title: a("grantUser.revoke.title"),
374
+ message: a("grantUser.revoke.message", {
375
+ name: e.name
376
+ }),
377
+ minWidth: L.value.lg ? 588 : 0,
378
+ primaryActions: {
379
+ text: a("grantUser.actions.revoke"),
380
+ close: !1,
381
+ variant: "destructive"
382
+ },
383
+ secondaryActions: {
384
+ text: a("common.cancel"),
385
+ close: !0
386
+ }
387
+ }).onPrimary(async () => {
388
+ T.minor(async () => {
389
+ await b.revokeGrantUser(e._id, e.restaurantId);
390
+ }, {
391
+ successMessage: a("grantUser.revoke.successMessage", {
392
+ name: e.name
393
+ })
394
+ }), g.close();
395
+ });
396
+ };
397
+ function f() {
398
+ var e;
399
+ (e = G.value) == null || e.trigger();
400
+ }
401
+ const ae = F(() => [{
402
+ label: a("grantUser.status.active"),
403
+ value: "active"
404
+ }, {
405
+ label: a("grantUser.status.used"),
406
+ value: "used"
407
+ }, {
408
+ label: a("grantUser.status.revoked"),
409
+ value: "revoked"
410
+ }]), re = F(() => u.value.map((e) => ({
411
+ label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
412
+ value: e._id
413
+ }))), $ = I();
414
+ async function se(e) {
415
+ try {
416
+ await navigator.clipboard.writeText(e), d.open({
417
+ message: a("grantUser.passcode.copied"),
418
+ type: "success"
419
+ });
420
+ } catch (t) {
421
+ d.open({
422
+ message: String(t),
423
+ type: "error"
424
+ });
425
+ }
426
+ }
427
+ return y({
428
+ create: f,
429
+ filteredGrantUsers: k
430
+ }), (e, t) => {
431
+ const v = h("FmSearch"), O = h("FmTable"), A = h("FmButton"), j = h("FmChip"), de = h("FmListItem"), me = h("FmList");
432
+ return S(), E(J, null, [n(Re, {
433
+ ref_key: "grantUserFormRef",
434
+ ref: G,
435
+ class: "gap-8"
436
+ }, null, 512), c("div", Le, [c("div", Ne, [c("div", Ae, [n(D, {
437
+ modelValue: U.value,
438
+ "onUpdate:modelValue": t[0] || (t[0] = (o) => U.value = o),
439
+ multiple: "",
440
+ items: re.value,
441
+ variant: "dark",
442
+ "selected-prefix": r(a)("grantUser.columns.restaurant"),
443
+ placeholder: r(a)("grantUser.columns.restaurant"),
444
+ class: "!w-auto"
445
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), n(D, {
446
+ modelValue: $.value,
447
+ "onUpdate:modelValue": t[1] || (t[1] = (o) => $.value = o),
448
+ multiple: "",
449
+ variant: "dark",
450
+ items: ae.value,
451
+ "selected-prefix": r(a)("grantUser.filter.selected_status_prefix"),
452
+ placeholder: r(a)("grantUser.filter.status_placeholder")
453
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), n(v, {
454
+ modelValue: r(i),
455
+ "onUpdate:modelValue": t[2] || (t[2] = (o) => oe(i) ? i.value = o : null),
456
+ autofocus: "",
457
+ class: "pl-4 w-[320px]",
458
+ placeholder: r(a)("grantUser.search.placeholder")
459
+ }, null, 8, ["modelValue", "placeholder"])]), c("div", ze, [c("div", De, [n(v, {
460
+ modelValue: r(i),
461
+ "onUpdate:modelValue": t[3] || (t[3] = (o) => oe(i) ? i.value = o : null),
462
+ autofocus: "",
463
+ placeholder: r(a)("grantUser.search.placeholder")
464
+ }, null, 8, ["modelValue", "placeholder"])]), n(Ve), c("div", Ee, [n(D, {
465
+ modelValue: U.value,
466
+ "onUpdate:modelValue": t[4] || (t[4] = (o) => U.value = o),
467
+ multiple: "",
468
+ items: re.value,
469
+ variant: "dark",
470
+ "selected-prefix": r(a)("grantUser.columns.restaurant"),
471
+ placeholder: r(a)("grantUser.columns.restaurant"),
472
+ class: "!w-auto"
473
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), n(D, {
474
+ modelValue: $.value,
475
+ "onUpdate:modelValue": t[5] || (t[5] = (o) => $.value = o),
476
+ multiple: "",
477
+ items: ae.value,
478
+ variant: "dark",
479
+ "selected-prefix": r(a)("grantUser.filter.selected_status_prefix"),
480
+ placeholder: r(a)("grantUser.filter.status_placeholder")
481
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), l.value.length > 0 || r(b).isLoading ? (S(), K(we, {
482
+ key: 0,
483
+ class: "overflow-auto"
484
+ }, {
485
+ default: x(() => [n(O, {
486
+ class: "xs:hidden",
487
+ "column-defs": P,
488
+ "row-data": k.value,
489
+ "page-size": k.value.length,
490
+ loading: r(b).isLoading,
491
+ virtual: k.value.length > 0,
492
+ "pin-header-row": "",
493
+ "hide-footer": ""
494
+ }, null, 8, ["row-data", "page-size", "loading", "virtual"]), c("div", Ke, [n(me, {
495
+ separator: ""
496
+ }, {
497
+ default: x(() => [(S(!0), E(J, null, fe(k.value, (o) => (S(), K(de, {
498
+ key: o._id,
499
+ class: "py-12 px-16 items-center justify-between"
500
+ }, {
501
+ default: x(() => [c("div", Me, [c("div", Pe, [n(A, {
502
+ variant: "tertiary",
503
+ "text-color": "neutral-gray-400",
504
+ icon: "content_copy",
505
+ onClick: ne((pe) => se(o.passcode), ["stop"])
506
+ }, null, 8, ["onClick"]), c("p", Te, [c("span", Oe, w(o.passcode), 1), le(" - " + w(o.name), 1)])]), c("div", je, [c("div", null, [le(w(V.value[o.restaurantId] || "-") + " ", 1), c("div", qe, w(o.restaurantId), 1), c("div", null, w(C.value[o.roleId] || "-"), 1)]), c("div", He, [c("div", We, w(r(a)("grantUser.columns.grantedBy")) + ": " + w(o.grantByName), 1), c("div", Je, w(r(a)("grantUser.columns.createdAt")) + ": " + w(new Date(o.createdAt).toLocaleString()), 1), n(j, {
507
+ label: R(o.status),
508
+ class: _e(B(o.status))
509
+ }, null, 8, ["label", "class"])])])]), o.status === "active" ? (S(), E("div", Qe, [n(A, {
510
+ label: r(a)("grantUser.actions.revoke"),
511
+ variant: r(q).Secondary,
512
+ onClick: ne((pe) => N(o), ["stop"])
513
+ }, null, 8, ["label", "variant", "onClick"])])) : ve("", !0)]),
514
+ _: 2
515
+ }, 1024))), 128))]),
516
+ _: 1
517
+ })])]),
518
+ _: 1
519
+ })) : (S(), K(r(Se), {
520
+ key: 1,
521
+ title: r(a)("grantUser.noData.title"),
522
+ subtitle: r(a)("grantUser.noData.subtitle")
523
+ }, null, 8, ["title", "subtitle"]))])], 64);
524
+ };
525
+ }
526
+ }), dt = /* @__PURE__ */ Q({
527
+ __name: "Main",
528
+ setup(m) {
529
+ const { readGrantUsers: y } = te(), { currentBusiness: a } = ye(), { readRoles: U } = Z(), { readRestaurants: b } = ee(), { t: u } = X(), p = Y(), l = I();
530
+ return ie(
531
+ a,
532
+ async () => {
533
+ var i;
534
+ if ((i = a.value) != null && i._id)
535
+ try {
536
+ await Promise.all([b(), U(), y()]);
537
+ } catch (s) {
538
+ console.error("Failed to load grant dependencies:", s), p.open({
539
+ message: s instanceof Error ? s.message : String(s),
540
+ type: "error"
541
+ });
542
+ }
543
+ },
544
+ { immediate: !0 }
545
+ ), (i, s) => {
546
+ const k = h("FmSpacer"), V = h("FmButton");
547
+ return S(), K(xe, {
548
+ heading: r(u)("grantUser.title")
549
+ }, {
550
+ "append-heading": x(() => [
551
+ n(k),
552
+ n(V, {
553
+ "prepend-icon": "add",
554
+ label: r(u)("grantUser.actions.create"),
555
+ onClick: s[0] || (s[0] = (C) => {
556
+ var B;
557
+ return (B = l.value) == null ? void 0 : B.create();
558
+ })
559
+ }, null, 8, ["label"])
560
+ ]),
561
+ default: x(() => [
562
+ n(Xe, {
563
+ ref_key: "grantUserListRef",
564
+ ref: l
565
+ }, null, 512)
566
+ ]),
567
+ _: 1
568
+ }, 8, ["heading"]);
569
+ };
570
+ }
571
+ });
572
+ export {
573
+ dt as default
574
+ };