@feedmepos/mf-hrm-portal 2.1.1-dev.6 → 2.2.0-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.
- package/dist/ApprovalCodeList-Cwy-Rn90.js +728 -0
- package/dist/{AuditLogList-DrrL4vf4.js → AuditLogList-CfDEZ6Z-.js} +3 -3
- package/dist/{ConditionFormHost.vue_vue_type_script_setup_true_lang-CBjO1MZo.js → ConditionFormHost.vue_vue_type_script_setup_true_lang-BTDBRB1-.js} +2 -2
- package/dist/{EmployeeList-BMol4ah4.js → EmployeeList-DJrCBYvi.js} +6 -4
- package/dist/{GrantUserList-CLBl7FZ-.js → GrantUserList-UgQBjh54.js} +3 -3
- package/dist/{Main-D_LwrBdZ.js → Main-B5YknOhi.js} +9 -9
- package/dist/{Main-DNOHZd3j.js → Main-BnWK_GkW.js} +5 -5
- package/dist/Main-DQXiP6Io.js +121 -0
- package/dist/{PermissionSetList-DLYrXFbz.js → PermissionSetList-CfPZPmfV.js} +5 -5
- package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Drcx0tL_.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CPk4KJUW.js} +803 -803
- package/dist/{RoleList-g8PjH_k2.js → RoleList-CHnu2j25.js} +7 -7
- package/dist/{TeamMemberList-B9aCagSc.js → TeamMemberList-DprMQ_8g.js} +6 -6
- package/dist/{TimesheetList-C1IJhOYE.js → TimesheetList-D5G1dJfp.js} +5 -5
- package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-CqtiVm1j.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-DFfYiBBf.js} +2 -2
- package/dist/{app-DnOYVjuj.js → app-BhF0Kk5X.js} +154 -135
- package/dist/app.js +1 -1
- package/dist/{dayjs.min-Dxul0qTK.js → dayjs.min-Do1gXFxN.js} +1 -1
- package/dist/{employee-sr65CZR7.js → employee-BRCSs9t_.js} +3 -3
- package/dist/{iteration-DIqDMvFa.js → iteration-C2XLVxL1.js} +1 -1
- package/dist/{lodash-CXlqXFmD.js → lodash-eudyY8-f.js} +1 -1
- package/dist/{role-CE3NY-63.js → role-CSL6Qv8l.js} +1 -1
- package/dist/{rule-CEjrit6c.js → rule-D3DPWTm1.js} +20 -12
- package/dist/src/types/approval-code.d.ts +29 -48
- package/dist/src/views/hr/locales/index.d.ts +4 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{useReportPermissions-FVW_HwcL.js → useReportPermissions-CSdIiY_7.js} +3 -3
- package/package.json +2 -2
- package/dist/ApprovalCodeList-B1XHbhum.js +0 -757
- package/dist/Main-auigiuVZ.js +0 -122
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
import { defineComponent as re, ref as K, computed as g, resolveComponent as b, createBlock as O, openBlock as _, withCtx as $, createElementVNode as s, createElementBlock as S, createCommentVNode as Y, toDisplayString as C, unref as a, Fragment as H, renderList as te, createVNode as c, renderSlot as xe, isRef as ue, withModifiers as de, createTextVNode as be, normalizeClass as ke, h as x } from "vue";
|
|
2
|
+
import { d as Ve } from "./dayjs.min-Do1gXFxN.js";
|
|
3
|
+
import { useI18n as ne } from "@feedmepos/mf-common";
|
|
4
|
+
import { useSnackbar as ie, components as z, useDialog as we, useBreakpoints as Fe, FmButtonVariant as se } from "@feedmepos/ui-library";
|
|
5
|
+
import { S as q } from "./SelectFilter-ATOm0hdn.js";
|
|
6
|
+
import { _ as $e } from "./app-BhF0Kk5X.js";
|
|
7
|
+
import { _ as pe, u as Se, H as Ae } from "./FormItem.vue_vue_type_script_setup_true_lang-DPT2FoIc.js";
|
|
8
|
+
import { _ as Pe } from "./index.vue_vue_type_script_setup_true_lang-BVVwfd7B.js";
|
|
9
|
+
import { u as ve } from "./useLoading-BH02lYns.js";
|
|
10
|
+
import { u as fe } from "./approval-code-Q4666xp5.js";
|
|
11
|
+
import { u as ce } from "./restaurant-YOVMuuFY.js";
|
|
12
|
+
import { _ as Be } from "./FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js";
|
|
13
|
+
function Ie(d) {
|
|
14
|
+
var e;
|
|
15
|
+
const r = (e = d.conditions) == null ? void 0 : e.adjustment;
|
|
16
|
+
if (r && typeof r == "object" && "$lte" in r && typeof r.$lte == "number") {
|
|
17
|
+
const v = Math.round(r.$lte * 100);
|
|
18
|
+
return v === 100 ? void 0 : v;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function ye(d, r) {
|
|
22
|
+
return d.map((e) => {
|
|
23
|
+
const v = r(`approvalCode.permissions.${e.key}`), n = Ie(e);
|
|
24
|
+
return n === void 0 ? v : `${v} ≤${n}%`;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function _e(d, r, e) {
|
|
28
|
+
return [d.name, ye(d.permissions, e).join(", "), r].filter(Boolean).join(" · ");
|
|
29
|
+
}
|
|
30
|
+
function Ce(d, r, e) {
|
|
31
|
+
return [
|
|
32
|
+
_e(d, r, e),
|
|
33
|
+
`${e("approvalCode.columns.passcode")} ${d.passcode}`
|
|
34
|
+
].filter(Boolean).join(" · ");
|
|
35
|
+
}
|
|
36
|
+
function ge(d) {
|
|
37
|
+
return typeof d == "string" ? d.trim() : d;
|
|
38
|
+
}
|
|
39
|
+
function Ne(d) {
|
|
40
|
+
const r = ge(d);
|
|
41
|
+
if (r === void 0 || r === "") return !0;
|
|
42
|
+
const e = Number(r);
|
|
43
|
+
return Number.isInteger(e) && e >= 1 && e <= 100;
|
|
44
|
+
}
|
|
45
|
+
function Ke(d) {
|
|
46
|
+
const r = ge(d);
|
|
47
|
+
if (!(r === void 0 || r === ""))
|
|
48
|
+
return Number(r);
|
|
49
|
+
}
|
|
50
|
+
const oe = [
|
|
51
|
+
{ key: "resend", ruleKey: "resend" },
|
|
52
|
+
{ key: "openDrawer", ruleKey: "openDrawer" },
|
|
53
|
+
{ key: "counter", ruleKey: "counter" },
|
|
54
|
+
{ key: "discount", ruleKey: "discount" },
|
|
55
|
+
{ key: "changePrice", ruleKey: "changePrice" },
|
|
56
|
+
{ key: "void", ruleKey: "void" },
|
|
57
|
+
{ key: "changePaymentType", ruleKey: "changePaymentType" },
|
|
58
|
+
{ key: "refund", ruleKey: "refund" }
|
|
59
|
+
];
|
|
60
|
+
function Me(d, r) {
|
|
61
|
+
const e = Ke(r);
|
|
62
|
+
return d.flatMap((v) => {
|
|
63
|
+
const n = oe.find((h) => h.key === v);
|
|
64
|
+
return n ? [
|
|
65
|
+
n.ruleKey === "discount" && e !== void 0 ? { key: n.ruleKey, maxPercentage: e } : { key: n.ruleKey }
|
|
66
|
+
] : [];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function ee(d) {
|
|
70
|
+
return d.usedAt ?? d.revokedAt;
|
|
71
|
+
}
|
|
72
|
+
function Te(d, r) {
|
|
73
|
+
if (!r || r.length === 0) return !0;
|
|
74
|
+
const e = new Set(
|
|
75
|
+
r.map((v) => {
|
|
76
|
+
var n;
|
|
77
|
+
return (n = oe.find((h) => h.key === v)) == null ? void 0 : n.ruleKey;
|
|
78
|
+
}).filter((v) => v !== void 0)
|
|
79
|
+
);
|
|
80
|
+
return d.permissions.some((v) => e.has(v.key));
|
|
81
|
+
}
|
|
82
|
+
const je = { class: "pr-24" }, De = { class: "fm-typo-en-title-md-600" }, Re = { class: "text-fm-color-typo-secondary text-sm mt-4" }, Ue = { class: "rounded-md border border-fm-color-neutral-gray-100 p-16" }, Le = { class: "flex items-center justify-between gap-8" }, ze = { class: "text-fm-color-typo-secondary text-sm min-w-0" }, Oe = { class: "font-mono text-xl font-bold" }, Ee = { class: "w-full flex items-center justify-end gap-8" }, qe = /* @__PURE__ */ re({
|
|
83
|
+
__name: "ApprovalCodeCreatedDialog",
|
|
84
|
+
emits: ["createAnother"],
|
|
85
|
+
setup(d, { expose: r, emit: e }) {
|
|
86
|
+
const v = e, { t: n } = ne(), h = ie(), { restaurants: V } = ce(), w = K(!1), i = K([]), A = (f) => {
|
|
87
|
+
f.length !== 0 && (i.value = f, w.value = !0);
|
|
88
|
+
}, M = g(() => i.value.length > 1), p = g(() => {
|
|
89
|
+
var P, u;
|
|
90
|
+
const f = (P = i.value[0]) == null ? void 0 : P.restaurantId;
|
|
91
|
+
return (u = V.value.find((y) => y._id === f)) == null ? void 0 : u.profile.name;
|
|
92
|
+
}), B = g(() => {
|
|
93
|
+
const f = i.value[0];
|
|
94
|
+
return f ? _e(f, p.value, n) : "";
|
|
95
|
+
}), I = g(
|
|
96
|
+
() => M.value ? n("approvalCode.created.titleBulk", { count: i.value.length }) : n("approvalCode.created.title")
|
|
97
|
+
), U = g(
|
|
98
|
+
() => M.value ? n("approvalCode.created.subtitleBulk") : n("approvalCode.created.subtitle")
|
|
99
|
+
);
|
|
100
|
+
async function T(f) {
|
|
101
|
+
try {
|
|
102
|
+
await navigator.clipboard.writeText(f), h.open({
|
|
103
|
+
message: n("approvalCode.passcode.copied"),
|
|
104
|
+
type: "success"
|
|
105
|
+
});
|
|
106
|
+
} catch (P) {
|
|
107
|
+
h.open({
|
|
108
|
+
message: String(P),
|
|
109
|
+
type: "error"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const E = (f) => T(Ce(f, p.value, n)), j = () => T([B.value, ...i.value.map((f) => f.passcode)].join(`
|
|
114
|
+
`)), W = () => {
|
|
115
|
+
w.value = !1;
|
|
116
|
+
}, N = () => {
|
|
117
|
+
w.value = !1, v("createAnother");
|
|
118
|
+
};
|
|
119
|
+
return r({ open: A }), (f, P) => {
|
|
120
|
+
const u = b("FmButton"), y = b("FmDialog");
|
|
121
|
+
return _(), O(y, {
|
|
122
|
+
modelValue: w.value,
|
|
123
|
+
"onUpdate:modelValue": P[0] || (P[0] = (F) => w.value = F),
|
|
124
|
+
"min-width": 360,
|
|
125
|
+
"max-width": 560
|
|
126
|
+
}, {
|
|
127
|
+
"dialog-header": $(() => [
|
|
128
|
+
s("div", je, [
|
|
129
|
+
s("p", De, C(I.value), 1),
|
|
130
|
+
s("p", Re, C(U.value), 1)
|
|
131
|
+
])
|
|
132
|
+
]),
|
|
133
|
+
"dialog-footer": $(() => [
|
|
134
|
+
s("div", Ee, [
|
|
135
|
+
c(u, {
|
|
136
|
+
variant: "secondary",
|
|
137
|
+
label: a(n)("approvalCode.created.createAnother"),
|
|
138
|
+
onClick: N
|
|
139
|
+
}, null, 8, ["label"]),
|
|
140
|
+
c(u, {
|
|
141
|
+
variant: "primary",
|
|
142
|
+
label: a(n)("approvalCode.created.done"),
|
|
143
|
+
onClick: W
|
|
144
|
+
}, null, 8, ["label"])
|
|
145
|
+
])
|
|
146
|
+
]),
|
|
147
|
+
default: $(() => [
|
|
148
|
+
s("div", Ue, [
|
|
149
|
+
s("div", Le, [
|
|
150
|
+
s("p", ze, C(B.value), 1),
|
|
151
|
+
M.value ? (_(), O(u, {
|
|
152
|
+
key: 0,
|
|
153
|
+
class: "shrink-0 whitespace-nowrap",
|
|
154
|
+
variant: "secondary",
|
|
155
|
+
icon: "content_copy",
|
|
156
|
+
label: a(n)("approvalCode.created.copyAll"),
|
|
157
|
+
onClick: j
|
|
158
|
+
}, null, 8, ["label"])) : Y("", !0)
|
|
159
|
+
]),
|
|
160
|
+
(_(!0), S(H, null, te(i.value, (F) => (_(), S("div", {
|
|
161
|
+
key: F._id,
|
|
162
|
+
class: "flex items-center justify-between mt-8"
|
|
163
|
+
}, [
|
|
164
|
+
s("span", Oe, C(F.passcode), 1),
|
|
165
|
+
c(u, {
|
|
166
|
+
variant: "tertiary",
|
|
167
|
+
icon: "content_copy",
|
|
168
|
+
label: a(n)("approvalCode.created.copy"),
|
|
169
|
+
onClick: (G) => E(F)
|
|
170
|
+
}, null, 8, ["label", "onClick"])
|
|
171
|
+
]))), 128))
|
|
172
|
+
])
|
|
173
|
+
]),
|
|
174
|
+
_: 1
|
|
175
|
+
}, 8, ["modelValue"]);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}), Ye = { class: "fm-typo-en-title-md-600" }, He = { class: "space-y-40" }, We = { class: "space-y-8" }, Ge = { class: "flex items-center gap-8" }, Xe = {
|
|
179
|
+
key: 0,
|
|
180
|
+
class: "pl-32 pt-8"
|
|
181
|
+
}, Ze = {
|
|
182
|
+
key: 0,
|
|
183
|
+
class: "text-fm-color-typo-error text-sm"
|
|
184
|
+
}, Je = {
|
|
185
|
+
key: 0,
|
|
186
|
+
class: "text-fm-color-typo-error text-sm"
|
|
187
|
+
}, Qe = { class: "flex gap-8 items-center justify-start" }, et = /* @__PURE__ */ re({
|
|
188
|
+
__name: "ApprovalCodeForm",
|
|
189
|
+
emits: ["created"],
|
|
190
|
+
setup(d, { expose: r, emit: e }) {
|
|
191
|
+
const v = e, n = fe(), h = ce(), V = ie(), w = ve(V), { t: i } = ne(), A = K(!1), M = () => ({
|
|
192
|
+
name: "",
|
|
193
|
+
restaurantId: "",
|
|
194
|
+
permissions: [],
|
|
195
|
+
count: 1
|
|
196
|
+
}), p = K(M()), B = K(void 0), I = () => {
|
|
197
|
+
p.value = M(), B.value = void 0, A.value = !0;
|
|
198
|
+
}, U = g(() => i("approvalCode.form.title")), T = g(() => i("common.create")), E = g(() => h.restaurants.value.map((u) => ({
|
|
199
|
+
label: `${u.profile.code ? u.profile.code + " - " : ""}${u.profile.name}`,
|
|
200
|
+
value: u._id
|
|
201
|
+
}))), j = (u) => p.value.permissions.includes(u), W = (u, y) => {
|
|
202
|
+
y && !j(u) && (p.value.permissions = [...p.value.permissions, u]), y || (p.value.permissions = p.value.permissions.filter((F) => F !== u));
|
|
203
|
+
}, N = g(
|
|
204
|
+
() => p.value.permissions.length === 0 ? i("approvalCode.form.permissionsRequired") : ""
|
|
205
|
+
), f = g(() => j("discount") ? Ne(B.value) ? "" : i("approvalCode.form.discountMaxPercentageInvalid") : "");
|
|
206
|
+
async function P() {
|
|
207
|
+
if (N.value) {
|
|
208
|
+
V.open({ message: N.value, type: "error" });
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (f.value) {
|
|
212
|
+
V.open({ message: f.value, type: "error" });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const u = await w.minor(
|
|
216
|
+
async () => n.createApprovalCodes({
|
|
217
|
+
name: p.value.name,
|
|
218
|
+
restaurantId: p.value.restaurantId,
|
|
219
|
+
count: Number(p.value.count),
|
|
220
|
+
permissions: Me(p.value.permissions, B.value)
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
V.open({
|
|
224
|
+
message: u.length === 1 ? i("approvalCode.create.successMessage", { passcode: u[0].passcode }) : i("approvalCode.create.successMessageBulk", { count: u.length }),
|
|
225
|
+
type: "success"
|
|
226
|
+
}), A.value = !1, v("created", u);
|
|
227
|
+
}
|
|
228
|
+
return r({
|
|
229
|
+
show: A,
|
|
230
|
+
trigger: I
|
|
231
|
+
}), (u, y) => {
|
|
232
|
+
const F = b("FmTextField"), G = b("FmSelect"), J = b("FmCheckbox"), Q = b("FmStepperField"), X = b("fm-button"), ae = b("fm-side-sheet");
|
|
233
|
+
return _(), S(H, null, [
|
|
234
|
+
xe(u.$slots, "default", { trigger: I }),
|
|
235
|
+
c(ae, {
|
|
236
|
+
id: "approval-code-form",
|
|
237
|
+
modelValue: A.value,
|
|
238
|
+
"onUpdate:modelValue": y[5] || (y[5] = (m) => A.value = m),
|
|
239
|
+
"is-container": a(z).FmForm,
|
|
240
|
+
"is-container-props": {
|
|
241
|
+
onValidationSuccess: P,
|
|
242
|
+
blameFormChildOnValidationFailed: !0
|
|
243
|
+
},
|
|
244
|
+
"max-width": 560
|
|
245
|
+
}, {
|
|
246
|
+
"side-sheet-header": $(() => [
|
|
247
|
+
s("p", Ye, C(U.value), 1)
|
|
248
|
+
]),
|
|
249
|
+
"side-sheet-footer": $(() => [
|
|
250
|
+
s("div", Qe, [
|
|
251
|
+
c(X, {
|
|
252
|
+
label: T.value,
|
|
253
|
+
size: "lg",
|
|
254
|
+
type: "submit",
|
|
255
|
+
variant: "primary"
|
|
256
|
+
}, null, 8, ["label"]),
|
|
257
|
+
c(X, {
|
|
258
|
+
label: a(i)("common.cancel"),
|
|
259
|
+
size: "lg",
|
|
260
|
+
variant: "tertiary",
|
|
261
|
+
onClick: y[4] || (y[4] = () => A.value = !1)
|
|
262
|
+
}, null, 8, ["label"])
|
|
263
|
+
])
|
|
264
|
+
]),
|
|
265
|
+
default: $(() => [
|
|
266
|
+
s("div", He, [
|
|
267
|
+
c(Be, {
|
|
268
|
+
title: a(i)("approvalCode.form.section")
|
|
269
|
+
}, {
|
|
270
|
+
default: $(() => [
|
|
271
|
+
c(F, {
|
|
272
|
+
modelValue: p.value.name,
|
|
273
|
+
"onUpdate:modelValue": y[0] || (y[0] = (m) => p.value.name = m),
|
|
274
|
+
label: a(i)("approvalCode.form.name"),
|
|
275
|
+
placeholder: a(i)("approvalCode.form.namePlaceholder"),
|
|
276
|
+
rules: [(m) => !!m || a(i)("approvalCode.form.nameRequired")]
|
|
277
|
+
}, null, 8, ["modelValue", "label", "placeholder", "rules"]),
|
|
278
|
+
c(pe, {
|
|
279
|
+
label: a(i)("approvalCode.form.restaurant")
|
|
280
|
+
}, {
|
|
281
|
+
default: $(() => [
|
|
282
|
+
c(G, {
|
|
283
|
+
modelValue: p.value.restaurantId,
|
|
284
|
+
"onUpdate:modelValue": y[1] || (y[1] = (m) => p.value.restaurantId = m),
|
|
285
|
+
items: E.value,
|
|
286
|
+
placeholder: a(i)("approvalCode.form.selectRestaurant"),
|
|
287
|
+
rules: [(m) => !!m || a(i)("approvalCode.form.restaurantRequired")]
|
|
288
|
+
}, null, 8, ["modelValue", "items", "placeholder", "rules"])
|
|
289
|
+
]),
|
|
290
|
+
_: 1
|
|
291
|
+
}, 8, ["label"]),
|
|
292
|
+
c(pe, {
|
|
293
|
+
label: a(i)("approvalCode.form.permissions")
|
|
294
|
+
}, {
|
|
295
|
+
default: $(() => [
|
|
296
|
+
s("div", We, [
|
|
297
|
+
(_(!0), S(H, null, te(a(oe), (m) => (_(), S("div", {
|
|
298
|
+
key: m.key
|
|
299
|
+
}, [
|
|
300
|
+
s("div", Ge, [
|
|
301
|
+
c(J, {
|
|
302
|
+
"model-value": j(m.key),
|
|
303
|
+
value: m.key,
|
|
304
|
+
size: "sm",
|
|
305
|
+
dense: "",
|
|
306
|
+
"onUpdate:modelValue": (t) => W(m.key, t)
|
|
307
|
+
}, null, 8, ["model-value", "value", "onUpdate:modelValue"]),
|
|
308
|
+
s("span", null, C(a(i)(`approvalCode.permissions.${m.key}`)), 1)
|
|
309
|
+
]),
|
|
310
|
+
m.key === "discount" && j("discount") ? (_(), S("div", Xe, [
|
|
311
|
+
c(F, {
|
|
312
|
+
modelValue: B.value,
|
|
313
|
+
"onUpdate:modelValue": y[2] || (y[2] = (t) => B.value = t),
|
|
314
|
+
type: "number",
|
|
315
|
+
class: "max-w-[200px]",
|
|
316
|
+
label: a(i)("approvalCode.form.discountMaxPercentage")
|
|
317
|
+
}, null, 8, ["modelValue", "label"]),
|
|
318
|
+
f.value ? (_(), S("p", Ze, C(f.value), 1)) : Y("", !0)
|
|
319
|
+
])) : Y("", !0)
|
|
320
|
+
]))), 128)),
|
|
321
|
+
N.value ? (_(), S("p", Je, C(N.value), 1)) : Y("", !0)
|
|
322
|
+
])
|
|
323
|
+
]),
|
|
324
|
+
_: 1
|
|
325
|
+
}, 8, ["label"]),
|
|
326
|
+
c(Q, {
|
|
327
|
+
modelValue: p.value.count,
|
|
328
|
+
"onUpdate:modelValue": y[3] || (y[3] = (m) => p.value.count = m),
|
|
329
|
+
inputmode: "numeric",
|
|
330
|
+
"show-steppers": "",
|
|
331
|
+
min: 1,
|
|
332
|
+
max: 10,
|
|
333
|
+
label: a(i)("approvalCode.form.count"),
|
|
334
|
+
rules: [
|
|
335
|
+
(m) => Number.isInteger(Number(m)) && Number(m) >= 1 && Number(m) <= 10 || a(i)("approvalCode.form.countRange")
|
|
336
|
+
]
|
|
337
|
+
}, null, 8, ["modelValue", "label", "rules"])
|
|
338
|
+
]),
|
|
339
|
+
_: 1
|
|
340
|
+
}, 8, ["title"])
|
|
341
|
+
])
|
|
342
|
+
]),
|
|
343
|
+
_: 1
|
|
344
|
+
}, 8, ["modelValue", "is-container", "is-container-props"])
|
|
345
|
+
], 64);
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
}), tt = {
|
|
349
|
+
class: "space-y-8"
|
|
350
|
+
}, ot = {
|
|
351
|
+
class: "xs:hidden flex w-full items-start justify-between"
|
|
352
|
+
}, at = {
|
|
353
|
+
class: "flex items-start gap-8"
|
|
354
|
+
}, lt = {
|
|
355
|
+
class: "space-y-4 hidden xs:block"
|
|
356
|
+
}, st = {
|
|
357
|
+
class: "px-16"
|
|
358
|
+
}, rt = {
|
|
359
|
+
class: "px-16 flex items-start gap-8"
|
|
360
|
+
}, nt = {
|
|
361
|
+
class: "pb-64 hidden xs:block"
|
|
362
|
+
}, it = {
|
|
363
|
+
class: "space-y-4"
|
|
364
|
+
}, ct = {
|
|
365
|
+
class: "flex items-center gap-8"
|
|
366
|
+
}, ut = {
|
|
367
|
+
class: "fm-typo-en-body-lg-600"
|
|
368
|
+
}, dt = {
|
|
369
|
+
class: "font-mono text-lg font-bold mr-4"
|
|
370
|
+
}, pt = {
|
|
371
|
+
class: "text-fm-color-typo-secondary"
|
|
372
|
+
}, mt = {
|
|
373
|
+
class: "flex flex-wrap gap-4 mt-4"
|
|
374
|
+
}, vt = {
|
|
375
|
+
class: "mt-4 space-y-2"
|
|
376
|
+
}, ft = {
|
|
377
|
+
class: "text-xs"
|
|
378
|
+
}, yt = {
|
|
379
|
+
class: "text-xs"
|
|
380
|
+
}, _t = {
|
|
381
|
+
key: 0,
|
|
382
|
+
class: "text-xs"
|
|
383
|
+
}, Ct = {
|
|
384
|
+
class: "flex flex-col gap-4"
|
|
385
|
+
}, me = 10, gt = 2, It = /* @__PURE__ */ re({
|
|
386
|
+
__name: "ApprovalCodeList",
|
|
387
|
+
setup(d, {
|
|
388
|
+
expose: r
|
|
389
|
+
}) {
|
|
390
|
+
const {
|
|
391
|
+
t: e
|
|
392
|
+
} = ne(), v = (t) => Ve(t).format("DD/MM/YYYY, h:mm:ss A"), n = K(), h = K(), V = K(), w = fe(), {
|
|
393
|
+
restaurants: i
|
|
394
|
+
} = ce(), A = g(() => oe.map((t) => ({
|
|
395
|
+
label: e(`approvalCode.permissions.${t.key}`),
|
|
396
|
+
value: t.key
|
|
397
|
+
}))), M = g(() => w.approvalCodes), {
|
|
398
|
+
searchKey: p,
|
|
399
|
+
filter: B
|
|
400
|
+
} = Se(), I = g(() => {
|
|
401
|
+
const t = {};
|
|
402
|
+
return i.value.forEach((o) => {
|
|
403
|
+
t[o._id] = o.profile.name;
|
|
404
|
+
}), t;
|
|
405
|
+
}), U = (t) => ye(t.permissions, e), T = g(() => {
|
|
406
|
+
var t;
|
|
407
|
+
return (t = M.value) == null ? void 0 : t.filter((o) => {
|
|
408
|
+
const k = !n.value || n.value.includes(o.restaurantId), D = !h.value || h.value.includes(o.status), R = I.value[o.restaurantId] || "";
|
|
409
|
+
return k && D && Te(o, V.value) && B([o.passcode, o.name, R, o.grantByName, ...U(o)]);
|
|
410
|
+
});
|
|
411
|
+
}), E = (t) => {
|
|
412
|
+
switch (t) {
|
|
413
|
+
case "active":
|
|
414
|
+
return "bg-fm-color-system-success-100 text-fm-color-typo-success";
|
|
415
|
+
case "used":
|
|
416
|
+
return "bg-fm-color-typo-tertiary text-fm-color-typo-primary";
|
|
417
|
+
case "revoked":
|
|
418
|
+
return "bg-fm-color-system-error-100 text-fm-color-typo-error";
|
|
419
|
+
default:
|
|
420
|
+
return "bg-fm-color-typo-secondary text-fm-color-typo-primary";
|
|
421
|
+
}
|
|
422
|
+
}, j = (t) => e(`approvalCode.status.${t}`), W = [{
|
|
423
|
+
accessorKey: "passcode",
|
|
424
|
+
size: 120,
|
|
425
|
+
maxSize: 120,
|
|
426
|
+
minSize: 120,
|
|
427
|
+
header: () => e("approvalCode.columns.passcode"),
|
|
428
|
+
cell(t) {
|
|
429
|
+
const o = t.row.original;
|
|
430
|
+
return x("div", {
|
|
431
|
+
class: "flex items-center gap-8"
|
|
432
|
+
}, [x(z.FmButton, {
|
|
433
|
+
variant: se.Tertiary,
|
|
434
|
+
textColor: "neutral-gray-400",
|
|
435
|
+
icon: "content_copy",
|
|
436
|
+
onClick: (k) => {
|
|
437
|
+
k.stopPropagation(), m(o);
|
|
438
|
+
}
|
|
439
|
+
}), x("span", {
|
|
440
|
+
class: "font-mono text-lg font-bold"
|
|
441
|
+
}, o.passcode)]);
|
|
442
|
+
}
|
|
443
|
+
}, {
|
|
444
|
+
accessorKey: "name",
|
|
445
|
+
header: () => e("approvalCode.columns.name"),
|
|
446
|
+
enableSorting: !1
|
|
447
|
+
}, {
|
|
448
|
+
accessorKey: "permissions",
|
|
449
|
+
header: () => e("approvalCode.columns.permissions"),
|
|
450
|
+
enableSorting: !1,
|
|
451
|
+
cell(t) {
|
|
452
|
+
const o = t.row.original, k = U(o), D = k.slice(0, gt), R = k.length - D.length, Z = x("div", {
|
|
453
|
+
class: "flex flex-wrap gap-4 py-8"
|
|
454
|
+
}, [...D.map((le) => x(z.FmChip, {
|
|
455
|
+
label: le
|
|
456
|
+
})), ...R > 0 ? [x(z.FmChip, {
|
|
457
|
+
label: `+${R}`
|
|
458
|
+
})] : []]);
|
|
459
|
+
return R === 0 ? Z : x(z.FmTooltip, {
|
|
460
|
+
variant: "plain",
|
|
461
|
+
placement: "top"
|
|
462
|
+
}, {
|
|
463
|
+
default: () => Z,
|
|
464
|
+
content: () => x("div", k.join(", "))
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}, {
|
|
468
|
+
accessorKey: "restaurantName",
|
|
469
|
+
accessorFn: (t) => I.value[t.restaurantId],
|
|
470
|
+
header: () => e("approvalCode.columns.restaurant"),
|
|
471
|
+
enableSorting: !1,
|
|
472
|
+
meta: {
|
|
473
|
+
width: "220px"
|
|
474
|
+
},
|
|
475
|
+
cell(t) {
|
|
476
|
+
return x("div", I.value[t.row.original.restaurantId] || "-");
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
accessorKey: "status",
|
|
480
|
+
header: () => e("approvalCode.columns.status"),
|
|
481
|
+
enableSorting: !1,
|
|
482
|
+
meta: {
|
|
483
|
+
maxWidth: "120px"
|
|
484
|
+
},
|
|
485
|
+
cell(t) {
|
|
486
|
+
const o = t.row.original.status;
|
|
487
|
+
return x(z.FmChip, {
|
|
488
|
+
label: j(o),
|
|
489
|
+
class: E(o)
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}, {
|
|
493
|
+
accessorKey: "createdAt",
|
|
494
|
+
header: () => e("approvalCode.columns.createdAt"),
|
|
495
|
+
cell(t) {
|
|
496
|
+
const o = t.row.original.createdAt;
|
|
497
|
+
return x("div", v(o));
|
|
498
|
+
}
|
|
499
|
+
}, {
|
|
500
|
+
id: "resolvedAt",
|
|
501
|
+
accessorFn: (t) => ee(t) ?? "",
|
|
502
|
+
header: () => e("approvalCode.columns.resolvedAt"),
|
|
503
|
+
cell(t) {
|
|
504
|
+
const o = ee(t.row.original);
|
|
505
|
+
return x("div", o ? v(o) : "-");
|
|
506
|
+
}
|
|
507
|
+
}, {
|
|
508
|
+
accessorKey: "grantByName",
|
|
509
|
+
header: () => e("approvalCode.columns.grantedBy"),
|
|
510
|
+
enableSorting: !1,
|
|
511
|
+
cell(t) {
|
|
512
|
+
return x("div", t.row.original.grantByName);
|
|
513
|
+
}
|
|
514
|
+
}, {
|
|
515
|
+
id: "action",
|
|
516
|
+
size: 140,
|
|
517
|
+
minSize: 140,
|
|
518
|
+
enableSorting: !1,
|
|
519
|
+
meta: {
|
|
520
|
+
cellClass: "p-16",
|
|
521
|
+
headerContentClass: "-mx-16"
|
|
522
|
+
},
|
|
523
|
+
cell: (t) => {
|
|
524
|
+
const o = t.row.original, k = [];
|
|
525
|
+
return o.status === "active" && k.push(x(z.FmButton, {
|
|
526
|
+
label: e("approvalCode.actions.revoke"),
|
|
527
|
+
variant: se.Secondary,
|
|
528
|
+
onClick: (D) => {
|
|
529
|
+
D.stopPropagation(), G(o);
|
|
530
|
+
}
|
|
531
|
+
})), x("div", {
|
|
532
|
+
class: "w-full flex justify-end items-center gap-4"
|
|
533
|
+
}, k);
|
|
534
|
+
}
|
|
535
|
+
}], N = ie(), f = we(), P = ve(N), u = K(), y = K(), {
|
|
536
|
+
breakpoints: F
|
|
537
|
+
} = Fe(), G = (t) => {
|
|
538
|
+
f.open({
|
|
539
|
+
title: e("approvalCode.revoke.title"),
|
|
540
|
+
message: e("approvalCode.revoke.message", {
|
|
541
|
+
name: t.name
|
|
542
|
+
}),
|
|
543
|
+
minWidth: F.value.lg ? 588 : 0,
|
|
544
|
+
primaryActions: {
|
|
545
|
+
text: e("approvalCode.actions.revoke"),
|
|
546
|
+
close: !1,
|
|
547
|
+
variant: "destructive"
|
|
548
|
+
},
|
|
549
|
+
secondaryActions: {
|
|
550
|
+
text: e("common.cancel"),
|
|
551
|
+
close: !0
|
|
552
|
+
}
|
|
553
|
+
}).onPrimary(async () => {
|
|
554
|
+
P.minor(async () => {
|
|
555
|
+
await w.revokeApprovalCode(t._id, t.restaurantId);
|
|
556
|
+
}, {
|
|
557
|
+
successMessage: e("approvalCode.revoke.successMessage", {
|
|
558
|
+
name: t.name
|
|
559
|
+
})
|
|
560
|
+
}), f.close();
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
function J() {
|
|
564
|
+
var t;
|
|
565
|
+
(t = u.value) == null || t.trigger();
|
|
566
|
+
}
|
|
567
|
+
const Q = g(() => [{
|
|
568
|
+
label: e("approvalCode.status.active"),
|
|
569
|
+
value: "active"
|
|
570
|
+
}, {
|
|
571
|
+
label: e("approvalCode.status.used"),
|
|
572
|
+
value: "used"
|
|
573
|
+
}, {
|
|
574
|
+
label: e("approvalCode.status.revoked"),
|
|
575
|
+
value: "revoked"
|
|
576
|
+
}]), X = g(() => i.value.map((t) => ({
|
|
577
|
+
label: `${t.profile.code ? `${t.profile.code} - ` : ""}${t.profile.name}`,
|
|
578
|
+
value: t._id
|
|
579
|
+
})));
|
|
580
|
+
function ae(t) {
|
|
581
|
+
return Ce(t, I.value[t.restaurantId], e);
|
|
582
|
+
}
|
|
583
|
+
async function m(t) {
|
|
584
|
+
try {
|
|
585
|
+
await navigator.clipboard.writeText(ae(t)), N.open({
|
|
586
|
+
message: e("approvalCode.passcode.copied"),
|
|
587
|
+
type: "success"
|
|
588
|
+
});
|
|
589
|
+
} catch (o) {
|
|
590
|
+
N.open({
|
|
591
|
+
message: String(o),
|
|
592
|
+
type: "error"
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return r({
|
|
597
|
+
create: J,
|
|
598
|
+
filteredApprovalCodes: T
|
|
599
|
+
}), (t, o) => {
|
|
600
|
+
const k = b("FmSearch"), D = b("FmTable"), R = b("FmButton"), Z = b("FmChip"), le = b("FmListItem"), he = b("FmList");
|
|
601
|
+
return _(), S(H, null, [c(et, {
|
|
602
|
+
ref_key: "approvalCodeFormRef",
|
|
603
|
+
ref: u,
|
|
604
|
+
class: "gap-8",
|
|
605
|
+
onCreated: o[0] || (o[0] = (l) => {
|
|
606
|
+
var L;
|
|
607
|
+
return (L = y.value) == null ? void 0 : L.open(l);
|
|
608
|
+
})
|
|
609
|
+
}, null, 512), c(qe, {
|
|
610
|
+
ref_key: "createdDialogRef",
|
|
611
|
+
ref: y,
|
|
612
|
+
onCreateAnother: J
|
|
613
|
+
}, null, 512), s("div", tt, [s("div", ot, [s("div", at, [c(q, {
|
|
614
|
+
modelValue: V.value,
|
|
615
|
+
"onUpdate:modelValue": o[1] || (o[1] = (l) => V.value = l),
|
|
616
|
+
multiple: "",
|
|
617
|
+
variant: "dark",
|
|
618
|
+
items: A.value,
|
|
619
|
+
"selected-prefix": a(e)("approvalCode.filter.selected_action_prefix"),
|
|
620
|
+
placeholder: a(e)("approvalCode.filter.action_placeholder"),
|
|
621
|
+
class: "!w-auto"
|
|
622
|
+
}, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(q, {
|
|
623
|
+
modelValue: n.value,
|
|
624
|
+
"onUpdate:modelValue": o[2] || (o[2] = (l) => n.value = l),
|
|
625
|
+
multiple: "",
|
|
626
|
+
items: X.value,
|
|
627
|
+
variant: "dark",
|
|
628
|
+
"selected-prefix": a(e)("approvalCode.columns.restaurant"),
|
|
629
|
+
placeholder: a(e)("approvalCode.columns.restaurant"),
|
|
630
|
+
class: "!w-auto"
|
|
631
|
+
}, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(q, {
|
|
632
|
+
modelValue: h.value,
|
|
633
|
+
"onUpdate:modelValue": o[3] || (o[3] = (l) => h.value = l),
|
|
634
|
+
multiple: "",
|
|
635
|
+
variant: "dark",
|
|
636
|
+
items: Q.value,
|
|
637
|
+
"selected-prefix": a(e)("approvalCode.filter.selected_status_prefix"),
|
|
638
|
+
placeholder: a(e)("approvalCode.filter.status_placeholder")
|
|
639
|
+
}, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), c(k, {
|
|
640
|
+
modelValue: a(p),
|
|
641
|
+
"onUpdate:modelValue": o[4] || (o[4] = (l) => ue(p) ? p.value = l : null),
|
|
642
|
+
autofocus: "",
|
|
643
|
+
class: "pl-4 w-[320px]",
|
|
644
|
+
placeholder: a(e)("approvalCode.search.placeholder")
|
|
645
|
+
}, null, 8, ["modelValue", "placeholder"])]), s("div", lt, [s("div", st, [c(k, {
|
|
646
|
+
modelValue: a(p),
|
|
647
|
+
"onUpdate:modelValue": o[5] || (o[5] = (l) => ue(p) ? p.value = l : null),
|
|
648
|
+
autofocus: "",
|
|
649
|
+
placeholder: a(e)("approvalCode.search.placeholder")
|
|
650
|
+
}, null, 8, ["modelValue", "placeholder"])]), c(Ae), s("div", rt, [c(q, {
|
|
651
|
+
modelValue: V.value,
|
|
652
|
+
"onUpdate:modelValue": o[6] || (o[6] = (l) => V.value = l),
|
|
653
|
+
multiple: "",
|
|
654
|
+
variant: "dark",
|
|
655
|
+
items: A.value,
|
|
656
|
+
"selected-prefix": a(e)("approvalCode.filter.selected_action_prefix"),
|
|
657
|
+
placeholder: a(e)("approvalCode.filter.action_placeholder"),
|
|
658
|
+
class: "!w-auto"
|
|
659
|
+
}, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(q, {
|
|
660
|
+
modelValue: n.value,
|
|
661
|
+
"onUpdate:modelValue": o[7] || (o[7] = (l) => n.value = l),
|
|
662
|
+
multiple: "",
|
|
663
|
+
items: X.value,
|
|
664
|
+
variant: "dark",
|
|
665
|
+
"selected-prefix": a(e)("approvalCode.columns.restaurant"),
|
|
666
|
+
placeholder: a(e)("approvalCode.columns.restaurant"),
|
|
667
|
+
class: "!w-auto"
|
|
668
|
+
}, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(q, {
|
|
669
|
+
modelValue: h.value,
|
|
670
|
+
"onUpdate:modelValue": o[8] || (o[8] = (l) => h.value = l),
|
|
671
|
+
multiple: "",
|
|
672
|
+
variant: "dark",
|
|
673
|
+
items: Q.value,
|
|
674
|
+
"selected-prefix": a(e)("approvalCode.filter.selected_status_prefix"),
|
|
675
|
+
placeholder: a(e)("approvalCode.filter.status_placeholder")
|
|
676
|
+
}, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])]), M.value.length > 0 || a(w).isLoading ? (_(), O($e, {
|
|
677
|
+
key: 0,
|
|
678
|
+
class: "overflow-auto"
|
|
679
|
+
}, {
|
|
680
|
+
default: $(() => [c(D, {
|
|
681
|
+
class: "xs:hidden",
|
|
682
|
+
"column-defs": W,
|
|
683
|
+
"row-data": T.value,
|
|
684
|
+
"page-size": me,
|
|
685
|
+
"hide-footer": T.value.length <= me,
|
|
686
|
+
loading: a(w).isLoading,
|
|
687
|
+
virtual: !1,
|
|
688
|
+
"pin-header-row": ""
|
|
689
|
+
}, null, 8, ["row-data", "hide-footer", "loading"]), s("div", nt, [c(he, {
|
|
690
|
+
separator: ""
|
|
691
|
+
}, {
|
|
692
|
+
default: $(() => [(_(!0), S(H, null, te(T.value, (l) => (_(), O(le, {
|
|
693
|
+
key: l._id,
|
|
694
|
+
class: "py-12 px-16 items-center justify-between"
|
|
695
|
+
}, {
|
|
696
|
+
default: $(() => [s("div", it, [s("div", ct, [c(R, {
|
|
697
|
+
variant: "tertiary",
|
|
698
|
+
"text-color": "neutral-gray-400",
|
|
699
|
+
icon: "content_copy",
|
|
700
|
+
onClick: de((L) => m(l), ["stop"])
|
|
701
|
+
}, null, 8, ["onClick"]), s("p", ut, [s("span", dt, C(l.passcode), 1), be(" - " + C(l.name), 1)])]), s("div", pt, [s("div", null, C(I.value[l.restaurantId] || "-"), 1), s("div", mt, [(_(!0), S(H, null, te(U(l), (L) => (_(), O(Z, {
|
|
702
|
+
key: L,
|
|
703
|
+
label: L
|
|
704
|
+
}, null, 8, ["label"]))), 128))]), s("div", vt, [s("div", ft, C(a(e)("approvalCode.columns.grantedBy")) + ": " + C(l.grantByName), 1), s("div", yt, C(a(e)("approvalCode.columns.createdAt")) + ": " + C(v(l.createdAt)), 1), a(ee)(l) ? (_(), S("div", _t, C(a(e)("approvalCode.columns.resolvedAt")) + ": " + C(v(a(ee)(l))), 1)) : Y("", !0), c(Z, {
|
|
705
|
+
label: j(l.status),
|
|
706
|
+
class: ke(E(l.status))
|
|
707
|
+
}, null, 8, ["label", "class"])])])]), s("div", Ct, [l.status === "active" ? (_(), O(R, {
|
|
708
|
+
key: 0,
|
|
709
|
+
label: a(e)("approvalCode.actions.revoke"),
|
|
710
|
+
variant: a(se).Secondary,
|
|
711
|
+
onClick: de((L) => G(l), ["stop"])
|
|
712
|
+
}, null, 8, ["label", "variant", "onClick"])) : Y("", !0)])]),
|
|
713
|
+
_: 2
|
|
714
|
+
}, 1024))), 128))]),
|
|
715
|
+
_: 1
|
|
716
|
+
})])]),
|
|
717
|
+
_: 1
|
|
718
|
+
})) : (_(), O(a(Pe), {
|
|
719
|
+
key: 1,
|
|
720
|
+
title: a(e)("approvalCode.noData.title"),
|
|
721
|
+
subtitle: a(e)("approvalCode.noData.subtitle")
|
|
722
|
+
}, null, 8, ["title", "subtitle"]))])], 64);
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
export {
|
|
727
|
+
It as default
|
|
728
|
+
};
|