@feedmepos/mf-connect 0.0.39-prod → 0.1.0-beta.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 (101) hide show
  1. package/dist/Analytic-DSD9TsKr.js +622 -0
  2. package/dist/{App-X3fNEBF3.js → App-D8a5eW51.js} +250 -249
  3. package/dist/Broadcast-C8jgMe6g.js +223 -0
  4. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CRYS_tzZ.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-pG8WvV4I.js} +20 -20
  5. package/dist/Card-C1K7ULPo.js +825 -0
  6. package/dist/Collections-lMrdPUuM.js +453 -0
  7. package/dist/Credit-CJfU5tP4.js +220 -0
  8. package/dist/{EditCampaignSheet.vue_vue_type_script_setup_true_lang-DoZyevfa.js → EditCampaignSheet.vue_vue_type_script_setup_true_lang-BYoaa_-x.js} +1042 -1011
  9. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CzEtOmp0.js +345 -0
  10. package/dist/Experience-Bp2ki8gU.js +221 -0
  11. package/dist/Game-BpTf6ebE.js +255 -0
  12. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-rWUkV9gn.js +144 -0
  13. package/dist/{MainLayout-DpZC6o3R.js → LottieAnimation.vue_vue_type_script_setup_true_lang-CyGJxUol.js} +19 -53
  14. package/dist/MainLayout-B1aJoR95.js +41 -0
  15. package/dist/Marketing-BiKE2gxA.js +316 -0
  16. package/dist/Member-BSWyy32a.js +69 -0
  17. package/dist/MemberList-CHlGREyR.js +1733 -0
  18. package/dist/MemberOverview-wL_ailso.js +58 -0
  19. package/dist/{MemberTransactions-DueaXBCy.js → MemberTransactions-BzHiXCnp.js} +1 -1
  20. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-e-zWg08J.js +432 -0
  21. package/dist/Mission-8IGT3T2C.js +261 -0
  22. package/dist/Point-CbbJ6ohd.js +222 -0
  23. package/dist/Promotion-BYXCJa_S.js +247 -0
  24. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-_RX1J0Br.js → RuleGroup.vue_vue_type_script_setup_true_lang-Bruh-umZ.js} +557 -557
  25. package/dist/Segment-DXDNM0yd.js +437 -0
  26. package/dist/Setting-CLpvvZTv.js +1901 -0
  27. package/dist/Store-C6-P6bwc.js +1511 -0
  28. package/dist/StoreRewards-CUM2irXK.js +401 -0
  29. package/dist/{StoreTransactions.vue_vue_type_script_setup_true_lang-CLFiuO5k.js → StoreTransactions.vue_vue_type_script_setup_true_lang-JaRdmqif.js} +10 -10
  30. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-CoMQBL4P.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-DEb4OBcX.js} +1 -1
  31. package/dist/{Tier-CftEoP_R.js → Tier-DZTDxWBo.js} +481 -453
  32. package/dist/{Title-BsavXbYh.js → Title-C2Dr5ceK.js} +314 -295
  33. package/dist/Transaction-BL4mS29d.js +39 -0
  34. package/dist/Voucher-Cx0r2-df.js +490 -0
  35. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-DWuAODUF.js +56 -0
  36. package/dist/{app-BNmAx3zq.js → app-B_xuZ5HB.js} +1 -1
  37. package/dist/app-wE5HTF_Y.js +5762 -0
  38. package/dist/app.js +5 -3
  39. package/dist/{business-DGL4Ayx0.js → business-DSv8zM8C.js} +1 -1
  40. package/dist/{campaign-D94sS1kM.js → campaign-7y5qquHZ.js} +5 -3
  41. package/dist/{collection.fn-BHJ1ISqO.js → collection.fn-BxVZQAx0.js} +2 -2
  42. package/dist/dto-Ew1QwLci.js +2778 -0
  43. package/dist/{effect-CFRICzlM.js → effect-BzPh8fRI.js} +9 -9
  44. package/dist/{export-w2o9NYcy.js → export-C9tDplkA.js} +3 -3
  45. package/dist/{helper-CUDWQ8vq.js → helper-Sz7oQ0F4.js} +1 -1
  46. package/dist/{index-BGuLhEym.js → index-BQm0C3Jm.js} +3 -3
  47. package/dist/{index-BjwyxNSp.js → index-C-SOz7jt.js} +1 -1
  48. package/dist/{index-BcWJcD9f.js → index-C0lpADCo.js} +1 -1
  49. package/dist/{index-DIq2KVis.js → index-C3_4GUiI.js} +1 -1
  50. package/dist/{index-BPEV5Tzg.js → index-D-2nFLsg.js} +59 -47
  51. package/dist/{index-CFMBSL24.js → index-DBMaUGYI.js} +2 -2
  52. package/dist/{index-CpwFQFTV.js → index-DH_1nOJ_.js} +3 -3
  53. package/dist/index-Dy4pmQpt.js +29193 -0
  54. package/dist/{index-BQ6isIeo.js → index-_3qBsogG.js} +1 -1
  55. package/dist/index-gIRszcHf.js +3 -0
  56. package/dist/{index-VjUw31dN.js → index-tv4t0Pnh.js} +1 -1
  57. package/dist/{index-tZ1aqhks.js → index-z0IfdrZk.js} +319 -281
  58. package/dist/{index.esm2017-zciuPty-.js → index.esm2017-BnKJDxUo.js} +55 -55
  59. package/dist/{loading-GuXe5bYG.js → loading-Ds-yFYhc.js} +469 -460
  60. package/dist/{membership-BHWJVI3e.js → membership-DaiVw9qF.js} +3 -3
  61. package/dist/money-BHtBdZoz.js +15 -0
  62. package/dist/number-CZhcB8ef.js +12 -0
  63. package/dist/{rule-MgNa_8FF.js → rule-Cd2M6Ri2.js} +2 -2
  64. package/dist/{rule-builder-BsBCWzq_.js → rule-builder-B6og27Q1.js} +1 -1
  65. package/dist/style.css +1 -1
  66. package/dist/{template-D6k3lusq.js → template-DouRWBpv.js} +63 -63
  67. package/dist/{usePagination-JoYaROkV.js → usePagination-BeF5K3M7.js} +85 -85
  68. package/dist/vue-i18n-BTlOChXs.js +2365 -0
  69. package/dist/{xlsx-ClrA4KOh.js → xlsx-SahfXQ70.js} +517 -517
  70. package/dist/zod-Bg2FbC-D.js +90 -0
  71. package/package.json +7 -4
  72. package/dist/Analytic-DMFueUju.js +0 -620
  73. package/dist/Broadcast-YIfWIXeA.js +0 -216
  74. package/dist/Card-BIxlgQm7.js +0 -824
  75. package/dist/Collections-M6DaHM2W.js +0 -441
  76. package/dist/Credit-BtRy-xoY.js +0 -214
  77. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-D5DNTBSQ.js +0 -344
  78. package/dist/Experience-DGm1lnqj.js +0 -211
  79. package/dist/Game-B8-lG7qq.js +0 -250
  80. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-ByhTB9Ie.js +0 -144
  81. package/dist/Marketing-DtG3AIWr.js +0 -309
  82. package/dist/Member-K443-9Vy.js +0 -92
  83. package/dist/MemberList-CYXHXFTL.js +0 -1735
  84. package/dist/MemberOverview-C2n9oJZh.js +0 -58
  85. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-Bk2HLVmt.js +0 -203
  86. package/dist/Mission-CN5umXXA.js +0 -248
  87. package/dist/Point-XAm6H2p_.js +0 -220
  88. package/dist/Promotion-DsrA4KiE.js +0 -244
  89. package/dist/Segment-CZGGHoAu.js +0 -435
  90. package/dist/Setting-BjfxLKyp.js +0 -1870
  91. package/dist/Store-D_B-vhh3.js +0 -1513
  92. package/dist/StoreRewards-BjHffUKj.js +0 -429
  93. package/dist/Transaction-CdxzoKDG.js +0 -36
  94. package/dist/Voucher-B_9Nv1Mr.js +0 -485
  95. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-3LlSDiq0.js +0 -140
  96. package/dist/app--1Ks5Hms.js +0 -2974
  97. package/dist/dto-X0Eeujxx.js +0 -1151
  98. package/dist/index-BPNG8N-w.js +0 -11
  99. package/dist/index-DWM9MWGj.js +0 -28058
  100. package/dist/money-CrttVpCp.js +0 -15
  101. package/dist/number-CIndGU4O.js +0 -12
