@teamco/ischeduler-antd 2.0.1
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/antd/src/components/Scheduler.d.ts +28 -0
- package/dist/antd/src/components/Scheduler.d.ts.map +1 -0
- package/dist/antd/src/components/SchedulerDrawerButton.d.ts +23 -0
- package/dist/antd/src/components/SchedulerDrawerButton.d.ts.map +1 -0
- package/dist/antd/src/components/SchedulersList.d.ts +18 -0
- package/dist/antd/src/components/SchedulersList.d.ts.map +1 -0
- package/dist/antd/src/components/behaviors/AfterBehavior.d.ts +10 -0
- package/dist/antd/src/components/behaviors/AfterBehavior.d.ts.map +1 -0
- package/dist/antd/src/components/behaviors/MonthlyBehavior.d.ts +14 -0
- package/dist/antd/src/components/behaviors/MonthlyBehavior.d.ts.map +1 -0
- package/dist/antd/src/components/behaviors/OnThisDayBehavior.d.ts +8 -0
- package/dist/antd/src/components/behaviors/OnThisDayBehavior.d.ts.map +1 -0
- package/dist/antd/src/components/behaviors/WeeklyBehavior.d.ts +19 -0
- package/dist/antd/src/components/behaviors/WeeklyBehavior.d.ts.map +1 -0
- package/dist/antd/src/components/behaviors/YearlyBehavior.d.ts +14 -0
- package/dist/antd/src/components/behaviors/YearlyBehavior.d.ts.map +1 -0
- package/dist/antd/src/components/internal/CheckboxButton.d.ts +15 -0
- package/dist/antd/src/components/internal/CheckboxButton.d.ts.map +1 -0
- package/dist/antd/src/components/internal/DeleteAction.d.ts +13 -0
- package/dist/antd/src/components/internal/DeleteAction.d.ts.map +1 -0
- package/dist/antd/src/components/internal/DrawerEditAction.d.ts +12 -0
- package/dist/antd/src/components/internal/DrawerEditAction.d.ts.map +1 -0
- package/dist/antd/src/components/internal/Duration.d.ts +17 -0
- package/dist/antd/src/components/internal/Duration.d.ts.map +1 -0
- package/dist/antd/src/components/internal/HideColumns.d.ts +14 -0
- package/dist/antd/src/components/internal/HideColumns.d.ts.map +1 -0
- package/dist/antd/src/components/internal/SaveButton.d.ts +21 -0
- package/dist/antd/src/components/internal/SaveButton.d.ts.map +1 -0
- package/dist/antd/src/components/internal/StatusTag.d.ts +8 -0
- package/dist/antd/src/components/internal/StatusTag.d.ts.map +1 -0
- package/dist/antd/src/components/internal/Toolbar.d.ts +12 -0
- package/dist/antd/src/components/internal/Toolbar.d.ts.map +1 -0
- package/dist/antd/src/components/metadata/metadata.handlers.d.ts +4 -0
- package/dist/antd/src/components/metadata/metadata.handlers.d.ts.map +1 -0
- package/dist/antd/src/components/metadata/schedulersList.metadata.d.ts +14 -0
- package/dist/antd/src/components/metadata/schedulersList.metadata.d.ts.map +1 -0
- package/dist/antd/src/index.d.ts +7 -0
- package/dist/antd/src/index.d.ts.map +1 -0
- package/dist/antd/src/types/less.d.ts +9 -0
- package/dist/antd/src/utils/table.util.d.ts +14 -0
- package/dist/antd/src/utils/table.util.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +972 -0
- package/dist/ischeduler-antd.css +2 -0
- package/package.json +65 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,972 @@
|
|
|
1
|
+
import { CDiscountTypeValues as e, CEndReasonTypes as t, CFirstDayIdx as n, CNsDiscount as r, CNsDuration as i, COLORS as a, CScheduler as o, DEFAULT_DATE_TIME_FORMAT as s, DEFAULT_DISCOUNT_SCHEDULER as c, DEFAULT_SALE_SCHEDULER as l, DEFAULT_SCHEDULERS_LIMIT as u, EDays as d, EDiscountType as f, EDurationTypes as p, EMonths as m, ESchedulerPrefix as h, EStatus as g, EWeekDays as _, getDisabledDate as v, getKeyFromEnum as y, handleChangeStartDate as b, handleDurationValueChange as x, handleSelectWeeklyDay as S, isReadOnlyField as C, mergeNames as w, numberToCurrency as T, placeholderField as E, requiredField as D, setNestedDynamicFields as O, tsToLocaleDateTime as k, useColumnsToggle as ee, useSchedulerContext as A } from "@teamco/ischeduler-core";
|
|
2
|
+
import { Button as j, Checkbox as M, Col as N, DatePicker as P, Drawer as F, Dropdown as I, Form as L, InputNumber as R, Popconfirm as te, Row as z, Segmented as B, Select as V, Space as H, Table as U, Tag as W, Tooltip as G } from "antd";
|
|
3
|
+
import { useCallback as K, useEffect as q, useMemo as J, useRef as ne, useState as Y } from "react";
|
|
4
|
+
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
5
|
+
import { CalendarTwoTone as re, CheckCircleOutlined as ie, ControlTwoTone as ae, DeleteTwoTone as oe, EditTwoTone as se, FieldNumberOutlined as ce, MinusCircleOutlined as le, MoreOutlined as ue, PlusOutlined as de, ReloadOutlined as fe, SaveOutlined as pe, ScheduleTwoTone as me, SyncOutlined as he } from "@ant-design/icons";
|
|
6
|
+
import ge from "dayjs";
|
|
7
|
+
export * from "@teamco/ischeduler-core";
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
9
|
+
var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDescriptor, be = Object.getOwnPropertyNames, xe = Object.getPrototypeOf, Se = Object.prototype.hasOwnProperty, Ce = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), we = (e, t, n, r) => {
|
|
10
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i = be(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Se.call(e, s) && s !== n && ve(e, s, {
|
|
11
|
+
get: ((e) => t[e]).bind(null, s),
|
|
12
|
+
enumerable: !(r = ye(t, s)) || r.enumerable
|
|
13
|
+
});
|
|
14
|
+
return e;
|
|
15
|
+
}, Te = (e, t, n) => (n = e == null ? {} : _e(xe(e)), we(t || !e || !e.__esModule ? ve(n, "default", {
|
|
16
|
+
value: e,
|
|
17
|
+
enumerable: !0
|
|
18
|
+
}) : n, e)), Ee = (e) => {
|
|
19
|
+
let { t } = A(), { min: n = 1, label: r, disabled: a, durationTypes: o = [], required: s, prefix: c = [], exclude: l = [], namespace: u = i, onTypeChange: d, onValueChange: f } = e;
|
|
20
|
+
return /* @__PURE__ */ Z(L.Item, {
|
|
21
|
+
label: r,
|
|
22
|
+
children: /* @__PURE__ */ Q(H.Compact, {
|
|
23
|
+
style: { width: "100%" },
|
|
24
|
+
children: [/* @__PURE__ */ Z(L.Item, {
|
|
25
|
+
noStyle: !0,
|
|
26
|
+
name: w(c, u, "type"),
|
|
27
|
+
rules: [D(t("scheduler.meta.duration"), s)],
|
|
28
|
+
children: /* @__PURE__ */ Z(V, {
|
|
29
|
+
style: { width: 150 },
|
|
30
|
+
disabled: a,
|
|
31
|
+
onChange: d,
|
|
32
|
+
options: o.filter((e) => !l.includes(e)).map((e, t) => ({
|
|
33
|
+
key: `${e}-${t}`,
|
|
34
|
+
value: e,
|
|
35
|
+
label: p[e]
|
|
36
|
+
}))
|
|
37
|
+
})
|
|
38
|
+
}), /* @__PURE__ */ Z(L.Item, {
|
|
39
|
+
noStyle: !0,
|
|
40
|
+
name: w(c, u, "period"),
|
|
41
|
+
tooltip: D(r).message,
|
|
42
|
+
rules: [D(r, s)],
|
|
43
|
+
children: /* @__PURE__ */ Z(R, {
|
|
44
|
+
min: n,
|
|
45
|
+
onChange: f,
|
|
46
|
+
style: { width: "100%" },
|
|
47
|
+
disabled: a,
|
|
48
|
+
placeholder: r
|
|
49
|
+
})
|
|
50
|
+
})]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}, De = (e) => {
|
|
54
|
+
let { t } = A(), { min: n = 1, prefix: r = [], disabled: i = !1, required: a = !0 } = e, o = t("scheduler.occurrences");
|
|
55
|
+
return /* @__PURE__ */ Z(L.Item, {
|
|
56
|
+
label: o,
|
|
57
|
+
name: w(r, "range", "endReason", "occurrences"),
|
|
58
|
+
rules: [D(o, a)],
|
|
59
|
+
children: /* @__PURE__ */ Z(R, {
|
|
60
|
+
min: n,
|
|
61
|
+
style: { width: "calc(100% - 90px)" },
|
|
62
|
+
disabled: i,
|
|
63
|
+
placeholder: E(o)
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}, Oe = /* @__PURE__ */ Te((/* @__PURE__ */ Ce(((e, t) => {
|
|
67
|
+
(function() {
|
|
68
|
+
var e = {}.hasOwnProperty;
|
|
69
|
+
function n() {
|
|
70
|
+
for (var e = "", t = 0; t < arguments.length; t++) {
|
|
71
|
+
var n = arguments[t];
|
|
72
|
+
n && (e = i(e, r(n)));
|
|
73
|
+
}
|
|
74
|
+
return e;
|
|
75
|
+
}
|
|
76
|
+
function r(t) {
|
|
77
|
+
if (typeof t == "string" || typeof t == "number") return t;
|
|
78
|
+
if (typeof t != "object") return "";
|
|
79
|
+
if (Array.isArray(t)) return n.apply(null, t);
|
|
80
|
+
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) return t.toString();
|
|
81
|
+
var r = "";
|
|
82
|
+
for (var a in t) e.call(t, a) && t[a] && (r = i(r, a));
|
|
83
|
+
return r;
|
|
84
|
+
}
|
|
85
|
+
function i(e, t) {
|
|
86
|
+
return t ? e ? e + " " + t : e + t : e;
|
|
87
|
+
}
|
|
88
|
+
t !== void 0 && t.exports ? (n.default = n, t.exports = n) : typeof define == "function" && typeof define.amd == "object" && define.amd ? define("classnames", [], function() {
|
|
89
|
+
return n;
|
|
90
|
+
}) : window.classNames = n;
|
|
91
|
+
})();
|
|
92
|
+
})))(), 1), ke = "_checkboxWrapper_1kjv1_1", Ae = "_ant-checkbox-wrapper-checked_1kjv1_21", je = "_primary_1kjv1_25", Me = "_hide_1kjv1_33", Ne = {
|
|
93
|
+
checkboxWrapper: ke,
|
|
94
|
+
"ant-checkbox-wrapper-checked": "_ant-checkbox-wrapper-checked_1kjv1_21",
|
|
95
|
+
antCheckboxWrapperChecked: Ae,
|
|
96
|
+
primary: je,
|
|
97
|
+
hide: Me
|
|
98
|
+
}, Pe = (e) => {
|
|
99
|
+
let { loading: t, className: n, disabled: r, onChange: i, options: a = [], value: o = [], type: s = "primary", behavior: c = "hide" } = e;
|
|
100
|
+
return /* @__PURE__ */ Z(M.Group, {
|
|
101
|
+
options: a,
|
|
102
|
+
className: (0, Oe.default)(n, Ne.checkboxWrapper, Ne[s], Ne[c]),
|
|
103
|
+
value: o,
|
|
104
|
+
disabled: r || t,
|
|
105
|
+
onChange: i
|
|
106
|
+
});
|
|
107
|
+
}, Fe = "_scheduler_aqesn_1", Ie = "_result_aqesn_4", Le = "_drawerContent_aqesn_10", Re = "_chipLabel_aqesn_13", ze = "_monthlyGridDay_aqesn_18", Be = "_monthlyGridWeek_aqesn_25", Ve = "_monthsSeparator_aqesn_37", He = "_monthWrapper_aqesn_45", Ue = "_monthComponents_aqesn_50", We = "_weekWrapper_aqesn_70", Ge = "_ant-checkbox-wrapper-checked_aqesn_73", Ke = "_weekDaysWrap_aqesn_88", qe = "_yearWrapper_aqesn_91", Je = "_monthsWrapper_aqesn_91", Ye = "_tagsWrapper_aqesn_104", $ = {
|
|
108
|
+
scheduler: Fe,
|
|
109
|
+
result: Ie,
|
|
110
|
+
drawerContent: Le,
|
|
111
|
+
chipLabel: Re,
|
|
112
|
+
monthlyGridDay: ze,
|
|
113
|
+
monthlyGridWeek: Be,
|
|
114
|
+
monthsSeparator: Ve,
|
|
115
|
+
monthWrapper: He,
|
|
116
|
+
monthComponents: Ue,
|
|
117
|
+
weekWrapper: We,
|
|
118
|
+
"ant-checkbox-wrapper-checked": "_ant-checkbox-wrapper-checked_aqesn_73",
|
|
119
|
+
antCheckboxWrapperChecked: Ge,
|
|
120
|
+
weekDaysWrap: Ke,
|
|
121
|
+
yearWrapper: qe,
|
|
122
|
+
monthsWrapper: Je,
|
|
123
|
+
tagsWrapper: Ye
|
|
124
|
+
}, Xe = (e) => {
|
|
125
|
+
let { t, loading: r } = A(), { formRef: i, shortFormat: a = !0, isMultiple: o = !1, extendBy: s = [], namespaces: c = ["repeat", "weekly"], prefix: l, disabled: u, setOccurs: f } = e, p = w([...l, ...c], "days"), m = ne([]);
|
|
126
|
+
q(() => {
|
|
127
|
+
let e = i.getFieldValue(p);
|
|
128
|
+
Array.isArray(e) && e.length && (m.current = e, h());
|
|
129
|
+
}, [i]);
|
|
130
|
+
let h = K(() => {
|
|
131
|
+
let e = i.getFieldValue(l);
|
|
132
|
+
e?.duration && x({
|
|
133
|
+
type: e.duration.type,
|
|
134
|
+
period: e.duration.period
|
|
135
|
+
}, e, f, t);
|
|
136
|
+
}, [
|
|
137
|
+
i,
|
|
138
|
+
l,
|
|
139
|
+
f,
|
|
140
|
+
t
|
|
141
|
+
]), g = J(() => Object.keys(d).map((e) => t(`scheduler.weekdays.${d[e].toLowerCase()}`)), [t]), _ = J(() => Object.keys(d).map((e) => t(`scheduler.weekdays.short.${d[e].toLowerCase()}`)), [t]), v = (e) => e.map((t, r) => e[(r + n) % 7]), b = v(_), S = v(g), C = (a ? b : S).map((e, t) => {
|
|
142
|
+
let n = S[t], r = y(d, n);
|
|
143
|
+
return {
|
|
144
|
+
key: `${e}-${t}`,
|
|
145
|
+
label: a ? /* @__PURE__ */ Z(G, {
|
|
146
|
+
title: S[t],
|
|
147
|
+
children: e
|
|
148
|
+
}) : e,
|
|
149
|
+
value: r
|
|
150
|
+
};
|
|
151
|
+
}), T;
|
|
152
|
+
s.length && (C = [...C, ...s], T = $.weekDaysWrap);
|
|
153
|
+
let E = K((e) => {
|
|
154
|
+
if (o) m.current = e;
|
|
155
|
+
else {
|
|
156
|
+
let t = m.current, n = e.filter((e) => !t.includes(e)), r = n.length ? n : e;
|
|
157
|
+
i.setFieldValue(p, r), m.current = r;
|
|
158
|
+
}
|
|
159
|
+
h();
|
|
160
|
+
}, [
|
|
161
|
+
o,
|
|
162
|
+
i,
|
|
163
|
+
p,
|
|
164
|
+
h
|
|
165
|
+
]);
|
|
166
|
+
return /* @__PURE__ */ Z("div", {
|
|
167
|
+
className: (0, Oe.default)($.weekWrapper, T),
|
|
168
|
+
children: /* @__PURE__ */ Z(L.Item, {
|
|
169
|
+
label: t("scheduler.days"),
|
|
170
|
+
name: p,
|
|
171
|
+
rules: [D(t("scheduler.days"))],
|
|
172
|
+
children: /* @__PURE__ */ Z(Pe, {
|
|
173
|
+
loading: r,
|
|
174
|
+
disabled: u,
|
|
175
|
+
options: C,
|
|
176
|
+
onChange: E
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
}, Ze = (e) => {
|
|
181
|
+
let { t, loading: n } = A(), { min: r = 1, max: i = 31, prefix: a, disabled: o = !1, namespaces: s = ["repeat", "monthly"], formRef: c, setOccurs: l } = e, [u, d] = Y("DAY"), f = L.useWatch(w([...a, ...s], "weekDay"), c), p = t("scheduler.day"), m = K((e) => {
|
|
182
|
+
if (d(e), e === "DAY") {
|
|
183
|
+
let e = c.getFieldValue(a);
|
|
184
|
+
S(e.duration.period, e, l, t);
|
|
185
|
+
}
|
|
186
|
+
}, [
|
|
187
|
+
c,
|
|
188
|
+
a,
|
|
189
|
+
l,
|
|
190
|
+
d,
|
|
191
|
+
t
|
|
192
|
+
]);
|
|
193
|
+
q(() => {
|
|
194
|
+
let e = w([...a, ...s], "type");
|
|
195
|
+
m(c.getFieldValue(e));
|
|
196
|
+
}, [
|
|
197
|
+
c,
|
|
198
|
+
m,
|
|
199
|
+
a,
|
|
200
|
+
s
|
|
201
|
+
]);
|
|
202
|
+
let h = K(() => {
|
|
203
|
+
let e = () => {
|
|
204
|
+
let e = c.getFieldValue(a);
|
|
205
|
+
x({
|
|
206
|
+
type: e.duration.type,
|
|
207
|
+
period: e.duration.period
|
|
208
|
+
}, e, l, t);
|
|
209
|
+
};
|
|
210
|
+
if (u !== "PERIOD") return null;
|
|
211
|
+
let r = [
|
|
212
|
+
["First", "scheduler.day.first"],
|
|
213
|
+
["Second", "scheduler.day.second"],
|
|
214
|
+
["Third", "scheduler.day.third"],
|
|
215
|
+
["Fourth", "scheduler.day.fourth"],
|
|
216
|
+
["Last", "scheduler.day.last"]
|
|
217
|
+
].map(([e, n]) => {
|
|
218
|
+
let r = y(_, e);
|
|
219
|
+
return {
|
|
220
|
+
value: r,
|
|
221
|
+
label: t(n),
|
|
222
|
+
icon: f === r ? /* @__PURE__ */ Z(re, {}) : /* @__PURE__ */ Z(re, { twoToneColor: "gray" })
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
return /* @__PURE__ */ Q(N, {
|
|
226
|
+
span: 24,
|
|
227
|
+
className: $.monthlyGridWeek,
|
|
228
|
+
children: [/* @__PURE__ */ Z(L.Item, {
|
|
229
|
+
noStyle: !0,
|
|
230
|
+
name: w([...a, ...s], "weekDay"),
|
|
231
|
+
rules: [D(t("scheduler.weekday"))],
|
|
232
|
+
children: /* @__PURE__ */ Z(B, {
|
|
233
|
+
disabled: n || o,
|
|
234
|
+
onChange: e,
|
|
235
|
+
options: r.map(({ value: e, label: t, icon: r }) => ({
|
|
236
|
+
label: t,
|
|
237
|
+
value: e,
|
|
238
|
+
icon: r,
|
|
239
|
+
disabled: o || n
|
|
240
|
+
}))
|
|
241
|
+
})
|
|
242
|
+
}), /* @__PURE__ */ Z(Xe, {
|
|
243
|
+
formRef: c,
|
|
244
|
+
prefix: a,
|
|
245
|
+
isMultiple: !0,
|
|
246
|
+
disabled: o || n,
|
|
247
|
+
extendBy: [
|
|
248
|
+
{
|
|
249
|
+
key: "extend-day",
|
|
250
|
+
label: t("scheduler.day"),
|
|
251
|
+
value: "DAY"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
key: "extend-weekday",
|
|
255
|
+
label: t("scheduler.weekday"),
|
|
256
|
+
value: "WEEKDAY"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
key: "extend-weekend",
|
|
260
|
+
label: t("scheduler.weekend"),
|
|
261
|
+
value: "WEEKEND"
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
setOccurs: l
|
|
265
|
+
})]
|
|
266
|
+
});
|
|
267
|
+
}, [
|
|
268
|
+
f,
|
|
269
|
+
o,
|
|
270
|
+
c,
|
|
271
|
+
n,
|
|
272
|
+
u,
|
|
273
|
+
s,
|
|
274
|
+
a,
|
|
275
|
+
l,
|
|
276
|
+
t
|
|
277
|
+
]), g = () => u === "DAY" ? /* @__PURE__ */ Z(N, {
|
|
278
|
+
span: 12,
|
|
279
|
+
className: $.monthlyGridDay,
|
|
280
|
+
children: /* @__PURE__ */ Z(L.Item, {
|
|
281
|
+
noStyle: !0,
|
|
282
|
+
name: w([...a, ...s], "monthDay"),
|
|
283
|
+
hasFeedback: !0,
|
|
284
|
+
rules: [D(t("scheduler.days"))],
|
|
285
|
+
children: /* @__PURE__ */ Z(R, {
|
|
286
|
+
style: { width: 120 },
|
|
287
|
+
min: r,
|
|
288
|
+
max: i,
|
|
289
|
+
onChange: (e) => {
|
|
290
|
+
let n = c.getFieldValue(a);
|
|
291
|
+
e && S(e, n, l, t);
|
|
292
|
+
},
|
|
293
|
+
disabled: o || n,
|
|
294
|
+
placeholder: p
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
}) : null;
|
|
298
|
+
return /* @__PURE__ */ Q("div", {
|
|
299
|
+
className: $.monthWrapper,
|
|
300
|
+
children: [/* @__PURE__ */ Z(L.Item, {
|
|
301
|
+
noStyle: !0,
|
|
302
|
+
name: w([...a, ...s], "type"),
|
|
303
|
+
rules: [D(t("scheduler.meta.period"))],
|
|
304
|
+
children: /* @__PURE__ */ Z(B, {
|
|
305
|
+
disabled: o || n,
|
|
306
|
+
onChange: (e) => {
|
|
307
|
+
m(e);
|
|
308
|
+
},
|
|
309
|
+
options: [{
|
|
310
|
+
value: "DAY",
|
|
311
|
+
icon: u === "DAY" ? /* @__PURE__ */ Z(re, {}) : /* @__PURE__ */ Z(re, { twoToneColor: "gray" }),
|
|
312
|
+
label: t("scheduler.day")
|
|
313
|
+
}, {
|
|
314
|
+
value: "PERIOD",
|
|
315
|
+
icon: u === "PERIOD" ? /* @__PURE__ */ Z(ae, {}) : /* @__PURE__ */ Z(ae, { twoToneColor: "gray" }),
|
|
316
|
+
label: t("scheduler.meta.period")
|
|
317
|
+
}]
|
|
318
|
+
})
|
|
319
|
+
}), /* @__PURE__ */ Q(z, {
|
|
320
|
+
className: $.monthComponents,
|
|
321
|
+
children: [g(), h()]
|
|
322
|
+
})]
|
|
323
|
+
});
|
|
324
|
+
}, Qe = (e) => {
|
|
325
|
+
let { disabled: t, prefix: n } = e, { t: r } = A(), i = L.useWatch(w(n, "range", "startedAt")), a = {
|
|
326
|
+
format: s,
|
|
327
|
+
showTime: !0,
|
|
328
|
+
disabledDate: (e) => {
|
|
329
|
+
if (!i) return v(e);
|
|
330
|
+
let t = ge(i).add(1, "day").startOf("day");
|
|
331
|
+
return e && e.isBefore(t);
|
|
332
|
+
},
|
|
333
|
+
disabled: t || !i
|
|
334
|
+
}, o = r("scheduler.duration.endDate");
|
|
335
|
+
return /* @__PURE__ */ Z(L.Item, {
|
|
336
|
+
label: o,
|
|
337
|
+
name: w(n, "range", "endReason", "expiredAt"),
|
|
338
|
+
rules: [D(o, !0)],
|
|
339
|
+
children: /* @__PURE__ */ Z(P, { ...a })
|
|
340
|
+
});
|
|
341
|
+
}, $e = (e) => {
|
|
342
|
+
let { t, loading: n } = A(), { shortFormat: r = !0, isMultiple: i = !1, setOccurs: a, formRef: o, prefix: s, namespaces: c = ["repeat", "yearly"], disabled: l } = e, [u, d] = Y([]), f = w([...s, ...c], "months"), p = J(() => Object.keys(m).map((e) => t(`scheduler.months.${m[e].toLowerCase()}`)), [t]), h = J(() => Object.keys(m).map((e) => t(`scheduler.months.short.${m[e].toLowerCase()}`)), [t]);
|
|
343
|
+
q(() => {
|
|
344
|
+
let e = o.getFieldValue(f);
|
|
345
|
+
e && _(e);
|
|
346
|
+
}, [o]);
|
|
347
|
+
let g = Object.keys(m).map((e, t) => ({
|
|
348
|
+
key: `${e}-${t}`,
|
|
349
|
+
label: r ? /* @__PURE__ */ Z(G, {
|
|
350
|
+
title: p[t],
|
|
351
|
+
children: h[t]
|
|
352
|
+
}) : p[t],
|
|
353
|
+
value: e
|
|
354
|
+
})), _ = (e) => {
|
|
355
|
+
let n = [...e];
|
|
356
|
+
n.length ? i || (n = e.filter((e) => !u.includes(e))) : n = u, d(n), O(o, f.join("."), n);
|
|
357
|
+
let r = o.getFieldValue(s);
|
|
358
|
+
x({
|
|
359
|
+
type: r.duration.type,
|
|
360
|
+
period: r.duration.period
|
|
361
|
+
}, r, a, t);
|
|
362
|
+
};
|
|
363
|
+
return /* @__PURE__ */ Q("div", {
|
|
364
|
+
className: $.yearWrapper,
|
|
365
|
+
children: [/* @__PURE__ */ Z(L.Item, {
|
|
366
|
+
noStyle: !0,
|
|
367
|
+
name: f,
|
|
368
|
+
rules: [D(t("scheduler.months"))],
|
|
369
|
+
children: /* @__PURE__ */ Z(Pe, {
|
|
370
|
+
options: g,
|
|
371
|
+
disabled: l,
|
|
372
|
+
className: $.monthsWrapper,
|
|
373
|
+
loading: n,
|
|
374
|
+
onChange: _,
|
|
375
|
+
value: u
|
|
376
|
+
})
|
|
377
|
+
}), /* @__PURE__ */ Z(Ze, {
|
|
378
|
+
formRef: o,
|
|
379
|
+
prefix: s,
|
|
380
|
+
disabled: l,
|
|
381
|
+
setOccurs: a
|
|
382
|
+
})]
|
|
383
|
+
});
|
|
384
|
+
}, et = (e) => {
|
|
385
|
+
let { t: n, loading: a } = A(), { formRef: o, prefix: u, entity: d, onFinish: p, setDirty: m, disabled: g = !1, durationTypes: _ = [], discountTypes: y = [], readOnlyFields: S = [], schedulerType: T } = e, [E, O] = Y(null), [k, ee] = Y(null), [j, M] = Y(null), [F, I] = Y(null), [te, B] = Y("0"), U = o.getFieldValue(u), W = T === h.SALE ? l : c;
|
|
386
|
+
q(() => {
|
|
387
|
+
o.resetFields();
|
|
388
|
+
}, [o]), q(() => {
|
|
389
|
+
if (d && d.id !== F) {
|
|
390
|
+
let e = {}, t = e;
|
|
391
|
+
for (let e = 0; e < u.length - 1; e++) t[u[e]] = {}, t = t[u[e]];
|
|
392
|
+
t[u[u.length - 1]] = d, o.setFieldsValue(e), I(d.id ?? null);
|
|
393
|
+
}
|
|
394
|
+
}, [
|
|
395
|
+
d,
|
|
396
|
+
o,
|
|
397
|
+
F,
|
|
398
|
+
u
|
|
399
|
+
]), q(() => {
|
|
400
|
+
let e = o.getFieldValue(w(u, i, "type")), t = o.getFieldValue(w(u, i, "period")), r = o.getFieldValue(w(u, "range", "startedAt"));
|
|
401
|
+
r && b(r, M), ee(e), e && t && x({
|
|
402
|
+
type: e,
|
|
403
|
+
period: t
|
|
404
|
+
}, d ?? W, B, n), O(o.getFieldValue(w(u, "range", "endReason", "type")));
|
|
405
|
+
}, [
|
|
406
|
+
W,
|
|
407
|
+
d,
|
|
408
|
+
o,
|
|
409
|
+
u,
|
|
410
|
+
n
|
|
411
|
+
]);
|
|
412
|
+
let G = J(() => {
|
|
413
|
+
let e = {}, t = e;
|
|
414
|
+
for (let e = 0; e < u.length - 1; e++) t[u[e]] = {}, t = t[u[e]];
|
|
415
|
+
return t[u[u.length - 1]] = W, e;
|
|
416
|
+
}, [W, u]);
|
|
417
|
+
return /* @__PURE__ */ Z(H, { children: /* @__PURE__ */ Q(L, {
|
|
418
|
+
layout: "vertical",
|
|
419
|
+
autoComplete: "off",
|
|
420
|
+
form: o,
|
|
421
|
+
className: $.scheduler,
|
|
422
|
+
onFinish: p,
|
|
423
|
+
onFieldsChange: () => m(!0),
|
|
424
|
+
initialValues: G,
|
|
425
|
+
children: [
|
|
426
|
+
[h.DISCOUNT, h.TRIAL_DISCOUNT].includes(T) && /* @__PURE__ */ Z(z, {
|
|
427
|
+
gutter: [24, 24],
|
|
428
|
+
children: /* @__PURE__ */ Z(N, {
|
|
429
|
+
span: 12,
|
|
430
|
+
children: /* @__PURE__ */ Z(L.Item, {
|
|
431
|
+
label: n("scheduler.meta.duration"),
|
|
432
|
+
children: /* @__PURE__ */ Q(H.Compact, { children: [/* @__PURE__ */ Z(L.Item, {
|
|
433
|
+
noStyle: !0,
|
|
434
|
+
name: w(u, r, "type"),
|
|
435
|
+
rules: [D(n("scheduler.meta.duration"), !0)],
|
|
436
|
+
children: /* @__PURE__ */ Z(V, {
|
|
437
|
+
style: { width: 150 },
|
|
438
|
+
disabled: g || a,
|
|
439
|
+
options: y.sort().map((e, t) => ({
|
|
440
|
+
key: t,
|
|
441
|
+
label: f[e],
|
|
442
|
+
value: e
|
|
443
|
+
}))
|
|
444
|
+
})
|
|
445
|
+
}), /* @__PURE__ */ Z(L.Item, {
|
|
446
|
+
noStyle: !0,
|
|
447
|
+
name: w(u, r, "value"),
|
|
448
|
+
rules: [D(n("scheduler.meta.duration"), !0)],
|
|
449
|
+
children: /* @__PURE__ */ Z(R, {
|
|
450
|
+
min: 1,
|
|
451
|
+
style: { width: "100%" },
|
|
452
|
+
readOnly: C(w(null, r, "value").join("."), S),
|
|
453
|
+
disabled: g || a
|
|
454
|
+
})
|
|
455
|
+
})] })
|
|
456
|
+
})
|
|
457
|
+
})
|
|
458
|
+
}),
|
|
459
|
+
/* @__PURE__ */ Q(z, {
|
|
460
|
+
gutter: [24, 24],
|
|
461
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
462
|
+
span: 12,
|
|
463
|
+
children: /* @__PURE__ */ Z(Ee, {
|
|
464
|
+
label: n("scheduler.duration"),
|
|
465
|
+
disabled: g || a,
|
|
466
|
+
onTypeChange: (e) => {
|
|
467
|
+
ee(e);
|
|
468
|
+
let t = U?.duration?.period;
|
|
469
|
+
t != null && x({
|
|
470
|
+
type: e,
|
|
471
|
+
period: t
|
|
472
|
+
}, U, B, n);
|
|
473
|
+
},
|
|
474
|
+
onValueChange: (e) => {
|
|
475
|
+
let t = U?.duration?.type;
|
|
476
|
+
e && t && x({
|
|
477
|
+
type: t,
|
|
478
|
+
period: e
|
|
479
|
+
}, U, B, n);
|
|
480
|
+
},
|
|
481
|
+
prefix: u,
|
|
482
|
+
namespace: i,
|
|
483
|
+
required: !0,
|
|
484
|
+
durationTypes: _
|
|
485
|
+
})
|
|
486
|
+
}), /* @__PURE__ */ Z(N, {
|
|
487
|
+
span: 12,
|
|
488
|
+
children: /* @__PURE__ */ Z(L.Item, {
|
|
489
|
+
label: n("scheduler.startedAt"),
|
|
490
|
+
name: w(u, "range", "startedAt"),
|
|
491
|
+
rules: [D(n("scheduler.startedAt"))],
|
|
492
|
+
children: /* @__PURE__ */ Z(P, {
|
|
493
|
+
onChange: (e) => e && b(e, M),
|
|
494
|
+
showTime: !0,
|
|
495
|
+
format: s,
|
|
496
|
+
disabledDate: (e) => v(e),
|
|
497
|
+
disabled: g || a
|
|
498
|
+
})
|
|
499
|
+
})
|
|
500
|
+
})]
|
|
501
|
+
}),
|
|
502
|
+
k === "WEEK" && /* @__PURE__ */ Z(z, {
|
|
503
|
+
gutter: [24, 24],
|
|
504
|
+
children: /* @__PURE__ */ Z(N, {
|
|
505
|
+
span: 24,
|
|
506
|
+
children: /* @__PURE__ */ Z(Xe, {
|
|
507
|
+
prefix: u,
|
|
508
|
+
isMultiple: !0,
|
|
509
|
+
formRef: o,
|
|
510
|
+
setOccurs: B,
|
|
511
|
+
disabled: g
|
|
512
|
+
})
|
|
513
|
+
})
|
|
514
|
+
}),
|
|
515
|
+
k === "MONTH" && /* @__PURE__ */ Z(z, {
|
|
516
|
+
gutter: [24, 24],
|
|
517
|
+
children: /* @__PURE__ */ Z(N, {
|
|
518
|
+
span: 24,
|
|
519
|
+
children: /* @__PURE__ */ Z(Ze, {
|
|
520
|
+
formRef: o,
|
|
521
|
+
prefix: u,
|
|
522
|
+
disabled: g,
|
|
523
|
+
setOccurs: B
|
|
524
|
+
})
|
|
525
|
+
})
|
|
526
|
+
}),
|
|
527
|
+
k === "YEAR" && /* @__PURE__ */ Z(z, {
|
|
528
|
+
gutter: [24, 24],
|
|
529
|
+
children: /* @__PURE__ */ Z(N, {
|
|
530
|
+
span: 24,
|
|
531
|
+
children: /* @__PURE__ */ Z($e, {
|
|
532
|
+
formRef: o,
|
|
533
|
+
prefix: u,
|
|
534
|
+
disabled: g,
|
|
535
|
+
setOccurs: B
|
|
536
|
+
})
|
|
537
|
+
})
|
|
538
|
+
}),
|
|
539
|
+
/* @__PURE__ */ Q(z, {
|
|
540
|
+
gutter: [24, 24],
|
|
541
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
542
|
+
span: 12,
|
|
543
|
+
children: /* @__PURE__ */ Z(L.Item, {
|
|
544
|
+
label: n("scheduler.duration.end"),
|
|
545
|
+
name: w(u, "range", "endReason", "type"),
|
|
546
|
+
rules: [D(n("scheduler.duration.end"))],
|
|
547
|
+
children: /* @__PURE__ */ Z(V, {
|
|
548
|
+
disabled: g,
|
|
549
|
+
onChange: (e) => O(e),
|
|
550
|
+
options: [
|
|
551
|
+
n("scheduler.duration.end.day"),
|
|
552
|
+
n("scheduler.duration.end.after"),
|
|
553
|
+
n("scheduler.duration.end.no")
|
|
554
|
+
].map((e, n) => ({
|
|
555
|
+
key: n,
|
|
556
|
+
label: e,
|
|
557
|
+
value: t[n]
|
|
558
|
+
}))
|
|
559
|
+
})
|
|
560
|
+
})
|
|
561
|
+
}), /* @__PURE__ */ Q(N, {
|
|
562
|
+
span: 12,
|
|
563
|
+
children: [E === t[0] && /* @__PURE__ */ Z(Qe, {
|
|
564
|
+
prefix: u,
|
|
565
|
+
disabled: g
|
|
566
|
+
}), E === t[1] && /* @__PURE__ */ Z(De, {
|
|
567
|
+
prefix: u,
|
|
568
|
+
disabled: g
|
|
569
|
+
})]
|
|
570
|
+
})]
|
|
571
|
+
}),
|
|
572
|
+
/* @__PURE__ */ Z("span", {
|
|
573
|
+
className: $.result,
|
|
574
|
+
dangerouslySetInnerHTML: { __html: n("scheduler.result", {
|
|
575
|
+
occurs: te,
|
|
576
|
+
startAt: j ?? ""
|
|
577
|
+
}) }
|
|
578
|
+
})
|
|
579
|
+
]
|
|
580
|
+
}) });
|
|
581
|
+
}, tt = (e) => {
|
|
582
|
+
let { t, permissions: n } = A(), { formRef: r, loading: i, className: a, isEdit: o, disabled: s, size: c = "small", color: l = "primary", icon: u = /* @__PURE__ */ Z(pe, {}), htmlType: d = "submit", variant: f = "solid", onClick: p, danger: m = !1 } = e;
|
|
583
|
+
return (o ? n.canUpdate : n.canCreate) ? /* @__PURE__ */ Z(j, {
|
|
584
|
+
size: c,
|
|
585
|
+
variant: f,
|
|
586
|
+
htmlType: d,
|
|
587
|
+
className: a,
|
|
588
|
+
disabled: s,
|
|
589
|
+
loading: i,
|
|
590
|
+
icon: u,
|
|
591
|
+
danger: m,
|
|
592
|
+
onClick: (e) => {
|
|
593
|
+
e.preventDefault(), r && d === "submit" && r.submit(), p?.();
|
|
594
|
+
},
|
|
595
|
+
color: l,
|
|
596
|
+
children: t(o ? "actions.update" : "actions.save")
|
|
597
|
+
}) : null;
|
|
598
|
+
}, nt = ({ schedulerType: e, disabled: t, onSuccess: n, setDirty: i, dirty: a, isCreating: s, setIsCreating: c, buttonProps: l }) => {
|
|
599
|
+
let { t: d, loading: m, permissions: g, onCreate: _ } = A(), [v] = L.useForm(), [y, b] = Y(!1), x = J(() => [o, e], [e]), S = J(() => Object.keys(p), []), C = J(() => Object.keys(f), []);
|
|
600
|
+
if (!g.canCreate) return null;
|
|
601
|
+
let w = async () => {
|
|
602
|
+
try {
|
|
603
|
+
c(!0), await v.validateFields();
|
|
604
|
+
let t = v.getFieldValue(x), a = {
|
|
605
|
+
id: `new-${Date.now()}`,
|
|
606
|
+
...t,
|
|
607
|
+
type: e,
|
|
608
|
+
[r]: e === h.SALE ? null : t?.[r]
|
|
609
|
+
};
|
|
610
|
+
_ && await _(e, a), n?.(a), b(!1), i(!1), v.resetFields();
|
|
611
|
+
} catch {} finally {
|
|
612
|
+
c(!1);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(j, {
|
|
616
|
+
style: { padding: 0 },
|
|
617
|
+
color: "default",
|
|
618
|
+
variant: "link",
|
|
619
|
+
...l,
|
|
620
|
+
disabled: t || m,
|
|
621
|
+
onClick: (e) => {
|
|
622
|
+
e.preventDefault(), e.stopPropagation(), b(!0);
|
|
623
|
+
},
|
|
624
|
+
children: /* @__PURE__ */ Z(G, {
|
|
625
|
+
title: t ? d("scheduler.limited", { limit: u }) : void 0,
|
|
626
|
+
children: d("scheduler")
|
|
627
|
+
})
|
|
628
|
+
}), /* @__PURE__ */ Z(F, {
|
|
629
|
+
title: /* @__PURE__ */ Q("div", {
|
|
630
|
+
style: {
|
|
631
|
+
display: "flex",
|
|
632
|
+
alignItems: "center",
|
|
633
|
+
gap: 8
|
|
634
|
+
},
|
|
635
|
+
children: [/* @__PURE__ */ Z(me, {}), d("scheduler")]
|
|
636
|
+
}),
|
|
637
|
+
size: 600,
|
|
638
|
+
open: y,
|
|
639
|
+
onClose: () => b(!1),
|
|
640
|
+
extra: /* @__PURE__ */ Z(tt, {
|
|
641
|
+
size: "small",
|
|
642
|
+
loading: m || s,
|
|
643
|
+
disabled: t || !a,
|
|
644
|
+
onClick: w
|
|
645
|
+
}),
|
|
646
|
+
children: /* @__PURE__ */ Z(et, {
|
|
647
|
+
setDirty: i,
|
|
648
|
+
formRef: v,
|
|
649
|
+
prefix: x,
|
|
650
|
+
schedulerType: e,
|
|
651
|
+
durationTypes: S,
|
|
652
|
+
discountTypes: C,
|
|
653
|
+
disabled: t
|
|
654
|
+
})
|
|
655
|
+
})] });
|
|
656
|
+
}, rt = (e) => {
|
|
657
|
+
let { t } = A(), { selectedColumns: n = [], columnsList: r = [], onChange: i } = e;
|
|
658
|
+
if (!r?.length) return /* @__PURE__ */ Z(X, {});
|
|
659
|
+
let a = t("table.hideColumns"), o = {
|
|
660
|
+
mode: "multiple",
|
|
661
|
+
style: { minWidth: 250 },
|
|
662
|
+
options: [{
|
|
663
|
+
label: /* @__PURE__ */ Z("span", { children: a }),
|
|
664
|
+
title: a,
|
|
665
|
+
options: r
|
|
666
|
+
}],
|
|
667
|
+
placeholder: a,
|
|
668
|
+
maxTagCount: "responsive"
|
|
669
|
+
}, s = (e) => {
|
|
670
|
+
e.length < 1 || i?.(e);
|
|
671
|
+
};
|
|
672
|
+
return /* @__PURE__ */ Z(V, {
|
|
673
|
+
...o,
|
|
674
|
+
value: n,
|
|
675
|
+
onChange: s
|
|
676
|
+
});
|
|
677
|
+
}, it = (e) => {
|
|
678
|
+
let { loading: t, t: n } = A(), { children: r, items: i = [], size: a = "middle", onRefresh: o } = e, s = o ? [{
|
|
679
|
+
key: "refresh",
|
|
680
|
+
label: n("toolbar.refresh"),
|
|
681
|
+
icon: /* @__PURE__ */ Z(fe, {}),
|
|
682
|
+
onClick: o
|
|
683
|
+
}] : [];
|
|
684
|
+
return i?.length && (s = i.concat([{ type: "divider" }, ...s])), /* @__PURE__ */ Q("div", {
|
|
685
|
+
style: {
|
|
686
|
+
display: "flex",
|
|
687
|
+
alignItems: "center",
|
|
688
|
+
justifyContent: "flex-end",
|
|
689
|
+
gap: 8
|
|
690
|
+
},
|
|
691
|
+
children: [r || null, /* @__PURE__ */ Z(I, {
|
|
692
|
+
menu: { items: s },
|
|
693
|
+
trigger: ["click"],
|
|
694
|
+
children: /* @__PURE__ */ Z(j, {
|
|
695
|
+
loading: t,
|
|
696
|
+
size: a,
|
|
697
|
+
color: "default",
|
|
698
|
+
variant: "filled",
|
|
699
|
+
icon: /* @__PURE__ */ Z(ue, {}),
|
|
700
|
+
type: "primary"
|
|
701
|
+
})
|
|
702
|
+
})]
|
|
703
|
+
});
|
|
704
|
+
}, at = (e) => {
|
|
705
|
+
let { t, loading: n, permissions: r } = A(), { entity: i, icon: a, type: o = "primary", showLabel: s = !1, disabled: c, onDelete: l } = e;
|
|
706
|
+
return !i || !r.canDelete ? null : /* @__PURE__ */ Z(te, {
|
|
707
|
+
title: t("actions.confirm.delete"),
|
|
708
|
+
onConfirm: () => l?.(i),
|
|
709
|
+
okText: t("actions.delete"),
|
|
710
|
+
cancelText: t("actions.cancel"),
|
|
711
|
+
children: /* @__PURE__ */ Z(G, {
|
|
712
|
+
title: t("actions.delete"),
|
|
713
|
+
children: /* @__PURE__ */ Z(j, {
|
|
714
|
+
disabled: c || !r.canDelete,
|
|
715
|
+
loading: n,
|
|
716
|
+
danger: !0,
|
|
717
|
+
type: o,
|
|
718
|
+
icon: a || /* @__PURE__ */ Z(oe, { twoToneColor: "#eb2f96" }),
|
|
719
|
+
children: s && t("actions.delete")
|
|
720
|
+
})
|
|
721
|
+
})
|
|
722
|
+
});
|
|
723
|
+
}, ot = (e) => {
|
|
724
|
+
let { t, loading: n, permissions: r } = A(), { entity: i, type: o = "primary", showLabel: s = !1, onEdit: c } = e;
|
|
725
|
+
return !i || !r.canUpdate ? null : /* @__PURE__ */ Z(j, {
|
|
726
|
+
disabled: !r.canUpdate,
|
|
727
|
+
loading: n,
|
|
728
|
+
type: o,
|
|
729
|
+
icon: /* @__PURE__ */ Z(se, { twoToneColor: a.success }),
|
|
730
|
+
onClick: () => c?.(i),
|
|
731
|
+
children: s && t("actions.edit")
|
|
732
|
+
});
|
|
733
|
+
}, st = (e) => /* @__PURE__ */ Z("div", {
|
|
734
|
+
className: $.tagsWrapper,
|
|
735
|
+
children: e?.days.map((e, t) => /* @__PURE__ */ Z(W, {
|
|
736
|
+
color: a.tags.volcano,
|
|
737
|
+
children: e
|
|
738
|
+
}, t))
|
|
739
|
+
}), ct = (e, t) => e?.type === "PERIOD" ? /* @__PURE__ */ Z("div", {
|
|
740
|
+
className: $.tagsWrapper,
|
|
741
|
+
children: t?.days.map((t, n) => /* @__PURE__ */ Z(W, {
|
|
742
|
+
color: a.tags.cyan,
|
|
743
|
+
children: `${e.weekDay} ${t}`
|
|
744
|
+
}, n))
|
|
745
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
746
|
+
className: $.tagsWrapper,
|
|
747
|
+
children: /* @__PURE__ */ Z(W, {
|
|
748
|
+
color: a.tags.gold,
|
|
749
|
+
children: e?.monthDay
|
|
750
|
+
}, "monthDay")
|
|
751
|
+
}), lt = (e, t, n) => /* @__PURE__ */ Q(X, { children: [ct(t, n), /* @__PURE__ */ Z("div", {
|
|
752
|
+
className: $.tagsWrapper,
|
|
753
|
+
children: e?.months?.map((e, t) => /* @__PURE__ */ Z(W, {
|
|
754
|
+
color: a.tags.magenta,
|
|
755
|
+
children: e
|
|
756
|
+
}, t))
|
|
757
|
+
})] }), ut = ({ status: e }) => {
|
|
758
|
+
switch (e) {
|
|
759
|
+
case g.ACTIVE: return /* @__PURE__ */ Z(W, {
|
|
760
|
+
color: "success",
|
|
761
|
+
icon: /* @__PURE__ */ Z(ie, {}),
|
|
762
|
+
children: e
|
|
763
|
+
});
|
|
764
|
+
case g.PROCESSING: return /* @__PURE__ */ Z(W, {
|
|
765
|
+
color: "processing",
|
|
766
|
+
icon: /* @__PURE__ */ Z(he, { spin: !0 }),
|
|
767
|
+
children: e
|
|
768
|
+
});
|
|
769
|
+
case g.DEACTIVATED: return /* @__PURE__ */ Z(W, {
|
|
770
|
+
color: "default",
|
|
771
|
+
icon: /* @__PURE__ */ Z(le, {}),
|
|
772
|
+
children: e
|
|
773
|
+
});
|
|
774
|
+
default: return /* @__PURE__ */ Z(W, {
|
|
775
|
+
color: "default",
|
|
776
|
+
children: e
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}, dt = (e) => e.map((e, t) => ({
|
|
780
|
+
...e,
|
|
781
|
+
idx: t + 1,
|
|
782
|
+
key: e.id
|
|
783
|
+
})), ft = {
|
|
784
|
+
key: "idx",
|
|
785
|
+
title: /* @__PURE__ */ Z(ce, {}),
|
|
786
|
+
dataIndex: "idx",
|
|
787
|
+
rowScope: "row",
|
|
788
|
+
width: 70,
|
|
789
|
+
fixed: "left",
|
|
790
|
+
align: "center"
|
|
791
|
+
}, pt = (e = 100, t = "Actions") => ({
|
|
792
|
+
title: t,
|
|
793
|
+
key: "operation",
|
|
794
|
+
fixed: "right",
|
|
795
|
+
align: "center",
|
|
796
|
+
width: e
|
|
797
|
+
}), mt = (t, n = []) => {
|
|
798
|
+
let { disabled: r, schedulerType: i, currency: a, t: o, onEdit: s, onDelete: c } = t, l = s || c ? {
|
|
799
|
+
title: o("table.actions"),
|
|
800
|
+
key: "operation",
|
|
801
|
+
fixed: "right",
|
|
802
|
+
align: "center",
|
|
803
|
+
width: 100,
|
|
804
|
+
render: (e, t) => /* @__PURE__ */ Q("div", { children: [s && /* @__PURE__ */ Z(ot, {
|
|
805
|
+
onEdit: s,
|
|
806
|
+
disabled: r,
|
|
807
|
+
type: "text",
|
|
808
|
+
entity: t
|
|
809
|
+
}), c && /* @__PURE__ */ Z(at, {
|
|
810
|
+
onDelete: c,
|
|
811
|
+
icon: /* @__PURE__ */ Z(oe, { twoToneColor: "#eb2f96" }),
|
|
812
|
+
type: "text",
|
|
813
|
+
entity: t,
|
|
814
|
+
disabled: r
|
|
815
|
+
})] })
|
|
816
|
+
} : null, u = [h.DISCOUNT, h.TRIAL_DISCOUNT].includes(i) ? {
|
|
817
|
+
title: o("scheduler.meta.duration"),
|
|
818
|
+
dataIndex: "discount",
|
|
819
|
+
key: "discount",
|
|
820
|
+
width: 150,
|
|
821
|
+
render(t) {
|
|
822
|
+
return t ? t.type === "PERCENT" ? `${t.value}${e[t.type]}` : T(t.value, a ?? "USD") : "—";
|
|
823
|
+
}
|
|
824
|
+
} : null, d = [
|
|
825
|
+
ft,
|
|
826
|
+
{
|
|
827
|
+
title: o("scheduler.meta.duration"),
|
|
828
|
+
dataIndex: "duration",
|
|
829
|
+
key: "duration",
|
|
830
|
+
width: 150,
|
|
831
|
+
render(e) {
|
|
832
|
+
return `${e?.period} (${e?.type})`;
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
title: o("scheduler.duration"),
|
|
837
|
+
key: "repeat",
|
|
838
|
+
render(e, t) {
|
|
839
|
+
let { duration: n, repeat: r } = t, { weekly: i, monthly: a, yearly: o } = r;
|
|
840
|
+
switch (n?.type) {
|
|
841
|
+
case "WEEK": return st(i);
|
|
842
|
+
case "MONTH": return ct(a, i);
|
|
843
|
+
case "YEAR": return lt(o, a, i);
|
|
844
|
+
default: return /* @__PURE__ */ Z(X, {});
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
u,
|
|
849
|
+
{
|
|
850
|
+
title: o("scheduler.status"),
|
|
851
|
+
dataIndex: "status",
|
|
852
|
+
key: "status",
|
|
853
|
+
width: 150,
|
|
854
|
+
align: "center",
|
|
855
|
+
concealable: !0,
|
|
856
|
+
render: (e) => /* @__PURE__ */ Z(ut, { status: e })
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
title: o("scheduler.updatedAt"),
|
|
860
|
+
width: 200,
|
|
861
|
+
dataIndex: "metadata",
|
|
862
|
+
align: "center",
|
|
863
|
+
key: "metadata.updatedAt",
|
|
864
|
+
concealable: !0,
|
|
865
|
+
render: (e) => /* @__PURE__ */ Z("div", { children: e?.updatedAt ? k(e.updatedAt) : "—" })
|
|
866
|
+
},
|
|
867
|
+
l
|
|
868
|
+
].filter(Boolean);
|
|
869
|
+
return n.length ? d.filter((e) => n.includes(e?.dataIndex) || e.dataIndex === "idx") : d;
|
|
870
|
+
}, ht = (e) => {
|
|
871
|
+
let { type: t, title: n, disabled: i, readOnlyFields: a = [], currency: s, onRefresh: c } = e, { schedulers: l, loading: d, disabled: m, t: g, permissions: _, onUpdate: v, onDelete: y } = A(), b = i ?? m, x = l[t] ?? [], [S, C] = Y(/* @__PURE__ */ new Set()), [w, T] = Y(!1), [E, D] = Y(!1), O = J(() => S.size === 0 ? x : x.filter((e) => !e.id || !S.has(e.id)), [x, S]), k = O.length >= u, [j] = L.useForm(), [M, N] = Y(!1), [P, I] = Y(null), R = J(() => [o, t], [t]), te = J(() => Object.keys(p), []), z = J(() => Object.keys(f), []), B = (e) => {
|
|
872
|
+
I(e), N(!0);
|
|
873
|
+
}, V = async () => {
|
|
874
|
+
try {
|
|
875
|
+
await j.validateFields();
|
|
876
|
+
let e = j.getFieldValue(R), n = {
|
|
877
|
+
...P,
|
|
878
|
+
...e,
|
|
879
|
+
type: t,
|
|
880
|
+
[r]: t === h.SALE ? null : e?.[r]
|
|
881
|
+
};
|
|
882
|
+
v && await v(t, n), N(!1), I(null), T(!1), j.resetFields(), c?.();
|
|
883
|
+
} catch {}
|
|
884
|
+
}, { filteredColumns: H, columnsList: W, selectedColumns: G, setSelectedColumns: K } = ee(mt({
|
|
885
|
+
disabled: b,
|
|
886
|
+
schedulerType: t,
|
|
887
|
+
entities: O,
|
|
888
|
+
currency: s,
|
|
889
|
+
t: g,
|
|
890
|
+
onEdit: _.canUpdate ? B : void 0,
|
|
891
|
+
onDelete: _.canDelete ? async (e) => {
|
|
892
|
+
if (e.id?.startsWith("new-")) {
|
|
893
|
+
C((t) => {
|
|
894
|
+
let n = new Set(t);
|
|
895
|
+
return e.id && n.add(e.id), n;
|
|
896
|
+
});
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
y && e.id ? (await y(t, e.id), c?.()) : console.warn("No onDelete handler provided");
|
|
900
|
+
} : void 0
|
|
901
|
+
}));
|
|
902
|
+
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(U, {
|
|
903
|
+
columns: H,
|
|
904
|
+
loading: d,
|
|
905
|
+
scroll: { x: 1e3 },
|
|
906
|
+
bordered: !0,
|
|
907
|
+
className: $.gridList,
|
|
908
|
+
dataSource: dt(O),
|
|
909
|
+
rowKey: (e) => e.id ?? `row-${Math.random()}`,
|
|
910
|
+
title: () => /* @__PURE__ */ Z("div", {
|
|
911
|
+
className: $.gridHeader,
|
|
912
|
+
children: /* @__PURE__ */ Z(it, {
|
|
913
|
+
onRefresh: c,
|
|
914
|
+
items: _.canCreate && !k ? [{
|
|
915
|
+
label: /* @__PURE__ */ Z(nt, {
|
|
916
|
+
setDirty: T,
|
|
917
|
+
dirty: w,
|
|
918
|
+
isCreating: E,
|
|
919
|
+
setIsCreating: D,
|
|
920
|
+
schedulerType: t,
|
|
921
|
+
disabled: b || d || k || E,
|
|
922
|
+
onSuccess: () => c?.()
|
|
923
|
+
}),
|
|
924
|
+
icon: /* @__PURE__ */ Z(de, {})
|
|
925
|
+
}] : [],
|
|
926
|
+
children: /* @__PURE__ */ Z(rt, {
|
|
927
|
+
columnsList: W,
|
|
928
|
+
selectedColumns: G,
|
|
929
|
+
onChange: K
|
|
930
|
+
})
|
|
931
|
+
})
|
|
932
|
+
}),
|
|
933
|
+
footer: () => /* @__PURE__ */ Z("div", {
|
|
934
|
+
className: $.gridFooter,
|
|
935
|
+
children: `Total ${O.length} items`
|
|
936
|
+
})
|
|
937
|
+
}), /* @__PURE__ */ Z(F, {
|
|
938
|
+
title: /* @__PURE__ */ Q("div", {
|
|
939
|
+
style: {
|
|
940
|
+
display: "flex",
|
|
941
|
+
alignItems: "center",
|
|
942
|
+
gap: 8
|
|
943
|
+
},
|
|
944
|
+
children: [/* @__PURE__ */ Z(me, {}), n ?? g("scheduler")]
|
|
945
|
+
}),
|
|
946
|
+
size: 600,
|
|
947
|
+
open: M,
|
|
948
|
+
onClose: () => {
|
|
949
|
+
N(!1), I(null);
|
|
950
|
+
},
|
|
951
|
+
extra: /* @__PURE__ */ Z(tt, {
|
|
952
|
+
size: "small",
|
|
953
|
+
isEdit: !!P,
|
|
954
|
+
loading: d,
|
|
955
|
+
disabled: b || !w || E,
|
|
956
|
+
onClick: V
|
|
957
|
+
}),
|
|
958
|
+
children: M && /* @__PURE__ */ Z(et, {
|
|
959
|
+
setDirty: T,
|
|
960
|
+
formRef: j,
|
|
961
|
+
prefix: R,
|
|
962
|
+
entity: P,
|
|
963
|
+
schedulerType: t,
|
|
964
|
+
durationTypes: te,
|
|
965
|
+
discountTypes: z,
|
|
966
|
+
disabled: b,
|
|
967
|
+
readOnlyFields: a
|
|
968
|
+
})
|
|
969
|
+
})] });
|
|
970
|
+
};
|
|
971
|
+
//#endregion
|
|
972
|
+
export { et as Scheduler, nt as SchedulerDrawerButton, ht as SchedulersList, pt as actionField, ft as indexColumn, dt as indexable };
|