@@ -0,0 +1,453 @@
1
+ var oe = Object.defineProperty;
2
+ var te = (f, r, u) => r in f ? oe(f, r, { enumerable: !0, configurable: !0, writable: !0, value: u }) : f[r] = u;
3
+ var $ = (f, r, u) => te(f, typeof r != "symbol" ? r + "" : r, u);
4
+ import { defineComponent as H, ref as p, computed as J, watch as O, resolveComponent as d, openBlock as y, createBlock as T, unref as o, isRef as K, withCtx as I, createElementVNode as b, createVNode as s, createElementBlock as R, Fragment as N, renderList as ae, createCommentVNode as P, onMounted as le, h as S } from "vue";
5
+ import { h as j } from "./moment-BWErdI6_.js";
6
+ import { components as G } from "@feedmepos/ui-library";
7
+ import { u as Q, a as ne } from "./loading-Ds-yFYhc.js";
8
+ import { J as se } from "./JsonViewer-v8_C7l5N.js";
9
+ import { u as re } from "./app-wDQR6dpb.js";
10
+ import { useRoute as W, useRouter as ie } from "vue-router";
11
+ import { c as A } from "./index-C-SOz7jt.js";
12
+ import { u as z, w as de } from "./xlsx-SahfXQ70.js";
13
+ import { u as ue, _ as ce } from "./usePagination-BeF5K3M7.js";
14
+ import { m as me } from "./index-C3_4GUiI.js";
15
+ import { o as pe } from "./objectId-dwaoBfJX.js";
16
+ const fe = { class: "space-y-16" }, ge = { class: "gap-16 grid grid-cols-2" }, be = { class: "flex items-center gap-8" }, Ce = /* @__PURE__ */ H({
17
+ __name: "CreateCollectionSheet",
18
+ emits: ["success"],
19
+ setup(f, { expose: r, emit: u }) {
20
+ const { minor: F } = Q, k = W(), _ = p(), B = p(!1), E = u, g = p(!1);
21
+ function q(t) {
22
+ g.value = t, t && (l.value = {
23
+ quantity: 1,
24
+ code: "",
25
+ codeConfig: {
26
+ length: 8,
27
+ charset: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
28
+ prefix: "",
29
+ suffix: "",
30
+ pattern: "########"
31
+ }
32
+ });
33
+ }
34
+ const l = p({
35
+ quantity: 1,
36
+ code: "",
37
+ codeConfig: {
38
+ length: 8,
39
+ charset: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
40
+ prefix: "",
41
+ suffix: "",
42
+ pattern: "########"
43
+ }
44
+ }), D = [
45
+ {
46
+ label: "Bulk codes",
47
+ value: "bulk",
48
+ sublabel: "Bulk generate unique codes"
49
+ },
50
+ {
51
+ label: "Custom code",
52
+ value: "single",
53
+ sublabel: "Enter your own custom codes"
54
+ }
55
+ ], U = [
56
+ {
57
+ label: "Alphanumeric",
58
+ value: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
59
+ },
60
+ {
61
+ label: "Alphabetic",
62
+ value: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
63
+ },
64
+ { label: "Alphabetic Lowercase", value: "abcdefghijklmnopqrstuvwxyz" },
65
+ { label: "Alphabetic Uppercase", value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
66
+ { label: "Numbers", value: "0123456789" },
67
+ { label: "Custom", value: "" }
68
+ ], C = p(U[0].value), c = p("bulk"), h = p(!1), M = J(() => k.params.id);
69
+ async function n(t) {
70
+ var e;
71
+ await ((e = _.value) == null ? void 0 : e.validateInputs()), B.value && await F(
72
+ async () => {
73
+ await A.createCollectionByCampaignId(M.value, t), await E("success");
74
+ },
75
+ {
76
+ message: "Creating claim(s)",
77
+ successMessage: "Claim(s) created"
78
+ }
79
+ );
80
+ }
81
+ return r({
82
+ showSheet: q
83
+ }), O(
84
+ () => c.value,
85
+ (t, e) => {
86
+ e != t && (l.value.code = "", l.value.codeConfig.length = 8, l.value.codeConfig.charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", l.value.codeConfig.prefix = "", l.value.codeConfig.suffix = "", l.value.codeConfig.pattern = "########");
87
+ }
88
+ ), O(
89
+ () => l.value.codeConfig.length,
90
+ (t, e) => {
91
+ t != e && (l.value.codeConfig.pattern = "#".repeat(Math.min(16, Number(t))));
92
+ }
93
+ ), (t, e) => {
94
+ const v = d("FmRadio"), i = d("FmRadioGroup"), V = d("FmSwitch"), L = d("FmStepperField"), w = d("FmSelect"), x = d("FmTextField"), X = d("FmTextarea"), Z = d("FmForm"), Y = d("FmButton"), ee = d("FmSideSheet");
95
+ return y(), T(ee, {
96
+ "max-width": 560,
97
+ "dismiss-away": !0,
98
+ header: "Create collection",
99
+ modelValue: o(g),
100
+ "onUpdate:modelValue": [
101
+ e[14] || (e[14] = (a) => K(g) ? g.value = a : null),
102
+ e[15] || (e[15] = (a) => g.value = a)
103
+ ]
104
+ }, {
105
+ "side-sheet-footer": I(() => [
106
+ b("div", be, [
107
+ s(Y, {
108
+ label: "Save",
109
+ onClick: e[12] || (e[12] = (a) => n(o(l))),
110
+ loading: o(re)().isLoading
111
+ }, null, 8, ["loading"]),
112
+ s(Y, {
113
+ label: "Cancel",
114
+ type: "button",
115
+ variant: "tertiary",
116
+ onClick: e[13] || (e[13] = (a) => g.value = !1)
117
+ })
118
+ ])
119
+ ]),
120
+ default: I(() => [
121
+ s(se, { json: o(l) }, null, 8, ["json"]),
122
+ s(Z, {
123
+ ref_key: "form",
124
+ ref: _,
125
+ class: "space-y-40",
126
+ onValidationSuccess: e[10] || (e[10] = (a) => B.value = !0),
127
+ onValidationFailed: e[11] || (e[11] = (a) => B.value = !1)
128
+ }, {
129
+ default: I(() => [
130
+ b("div", null, [
131
+ e[16] || (e[16] = b("div", { class: "fm-typo-en-body-lg-600" }, "Code type", -1)),
132
+ s(i, {
133
+ modelValue: o(c),
134
+ "onUpdate:modelValue": e[0] || (e[0] = (a) => K(c) ? c.value = a : null),
135
+ inline: !1
136
+ }, {
137
+ default: I(() => [
138
+ (y(), R(N, null, ae(D, (a) => s(v, {
139
+ key: a.value,
140
+ value: a.value,
141
+ label: a.label,
142
+ sublabel: a.sublabel
143
+ }, null, 8, ["value", "label", "sublabel"])), 64))
144
+ ]),
145
+ _: 1
146
+ }, 8, ["modelValue"])
147
+ ]),
148
+ b("div", fe, [
149
+ e[17] || (e[17] = b("div", { class: "fm-typo-en-body-lg-600" }, "Settings", -1)),
150
+ o(c) === "bulk" ? (y(), R(N, { key: 0 }, [
151
+ s(V, {
152
+ "model-value": o(h),
153
+ "label-placement": "right",
154
+ value: "true",
155
+ label: "Advance code setting",
156
+ required: !0,
157
+ "onUpdate:modelValue": e[1] || (e[1] = () => h.value = !o(h))
158
+ }, null, 8, ["model-value"]),
159
+ o(h) ? (y(), R(N, { key: 0 }, [
160
+ s(L, {
161
+ modelValue: o(l).codeConfig.length,
162
+ "onUpdate:modelValue": e[2] || (e[2] = (a) => o(l).codeConfig.length = a),
163
+ label: "Code length",
164
+ max: 16,
165
+ min: 1,
166
+ rules: [
167
+ (a) => Number(a) >= 1 || "Code length must at least 1",
168
+ (a) => Number(a) <= 16 || "Code length must less than 16"
169
+ ],
170
+ required: !0
171
+ }, null, 8, ["modelValue", "rules"]),
172
+ s(w, {
173
+ label: "Charset",
174
+ "model-value": o(C),
175
+ items: U,
176
+ "helper-text": o(l).codeConfig.charset.length > 62 ? `${o(l).codeConfig.charset.substring(0, 62)}...` : o(l).codeConfig.charset,
177
+ "onUpdate:modelValue": e[3] || (e[3] = (a) => {
178
+ C.value = a, o(l).codeConfig.charset = a;
179
+ })
180
+ }, null, 8, ["model-value", "helper-text"]),
181
+ o(C) === "" ? (y(), T(x, {
182
+ key: 0,
183
+ modelValue: o(l).codeConfig.charset,
184
+ "onUpdate:modelValue": e[4] || (e[4] = (a) => o(l).codeConfig.charset = a),
185
+ label: "Custom Charset",
186
+ required: ""
187
+ }, null, 8, ["modelValue"])) : P("", !0),
188
+ b("div", ge, [
189
+ s(x, {
190
+ modelValue: o(l).codeConfig.prefix,
191
+ "onUpdate:modelValue": e[5] || (e[5] = (a) => o(l).codeConfig.prefix = a),
192
+ label: "Prefix (Optional)"
193
+ }, null, 8, ["modelValue"]),
194
+ s(x, {
195
+ modelValue: o(l).codeConfig.suffix,
196
+ "onUpdate:modelValue": e[6] || (e[6] = (a) => o(l).codeConfig.suffix = a),
197
+ label: "Suffix (Optional)"
198
+ }, null, 8, ["modelValue"])
199
+ ]),
200
+ s(x, {
201
+ modelValue: o(l).codeConfig.pattern,
202
+ "onUpdate:modelValue": e[7] || (e[7] = (a) => o(l).codeConfig.pattern = a),
203
+ label: "Pattern",
204
+ required: !0
205
+ }, null, 8, ["modelValue"])
206
+ ], 64)) : P("", !0),
207
+ s(x, {
208
+ modelValue: o(l).quantity,
209
+ "onUpdate:modelValue": e[8] || (e[8] = (a) => o(l).quantity = a),
210
+ label: "Number of code",
211
+ rules: [
212
+ (a) => a >= 1 || "Quantity cannot be less than 1",
213
+ (a) => a <= 1e4 || "Quantity cannot more than 10,000"
214
+ ],
215
+ required: !0,
216
+ "helper-text": `${o(l).quantity} claim will be created`
217
+ }, null, 8, ["modelValue", "rules", "helper-text"])
218
+ ], 64)) : P("", !0),
219
+ o(c) !== "bulk" ? (y(), T(X, {
220
+ key: 1,
221
+ modelValue: o(l).code,
222
+ "onUpdate:modelValue": e[9] || (e[9] = (a) => o(l).code = a),
223
+ label: "Custom Code",
224
+ rules: [(a) => o(c) != "single" || !!a || "Custom code is required"],
225
+ placeholder: "(For multiple codes, please enter in the new row.)"
226
+ }, null, 8, ["modelValue", "rules"])) : P("", !0)
227
+ ])
228
+ ]),
229
+ _: 1
230
+ }, 512)
231
+ ]),
232
+ _: 1
233
+ }, 8, ["modelValue"]);
234
+ };
235
+ }
236
+ });
237
+ class ve {
238
+ constructor() {
239
+ $(this, "data", []);
240
+ }
241
+ addRecord(r) {
242
+ this.data.push(r);
243
+ }
244
+ buildExcel() {
245
+ const r = z.book_new(), u = z.json_to_sheet(this.data);
246
+ return z.book_append_sheet(r, u, "Collection"), r;
247
+ }
248
+ }
249
+ const m = {
250
+ sortBy: "_id",
251
+ descending: !1,
252
+ rowsPerPage: 1e3,
253
+ page: 1,
254
+ rowsNumber: 0
255
+ }, xe = { class: "px-24 flex flex-col gap-y-32 pb-24" }, ye = { class: "flex items-center justify-end py-4 xs:hidden" }, Ae = /* @__PURE__ */ H({
256
+ __name: "Collections",
257
+ setup(f) {
258
+ const r = ie(), u = W(), F = p(), k = J(() => u.params.id), _ = p(!1), { custom: B } = Q, E = [
259
+ {
260
+ header: "ID/Code",
261
+ accessorKey: "_id",
262
+ cell(n) {
263
+ return S("div", { class: "flex items-center" }, [
264
+ S(G.FmIcon, {
265
+ name: "content_copy",
266
+ outline: !0,
267
+ size: "sm",
268
+ class: "cursor-pointer mr-4",
269
+ onClick: (t) => {
270
+ t.preventDefault(), t.stopPropagation(), ne(
271
+ n.row.original.code || n.row.original._id.toString()
272
+ );
273
+ }
274
+ }),
275
+ S(
276
+ "div",
277
+ { class: "pr-2 text-ellipsis overflow-hidden" },
278
+ n.row.original.code || n.row.original._id.toString()
279
+ )
280
+ ]);
281
+ }
282
+ },
283
+ {
284
+ header: "User",
285
+ accessorKey: "user",
286
+ enableSorting: !1,
287
+ cell(n) {
288
+ const t = n.row.original.pf_user;
289
+ return S(
290
+ "div",
291
+ {
292
+ class: "flex items-center gap-x-8"
293
+ },
294
+ [
295
+ S(G.FmAvatar, {
296
+ name: t != null && t.photoUrl || t == null ? void 0 : t.name,
297
+ src: (t == null ? void 0 : t.photoUrl) ?? void 0,
298
+ size: "sm"
299
+ }),
300
+ S("span", t == null ? void 0 : t.name)
301
+ ]
302
+ );
303
+ }
304
+ },
305
+ {
306
+ header: "Phone",
307
+ accessorFn: (n) => {
308
+ var t;
309
+ return ((t = n.pf_user) == null ? void 0 : t.phoneNumber) || "-";
310
+ },
311
+ accessorKey: "pf_user.phoneNumber"
312
+ },
313
+ {
314
+ header: "Balance",
315
+ accessorKey: "balance"
316
+ },
317
+ {
318
+ header: "Created at",
319
+ accessorKey: "_id",
320
+ accessorFn: (n) => j(pe(n._id.toString())).format("DD MMM YYYY")
321
+ },
322
+ {
323
+ header: "Nearest expired at",
324
+ accessorKey: "expiryBalance",
325
+ accessorFn: (n) => {
326
+ var t;
327
+ return n.expiryBalance && n.expiryBalance.length ? j((t = n.expiryBalance) == null ? void 0 : t[0].expiredAt).format("DD MMM YYYY") : "Never expires";
328
+ }
329
+ }
330
+ ], g = {
331
+ "$connect-STORE_REWARD_COLLECTIONS": me.readCollectionsByRewardId,
332
+ "$connect-CAMPAIGN_VOUCHER_COLLECTIONS": A.readCollectionsByCampaignId
333
+ }, q = (n) => {
334
+ const t = g[u.name];
335
+ return (e) => t(n, e);
336
+ }, { tableMeta: l, rowData: D, onSort: U, debouncedFetchData: C, onSearch: c } = ue(q(k.value));
337
+ async function h() {
338
+ var n;
339
+ await C(), (n = F.value) == null || n.showSheet(!1);
340
+ }
341
+ async function M() {
342
+ _.value || B(
343
+ async () => {
344
+ var v;
345
+ const n = new ve(), t = (await A.readCollectionsByCampaignId(k.value, {
346
+ limit: 1,
347
+ skip: 0,
348
+ sortBy: m.sortBy,
349
+ descending: m.descending
350
+ })).meta.totalResources ?? 0, e = m.rowsPerPage;
351
+ for (let i = 0; i < t; i += e) {
352
+ const V = {
353
+ ...m,
354
+ limit: e,
355
+ skip: (m.page - 1) * m.rowsPerPage,
356
+ sortBy: m.sortBy,
357
+ descending: m.descending
358
+ }, L = await A.readCollectionsByCampaignId(
359
+ k.value,
360
+ V
361
+ );
362
+ for await (const w of L.resources) {
363
+ const x = {
364
+ Id: (w == null ? void 0 : w.code) || ((v = w._id) == null ? void 0 : v.toString()) || ""
365
+ };
366
+ n.addRecord(x);
367
+ }
368
+ m.page++;
369
+ }
370
+ await de(
371
+ n.buildExcel(),
372
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
373
+ {
374
+ bookType: "xlsx",
375
+ bookSST: !1,
376
+ type: "array"
377
+ }
378
+ ), m.page = 1;
379
+ },
380
+ {
381
+ isLoading: _
382
+ }
383
+ );
384
+ }
385
+ return le(async () => {
386
+ await C();
387
+ }), (n, t) => {
388
+ const e = d("FmPageHead"), v = d("FmSearch");
389
+ return y(), R(N, null, [
390
+ s(e, {
391
+ title: "Collections",
392
+ "back-button": !0,
393
+ actions: [
394
+ { label: "Export", value: "export", isPrimary: !1 },
395
+ {
396
+ label: "Create collection",
397
+ value: "create",
398
+ isPrimary: !0
399
+ }
400
+ ],
401
+ "onClick:back": t[0] || (t[0] = (i) => o(r).back()),
402
+ "onClick:action": t[1] || (t[1] = (i) => {
403
+ var V;
404
+ i === "create" && ((V = o(F)) == null || V.showSheet(!0)), i === "export" && M();
405
+ })
406
+ }),
407
+ b("div", xe, [
408
+ s(v, {
409
+ class: "hidden xs:flex border-b border-fm-color-neutral-gray-100",
410
+ modelValue: o(l).searchValue,
411
+ "onUpdate:modelValue": [
412
+ t[2] || (t[2] = (i) => o(l).searchValue = i),
413
+ o(c)
414
+ ],
415
+ placeholder: "Search",
416
+ collapsible: ""
417
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
418
+ b("div", ye, [
419
+ s(v, {
420
+ modelValue: o(l).searchValue,
421
+ "onUpdate:modelValue": [
422
+ t[3] || (t[3] = (i) => o(l).searchValue = i),
423
+ o(c)
424
+ ],
425
+ placeholder: "Search",
426
+ collapsible: ""
427
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])
428
+ ]),
429
+ s(ce, {
430
+ loading: o(l).isLoading,
431
+ "row-data": o(D),
432
+ "column-defs": E,
433
+ "row-count": o(l).totalRows,
434
+ "page-count": o(l).pageCount,
435
+ "page-index": o(l).pageIndex,
436
+ "page-size": o(l).pageSize,
437
+ "shrink-at": !1,
438
+ onSortChange: o(U),
439
+ onPageChange: t[4] || (t[4] = (i) => o(C)({ pageSize: i.pageSize, pageIndex: i.pageIndex }))
440
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
441
+ s(Ce, {
442
+ ref_key: "sheetRef",
443
+ ref: F,
444
+ onSuccess: h
445
+ }, null, 512)
446
+ ])
447
+ ], 64);
448
+ };
449
+ }
450
+ });
451
+ export {
452
+ Ae as default
453
+ };
@@ -0,0 +1,220 @@
1
+ import { defineComponent as N, ref as S, computed as j, h as M, onMounted as A, resolveComponent as l, openBlock as c, createElementBlock as y, Fragment as h, createVNode as i, unref as a, createElementVNode as n, withCtx as C, renderList as H, createBlock as v, resolveDynamicComponent as q, toDisplayString as g, createCommentVNode as z } from "vue";
2
+ import { _ as G } from "./campaign-CpzFl8Vr.js";
3
+ import { useDialog as J, components as O } from "@feedmepos/ui-library";
4
+ import { p as Q, u as W } from "./loading-Ds-yFYhc.js";
5
+ import { u as X } from "./business-DSv8zM8C.js";
6
+ import { u as Y } from "./campaign-7y5qquHZ.js";
7
+ import { g as V, b as L } from "./dto-Ew1QwLci.js";
8
+ import { u as Z } from "./vue-i18n-BTlOChXs.js";
9
+ import { _ as ee } from "./ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js";
10
+ import { _ as oe } from "./EditCampaignSheet.vue_vue_type_script_setup_true_lang-BYoaa_-x.js";
11
+ import { u as te } from "./template-DouRWBpv.js";
12
+ import { c as _ } from "./index-C-SOz7jt.js";
13
+ const ae = { class: "px-24 flex flex-col gap-y-16" }, ne = { class: "flex items-center justify-between w-full" }, re = { class: "flex gap-8 overflow-x-auto" }, se = { class: "space-y-8" }, ie = { class: "flex w-full gap-4 items-center" }, le = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ce = { class: "space-y-4" }, me = { class: "fm-typo-en-body-lg-600" }, de = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pe = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ue = { key: 0 }, Ve = /* @__PURE__ */ N({
14
+ __name: "Credit",
15
+ setup(fe) {
16
+ const { t: r } = Z(), I = {
17
+ label: r("connect.program.common.actions.create", {
18
+ type: r("connect.program.credit.title").toLowerCase()
19
+ }),
20
+ value: "create",
21
+ isPrimary: !0,
22
+ prependIcon: "add"
23
+ }, R = te("CREDIT", J()), B = X(), m = Y(), { global: D, minor: w } = W, s = S({
24
+ searchKey: "",
25
+ location: null
26
+ }), d = j(
27
+ () => m.campaigns.credit.filter(
28
+ (e) => !s.value.location || !e.targetLocation || e.targetLocation.includes(s.value.location)
29
+ )
30
+ ), T = [
31
+ {
32
+ header: r("connect.program.common.table.title"),
33
+ accessorFn: (e) => e.name
34
+ },
35
+ {
36
+ header: r("connect.program.common.table.status"),
37
+ cell(e) {
38
+ return V(e.row.original);
39
+ }
40
+ },
41
+ {
42
+ header: r("connect.program.common.table.summary"),
43
+ accessorFn: (e) => L(e)
44
+ },
45
+ {
46
+ header: r("connect.program.common.table.actions"),
47
+ cell(e) {
48
+ return M(O.FmButton, {
49
+ variant: "tertiary",
50
+ icon: "delete",
51
+ iconColor: "neutral-gray-400",
52
+ onClick: (o) => {
53
+ o.stopPropagation(), x(e.row.original);
54
+ }
55
+ });
56
+ }
57
+ }
58
+ ], b = S();
59
+ async function x(e) {
60
+ await Q.remove(
61
+ r("connect.program.common.remove.confirm", { name: e.name })
62
+ ) && await w(
63
+ async () => {
64
+ await _.delete(e._id), await m.read("CREDIT");
65
+ },
66
+ {
67
+ message: r("connect.program.common.remove.removing", { name: e.name }),
68
+ successMessage: r("connect.program.common.remove.removed", {
69
+ name: e.name
70
+ })
71
+ }
72
+ );
73
+ }
74
+ async function f(e) {
75
+ e ? await o() : R.open(async (p) => {
76
+ await o(p);
77
+ });
78
+ async function o(p) {
79
+ var u;
80
+ (u = b.value) == null || u.showSheet(
81
+ !0,
82
+ "CREDIT",
83
+ e ? await _.readById(e._id) : void 0,
84
+ p
85
+ );
86
+ }
87
+ }
88
+ async function E(e) {
89
+ await w(
90
+ async () => {
91
+ e.campaign._id ? await _.update(e.campaign._id, e) : await _.create(e), await m.read("CREDIT");
92
+ },
93
+ {
94
+ message: `${e.campaign._id ? "Updating" : "Creating"} credit program`,
95
+ successMessage: `Credit program ${e.campaign._id ? "updated" : "created"} successfully`
96
+ }
97
+ );
98
+ }
99
+ return A(async () => {
100
+ await D(async () => {
101
+ await m.read("CREDIT");
102
+ });
103
+ }), (e, o) => {
104
+ const p = l("FmPageHead"), u = l("FmSearch"), K = l("FmTable"), F = l("FmButton"), $ = l("FmListItem"), P = l("FmList"), U = l("FmCard");
105
+ return c(), y(h, null, [
106
+ i(p, {
107
+ title: a(r)("connect.program.credit.title"),
108
+ actions: a(d).length > 0 ? [I] : [],
109
+ "onClick:action": o[0] || (o[0] = () => f())
110
+ }, null, 8, ["title", "actions"]),
111
+ n("div", ae, [
112
+ i(u, {
113
+ modelValue: a(s).searchKey,
114
+ "onUpdate:modelValue": o[1] || (o[1] = (t) => a(s).searchKey = t),
115
+ class: "hidden xs:block border-b-2 border-fm-color-neutral-gray-100",
116
+ placeholder: "search",
117
+ collapsible: ""
118
+ }, null, 8, ["modelValue"]),
119
+ a(m).campaigns.credit && a(m).campaigns.credit.length > 0 ? (c(), y(h, { key: 0 }, [
120
+ n("div", ne, [
121
+ n("div", re, [
122
+ i(ee, {
123
+ modelValue: a(s).location,
124
+ "onUpdate:modelValue": o[2] || (o[2] = (t) => a(s).location = t),
125
+ label: "Location: ",
126
+ "show-item-label": !0,
127
+ icon: "storefront",
128
+ placement: "bottom-start",
129
+ items: a(B).locationItems
130
+ }, null, 8, ["modelValue", "items"])
131
+ ]),
132
+ i(u, {
133
+ modelValue: a(s).searchKey,
134
+ "onUpdate:modelValue": o[3] || (o[3] = (t) => a(s).searchKey = t),
135
+ class: "xs:hidden",
136
+ placeholder: "search",
137
+ collapsible: ""
138
+ }, null, 8, ["modelValue"])
139
+ ]),
140
+ i(K, {
141
+ class: "xs:hidden",
142
+ "row-data": a(d),
143
+ "column-defs": T,
144
+ "search-value": a(s).searchKey,
145
+ "column-filter": [],
146
+ onRowClick: o[4] || (o[4] = (t) => f(t.original)),
147
+ "hide-footer": a(d).length < 10
148
+ }, null, 8, ["row-data", "search-value", "hide-footer"]),
149
+ i(P, { class: "hidden xs:flex flex-col mx-[-24px]" }, {
150
+ default: C(() => [
151
+ (c(!0), y(h, null, H(a(d).filter(
152
+ (t) => t.name.toLowerCase().includes(a(s).searchKey.toLowerCase())
153
+ ), (t) => (c(), v($, {
154
+ key: t._id.toString(),
155
+ onClick: (k) => f(t),
156
+ class: "py-12 px-16 flex items-center justify-between border-b border-fm-color-neutral-gray-100"
157
+ }, {
158
+ default: C(() => [
159
+ n("div", se, [
160
+ n("div", ie, [
161
+ (c(), v(q(a(V)(t)))),
162
+ n("div", le, g(t.currentReceive ?? 0) + " used ", 1)
163
+ ]),
164
+ n("div", ce, [
165
+ n("div", me, g(t.name), 1),
166
+ n("div", de, g(a(L)(t)), 1)
167
+ ]),
168
+ n("div", pe, " Credit received: " + g(t.currentReceive ?? 0), 1)
169
+ ]),
170
+ i(F, {
171
+ icon: "delete",
172
+ "icon-color": "neutral-gray-400",
173
+ variant: "tertiary",
174
+ onClick: (k) => (k.stopPropagation(), x(t))
175
+ }, null, 8, ["onClick"])
176
+ ]),
177
+ _: 2
178
+ }, 1032, ["onClick"]))), 128))
179
+ ]),
180
+ _: 1
181
+ }),
182
+ a(d).length == 0 ? (c(), y("div", ue, o[6] || (o[6] = [
183
+ n("div", { class: "text-fm-color-typo-secondary fm-typo-en-body-md-600" }, " No results found ", -1)
184
+ ]))) : z("", !0)
185
+ ], 64)) : (c(), v(U, {
186
+ key: 1,
187
+ variant: "outlined",
188
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
189
+ }, {
190
+ default: C(() => [
191
+ o[7] || (o[7] = n("img", {
192
+ src: G,
193
+ class: "aspect-square w-[150px]"
194
+ }, null, -1)),
195
+ o[8] || (o[8] = n("div", { class: "flex flex-col gap-16 text-center" }, [
196
+ n("div", { class: "fm-typo-en-title-sm-800" }, "Create your credit program"),
197
+ n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credits are virtual money that customers can use to pay for their purchases, similar to cash within your store. ")
198
+ ], -1)),
199
+ i(F, {
200
+ variant: "primary",
201
+ label: "Create credit program",
202
+ icon: "add",
203
+ onClick: o[5] || (o[5] = (t) => f())
204
+ })
205
+ ]),
206
+ _: 1
207
+ })),
208
+ i(oe, {
209
+ ref_key: "sheetRef",
210
+ ref: b,
211
+ "onSubmit:modelValue": E
212
+ }, null, 512)
213
+ ])
214
+ ], 64);
215
+ };
216
+ }
217
+ });
218
+ export {
219
+ Ve as default
220
+ };