@isettingkit/business-rules 0.1.31 → 0.1.32
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/index.es.js +231 -235
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as u, Fragment as E, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { ValueDataType as k, ValueHowToSetUp as b, DecisionConditionRender as $ } from "@isettingkit/input";
|
|
3
|
-
import { Stack as
|
|
3
|
+
import { Stack as d } from "@inubekit/stack";
|
|
4
4
|
import { Divider as w } from "@inubekit/divider";
|
|
5
5
|
import { Button as z } from "@inubekit/button";
|
|
6
|
-
import { useState as
|
|
6
|
+
import { useState as N, useEffect as te } from "react";
|
|
7
7
|
import { Text as x } from "@inubekit/text";
|
|
8
8
|
import { Date as q } from "@inubekit/date";
|
|
9
9
|
import { Checkbox as re } from "@inubekit/checkbox";
|
|
@@ -11,8 +11,8 @@ import { Toggle as B } from "@inubekit/toggle";
|
|
|
11
11
|
import { inube as v } from "@inubekit/foundations";
|
|
12
12
|
import g, { keyframes as ae } from "styled-components";
|
|
13
13
|
import { useFormik as ne } from "formik";
|
|
14
|
-
import { mixed as P, object as L, number as R, string as I, date as
|
|
15
|
-
import { DecisionViewConditionRenderer as
|
|
14
|
+
import { mixed as P, object as L, number as R, string as I, date as M, lazy as H } from "yup";
|
|
15
|
+
import { DecisionViewConditionRenderer as _ } from "@isettingkit/view";
|
|
16
16
|
import { SkeletonLine as T } from "@inubekit/skeleton";
|
|
17
17
|
import { MdOutlineDelete as oe, MdClear as ie, MdAdd as de } from "react-icons/md";
|
|
18
18
|
import { Icon as Q } from "@inubekit/icon";
|
|
@@ -23,22 +23,22 @@ import { useMediaQuery as ue } from "@inubekit/hooks";
|
|
|
23
23
|
const he = (e) => {
|
|
24
24
|
const {
|
|
25
25
|
onHandleStartChange: t,
|
|
26
|
-
onHandleEndChange:
|
|
27
|
-
onCheckClosedChange:
|
|
28
|
-
labelStart:
|
|
29
|
-
labelEnd:
|
|
30
|
-
checkedClosed:
|
|
31
|
-
required:
|
|
26
|
+
onHandleEndChange: n,
|
|
27
|
+
onCheckClosedChange: o,
|
|
28
|
+
labelStart: l,
|
|
29
|
+
labelEnd: a,
|
|
30
|
+
checkedClosed: s = !1,
|
|
31
|
+
required: c = !1,
|
|
32
32
|
valueStart: h = "",
|
|
33
|
-
valueEnd:
|
|
33
|
+
valueEnd: i = "",
|
|
34
34
|
messageStart: m = "",
|
|
35
35
|
messageEnd: p = "",
|
|
36
36
|
statusStart: f = "pending",
|
|
37
37
|
statusEnd: S = "pending"
|
|
38
|
-
} = e, [A, J] =
|
|
38
|
+
} = e, [A, J] = N(s), [K, X] = N(h), [Z, ee] = N(i);
|
|
39
39
|
return /* @__PURE__ */ u(E, { children: [
|
|
40
|
-
/* @__PURE__ */ u(
|
|
41
|
-
/* @__PURE__ */ r(
|
|
40
|
+
/* @__PURE__ */ u(d, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
|
|
41
|
+
/* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(
|
|
42
42
|
x,
|
|
43
43
|
{
|
|
44
44
|
appearance: "gray",
|
|
@@ -50,7 +50,7 @@ const he = (e) => {
|
|
|
50
50
|
}
|
|
51
51
|
) }),
|
|
52
52
|
/* @__PURE__ */ r(
|
|
53
|
-
|
|
53
|
+
d,
|
|
54
54
|
{
|
|
55
55
|
alignContent: "center",
|
|
56
56
|
justifyContent: "center",
|
|
@@ -61,7 +61,7 @@ const he = (e) => {
|
|
|
61
61
|
{
|
|
62
62
|
label: "Cerrada",
|
|
63
63
|
onChange: ({ target: y }) => {
|
|
64
|
-
J(y.checked),
|
|
64
|
+
J(y.checked), o && o(y.checked);
|
|
65
65
|
},
|
|
66
66
|
checked: A,
|
|
67
67
|
value: ""
|
|
@@ -70,32 +70,32 @@ const he = (e) => {
|
|
|
70
70
|
}
|
|
71
71
|
)
|
|
72
72
|
] }),
|
|
73
|
-
/* @__PURE__ */ u(
|
|
74
|
-
/* @__PURE__ */ r(
|
|
73
|
+
/* @__PURE__ */ u(d, { justifyContent: "space-between", gap: "24px", children: [
|
|
74
|
+
/* @__PURE__ */ r(d, { width: "189px", children: /* @__PURE__ */ r(
|
|
75
75
|
q,
|
|
76
76
|
{
|
|
77
77
|
id: "dateStart",
|
|
78
|
-
label:
|
|
78
|
+
label: l,
|
|
79
79
|
onChange: (y) => {
|
|
80
80
|
X(y.target.value), t(y);
|
|
81
81
|
},
|
|
82
82
|
value: K,
|
|
83
|
-
required:
|
|
83
|
+
required: c,
|
|
84
84
|
size: "compact",
|
|
85
85
|
status: f,
|
|
86
86
|
message: m
|
|
87
87
|
}
|
|
88
88
|
) }),
|
|
89
|
-
A && /* @__PURE__ */ r(
|
|
89
|
+
A && /* @__PURE__ */ r(d, { width: "189px", children: /* @__PURE__ */ r(
|
|
90
90
|
q,
|
|
91
91
|
{
|
|
92
92
|
id: "dateEnd",
|
|
93
|
-
label:
|
|
93
|
+
label: a,
|
|
94
94
|
onChange: (y) => {
|
|
95
|
-
ee(y.target.value),
|
|
95
|
+
ee(y.target.value), n(y);
|
|
96
96
|
},
|
|
97
97
|
value: Z,
|
|
98
|
-
required:
|
|
98
|
+
required: c,
|
|
99
99
|
size: "compact",
|
|
100
100
|
status: S,
|
|
101
101
|
message: p
|
|
@@ -128,38 +128,38 @@ const he = (e) => {
|
|
|
128
128
|
`, me = (e) => {
|
|
129
129
|
const {
|
|
130
130
|
checked: t,
|
|
131
|
-
children:
|
|
132
|
-
handleToggleChange:
|
|
133
|
-
id:
|
|
134
|
-
labelToggle:
|
|
135
|
-
name:
|
|
136
|
-
valueToggle:
|
|
137
|
-
} = e, [h,
|
|
138
|
-
|
|
131
|
+
children: n,
|
|
132
|
+
handleToggleChange: o,
|
|
133
|
+
id: l,
|
|
134
|
+
labelToggle: a,
|
|
135
|
+
name: s,
|
|
136
|
+
valueToggle: c = ""
|
|
137
|
+
} = e, [h, i] = N(t), m = (p) => {
|
|
138
|
+
i(p.target.checked), o(p);
|
|
139
139
|
};
|
|
140
140
|
return te(() => {
|
|
141
|
-
|
|
141
|
+
i(t);
|
|
142
142
|
}, [t]), /* @__PURE__ */ u(E, { children: [
|
|
143
|
-
/* @__PURE__ */ r(
|
|
143
|
+
/* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(
|
|
144
144
|
B,
|
|
145
145
|
{
|
|
146
146
|
checked: h,
|
|
147
|
-
id:
|
|
148
|
-
name:
|
|
147
|
+
id: l,
|
|
148
|
+
name: s,
|
|
149
149
|
onChange: m,
|
|
150
150
|
size: "small",
|
|
151
|
-
value:
|
|
152
|
-
children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children:
|
|
151
|
+
value: c,
|
|
152
|
+
children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: a })
|
|
153
153
|
}
|
|
154
154
|
) }),
|
|
155
|
-
h && /* @__PURE__ */ r(E, { children:
|
|
155
|
+
h && /* @__PURE__ */ r(E, { children: n })
|
|
156
156
|
] });
|
|
157
157
|
}, be = (e) => ({
|
|
158
158
|
schema: P().test(
|
|
159
159
|
"isArrayOrString",
|
|
160
160
|
"Must be an array of strings/numbers or a single string",
|
|
161
161
|
(t) => Array.isArray(t) ? t.every(
|
|
162
|
-
(
|
|
162
|
+
(n) => typeof n == "string" || typeof n == "number"
|
|
163
163
|
) : typeof t == "string"
|
|
164
164
|
),
|
|
165
165
|
value: e
|
|
@@ -168,25 +168,25 @@ const he = (e) => {
|
|
|
168
168
|
"isArrayOrString",
|
|
169
169
|
"Must be an array of strings/numbers or a single string",
|
|
170
170
|
(t) => Array.isArray(t) ? t.every(
|
|
171
|
-
(
|
|
171
|
+
(n) => typeof n == "string" || typeof n == "number"
|
|
172
172
|
) : typeof t == "string"
|
|
173
173
|
),
|
|
174
174
|
value: e
|
|
175
175
|
}), xe = (e) => {
|
|
176
|
-
const t = (e == null ? void 0 : e.from) ?? 0,
|
|
176
|
+
const t = (e == null ? void 0 : e.from) ?? 0, n = (e == null ? void 0 : e.to) ?? 0;
|
|
177
177
|
return {
|
|
178
178
|
schema: L({
|
|
179
|
-
from: R().required("Range From is required").max(
|
|
179
|
+
from: R().required("Range From is required").max(n, "'Range From' cannot be greater than 'Range To'").min(0, "'Range From' cannot be less than 0"),
|
|
180
180
|
to: R().min(0, "To value must be greater than or equal to 0").required("To value is required").test(
|
|
181
181
|
"is-greater",
|
|
182
182
|
"To value must be greater than From value",
|
|
183
|
-
function(
|
|
184
|
-
const { from:
|
|
185
|
-
return
|
|
183
|
+
function(o) {
|
|
184
|
+
const { from: l } = this.parent;
|
|
185
|
+
return o > l;
|
|
186
186
|
}
|
|
187
187
|
)
|
|
188
188
|
}),
|
|
189
|
-
value: { from: t, to:
|
|
189
|
+
value: { from: t, to: n }
|
|
190
190
|
};
|
|
191
191
|
}, V = (e, t) => t === k.PERCENTAGE ? {
|
|
192
192
|
schema: R().required("Percentage is required").min(0, "Percentage cannot be less than 0").max(100, "Percentage cannot be greater than 100"),
|
|
@@ -208,9 +208,9 @@ const he = (e) => {
|
|
|
208
208
|
[b.GREATER_THAN]: V,
|
|
209
209
|
[b.LESS_THAN]: V,
|
|
210
210
|
[b.EQUAL]: V
|
|
211
|
-
},
|
|
211
|
+
}, O = (e) => ve[e] || ye;
|
|
212
212
|
function Ce({ decision: e, onSubmitEvent: t }) {
|
|
213
|
-
const
|
|
213
|
+
const n = {
|
|
214
214
|
name: e.name || "",
|
|
215
215
|
dataType: e.dataType || k.ALPHABETICAL,
|
|
216
216
|
valueUse: e.valueUse || "",
|
|
@@ -220,25 +220,25 @@ function Ce({ decision: e, onSubmitEvent: t }) {
|
|
|
220
220
|
toggleNone: !0,
|
|
221
221
|
conditions: {},
|
|
222
222
|
checkClosed: !1
|
|
223
|
-
},
|
|
223
|
+
}, o = L({
|
|
224
224
|
name: I().required("Name is required"),
|
|
225
|
-
startDate:
|
|
226
|
-
endDate:
|
|
225
|
+
startDate: M().required("Start date is required"),
|
|
226
|
+
endDate: M().when("checkClosed", (s, c, { parent: h }) => (h == null ? void 0 : h.checkClosed) ? c.required("End date is required").test(
|
|
227
227
|
"is-after-startDate",
|
|
228
228
|
"End date must be greater than or equal to Start date",
|
|
229
229
|
function(m) {
|
|
230
230
|
const p = this.parent.startDate;
|
|
231
231
|
return !p || !m ? !0 : new Date(m) >= new Date(p);
|
|
232
232
|
}
|
|
233
|
-
) :
|
|
234
|
-
value:
|
|
235
|
-
conditions:
|
|
236
|
-
var
|
|
237
|
-
return (
|
|
233
|
+
) : c.notRequired()),
|
|
234
|
+
value: H(() => O(l.values.valueUse)(l.values.value, l.values.dataType).schema),
|
|
235
|
+
conditions: H((s, { parent: c }) => {
|
|
236
|
+
var i, m;
|
|
237
|
+
return (c == null ? void 0 : c.toggleNone) && ((i = c == null ? void 0 : c.conditions) == null ? void 0 : i.length) > 0 ? L().shape({}) : L(
|
|
238
238
|
(m = e.conditions) == null ? void 0 : m.reduce(
|
|
239
239
|
(p, f) => {
|
|
240
|
-
if (
|
|
241
|
-
const S =
|
|
240
|
+
if (l.values.conditions[f.name] !== void 0) {
|
|
241
|
+
const S = O(f.valueUse);
|
|
242
242
|
p[f.name] = S(
|
|
243
243
|
f.value,
|
|
244
244
|
f.dataType
|
|
@@ -250,60 +250,60 @@ function Ce({ decision: e, onSubmitEvent: t }) {
|
|
|
250
250
|
)
|
|
251
251
|
);
|
|
252
252
|
})
|
|
253
|
-
}),
|
|
254
|
-
initialValues:
|
|
255
|
-
validationSchema:
|
|
253
|
+
}), l = ne({
|
|
254
|
+
initialValues: n,
|
|
255
|
+
validationSchema: o,
|
|
256
256
|
validateOnBlur: !0,
|
|
257
|
-
onSubmit: (
|
|
257
|
+
onSubmit: (s) => {
|
|
258
258
|
var h;
|
|
259
|
-
const
|
|
259
|
+
const c = {
|
|
260
260
|
...e,
|
|
261
|
-
name:
|
|
262
|
-
dataType:
|
|
263
|
-
valueUse:
|
|
264
|
-
value:
|
|
265
|
-
startDate:
|
|
266
|
-
endDate:
|
|
267
|
-
conditions: (h = e.conditions) == null ? void 0 : h.map((
|
|
268
|
-
...
|
|
269
|
-
value:
|
|
261
|
+
name: s.name,
|
|
262
|
+
dataType: s.dataType,
|
|
263
|
+
valueUse: s.valueUse,
|
|
264
|
+
value: s.value,
|
|
265
|
+
startDate: s.startDate,
|
|
266
|
+
endDate: s.endDate,
|
|
267
|
+
conditions: (h = e.conditions) == null ? void 0 : h.map((i) => ({
|
|
268
|
+
...i,
|
|
269
|
+
value: s.conditions[i.name]
|
|
270
270
|
}))
|
|
271
271
|
};
|
|
272
|
-
t(
|
|
272
|
+
t(c);
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
|
-
return { formik:
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
|
|
275
|
+
return { formik: l, handleToggleNoneChange: (s) => {
|
|
276
|
+
var c;
|
|
277
|
+
l.setFieldValue("toggleNone", s), (c = e.conditions) == null || c.forEach((h) => {
|
|
278
|
+
if (s)
|
|
279
|
+
l.setFieldValue(`conditions.${h.name}`, void 0);
|
|
280
280
|
else {
|
|
281
|
-
const
|
|
282
|
-
|
|
281
|
+
const i = h.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
|
|
282
|
+
l.setFieldValue(`conditions.${h.name}`, i);
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
285
|
} };
|
|
286
286
|
}
|
|
287
287
|
const we = (e) => {
|
|
288
288
|
var h;
|
|
289
|
-
const { decision: t, onSubmitEvent:
|
|
289
|
+
const { decision: t, onSubmitEvent: n, textValues: o, onCancel: l } = e, { formik: a, handleToggleNoneChange: s } = Ce({
|
|
290
290
|
decision: t,
|
|
291
|
-
onSubmitEvent:
|
|
292
|
-
}),
|
|
291
|
+
onSubmitEvent: n
|
|
292
|
+
}), c = {
|
|
293
293
|
name: t.name,
|
|
294
294
|
valueUse: t.valueUse,
|
|
295
295
|
dataType: t.dataType,
|
|
296
296
|
possibleValue: t.possibleValue
|
|
297
297
|
};
|
|
298
|
-
return /* @__PURE__ */ r("form", { onSubmit:
|
|
298
|
+
return /* @__PURE__ */ r("form", { onSubmit: a.handleSubmit, children: /* @__PURE__ */ u(d, { direction: "column", gap: "24px", children: [
|
|
299
299
|
$({
|
|
300
|
-
condition:
|
|
301
|
-
formik:
|
|
300
|
+
condition: c,
|
|
301
|
+
formik: a,
|
|
302
302
|
isDecision: !0
|
|
303
303
|
}),
|
|
304
304
|
/* @__PURE__ */ r(w, { dashed: !0 }),
|
|
305
305
|
/* @__PURE__ */ r(pe, { children: /* @__PURE__ */ r(ge, { children: /* @__PURE__ */ u(
|
|
306
|
-
|
|
306
|
+
d,
|
|
307
307
|
{
|
|
308
308
|
direction: "column",
|
|
309
309
|
padding: "6px 12px",
|
|
@@ -311,54 +311,54 @@ const we = (e) => {
|
|
|
311
311
|
height: "272px",
|
|
312
312
|
children: [
|
|
313
313
|
/* @__PURE__ */ u(
|
|
314
|
-
|
|
314
|
+
d,
|
|
315
315
|
{
|
|
316
316
|
justifyContent: "space-between",
|
|
317
317
|
alignItems: "center",
|
|
318
318
|
gap: "64px",
|
|
319
319
|
children: [
|
|
320
|
-
/* @__PURE__ */ r(x, { type: "title", size: "small", weight: "bold", appearance: "gray", children:
|
|
320
|
+
/* @__PURE__ */ r(x, { type: "title", size: "small", weight: "bold", appearance: "gray", children: o.factsThatConditionIt }),
|
|
321
321
|
/* @__PURE__ */ r(
|
|
322
322
|
B,
|
|
323
323
|
{
|
|
324
324
|
id: "toggleNone",
|
|
325
|
-
onChange: () =>
|
|
326
|
-
checked:
|
|
325
|
+
onChange: () => s(!a.values.toggleNone),
|
|
326
|
+
checked: a.values.toggleNone,
|
|
327
327
|
size: "small",
|
|
328
|
-
children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children:
|
|
328
|
+
children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: o.none })
|
|
329
329
|
}
|
|
330
330
|
)
|
|
331
331
|
]
|
|
332
332
|
}
|
|
333
333
|
),
|
|
334
|
-
/* @__PURE__ */ r(
|
|
334
|
+
/* @__PURE__ */ r(d, { direction: "column", gap: "20px", children: (h = t.conditions) == null ? void 0 : h.map((i) => /* @__PURE__ */ r(
|
|
335
335
|
me,
|
|
336
336
|
{
|
|
337
|
-
id: `toggle-${
|
|
338
|
-
name: `toggle.${
|
|
339
|
-
labelToggle:
|
|
340
|
-
checked: !
|
|
337
|
+
id: `toggle-${i.name}`,
|
|
338
|
+
name: `toggle.${i.name}`,
|
|
339
|
+
labelToggle: i.name,
|
|
340
|
+
checked: !a.values.toggleNone && a.values.conditions[i.name] !== void 0,
|
|
341
341
|
handleToggleChange: (m) => {
|
|
342
342
|
if (!m.target.checked)
|
|
343
|
-
|
|
344
|
-
`conditions.${
|
|
343
|
+
a.setFieldValue(
|
|
344
|
+
`conditions.${i.name}`,
|
|
345
345
|
void 0
|
|
346
|
-
),
|
|
347
|
-
`conditions.${
|
|
346
|
+
), a.setFieldTouched(
|
|
347
|
+
`conditions.${i.name}`,
|
|
348
348
|
!1,
|
|
349
349
|
!1
|
|
350
350
|
);
|
|
351
351
|
else {
|
|
352
|
-
const f =
|
|
353
|
-
|
|
354
|
-
`conditions.${
|
|
352
|
+
const f = i.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
|
|
353
|
+
a.setFieldValue(
|
|
354
|
+
`conditions.${i.name}`,
|
|
355
355
|
f
|
|
356
356
|
);
|
|
357
357
|
}
|
|
358
358
|
},
|
|
359
|
-
children: $({ condition:
|
|
359
|
+
children: $({ condition: i, formik: a })
|
|
360
360
|
},
|
|
361
|
-
|
|
361
|
+
i.name
|
|
362
362
|
)) })
|
|
363
363
|
]
|
|
364
364
|
}
|
|
@@ -367,29 +367,29 @@ const we = (e) => {
|
|
|
367
367
|
/* @__PURE__ */ r(
|
|
368
368
|
he,
|
|
369
369
|
{
|
|
370
|
-
labelStart:
|
|
371
|
-
labelEnd:
|
|
372
|
-
valueStart:
|
|
373
|
-
valueEnd:
|
|
374
|
-
messageStart:
|
|
375
|
-
messageEnd:
|
|
376
|
-
statusStart:
|
|
377
|
-
statusEnd:
|
|
378
|
-
onHandleStartChange: (
|
|
379
|
-
onHandleEndChange: (
|
|
380
|
-
onCheckClosedChange: (
|
|
381
|
-
|
|
370
|
+
labelStart: o.termStart,
|
|
371
|
+
labelEnd: o.termEnd,
|
|
372
|
+
valueStart: a.values.startDate,
|
|
373
|
+
valueEnd: a.values.endDate,
|
|
374
|
+
messageStart: a.errors.startDate,
|
|
375
|
+
messageEnd: a.errors.endDate,
|
|
376
|
+
statusStart: a.touched.startDate ? a.errors.startDate ? "invalid" : "valid" : void 0,
|
|
377
|
+
statusEnd: a.touched.endDate ? a.errors.endDate ? "invalid" : "valid" : void 0,
|
|
378
|
+
onHandleStartChange: (i) => a.setFieldValue("startDate", i.target.value),
|
|
379
|
+
onHandleEndChange: (i) => a.setFieldValue("endDate", i.target.value),
|
|
380
|
+
onCheckClosedChange: (i) => {
|
|
381
|
+
a.setFieldValue("checkClosed", i), i && a.setFieldValue("endDate", "");
|
|
382
382
|
},
|
|
383
|
-
checkedClosed:
|
|
383
|
+
checkedClosed: a.values.checkClosed
|
|
384
384
|
}
|
|
385
385
|
),
|
|
386
386
|
/* @__PURE__ */ r(w, {}),
|
|
387
|
-
/* @__PURE__ */ u(
|
|
388
|
-
/* @__PURE__ */ r(z, { appearance: "gray", onClick:
|
|
389
|
-
/* @__PURE__ */ r(z, { type: "submit", children:
|
|
387
|
+
/* @__PURE__ */ u(d, { direction: "row", justifyContent: "end", gap: "16px", children: [
|
|
388
|
+
/* @__PURE__ */ r(z, { appearance: "gray", onClick: l, children: o.cancel }),
|
|
389
|
+
/* @__PURE__ */ r(z, { type: "submit", children: o.confirm })
|
|
390
390
|
] })
|
|
391
391
|
] }) });
|
|
392
|
-
},
|
|
392
|
+
}, j = g.div`
|
|
393
393
|
& > div {
|
|
394
394
|
border-radius: 8px;
|
|
395
395
|
border: 1px solid ${v.palette.neutral.N30};
|
|
@@ -417,7 +417,7 @@ const we = (e) => {
|
|
|
417
417
|
to: e.to ?? ""
|
|
418
418
|
}), De = (e) => e.value, Ee = (e) => e.value, Ae = (e) => e.value;
|
|
419
419
|
var C = /* @__PURE__ */ ((e) => (e.EQUAL = "equal", e.GREATER_THAN = "greater_than", e.LESS_THAN = "less_than", e.LIST_OF_VALUES = "list_of_values", e.LIST_OF_VALUES_MULTI = "list_of_values_multi", e.RANGE = "range", e))(C || {});
|
|
420
|
-
const
|
|
420
|
+
const _e = (e) => e.value, Ne = {
|
|
421
421
|
[C.LIST_OF_VALUES]: ke,
|
|
422
422
|
[C.LIST_OF_VALUES_MULTI]: Se,
|
|
423
423
|
[C.RANGE]: Te,
|
|
@@ -426,28 +426,28 @@ const Ne = (e) => e.value, _e = {
|
|
|
426
426
|
[C.EQUAL]: Ae
|
|
427
427
|
};
|
|
428
428
|
function D(e) {
|
|
429
|
-
const t = e == null ? void 0 : e.value,
|
|
430
|
-
return
|
|
429
|
+
const t = e == null ? void 0 : e.value, n = typeof t == "object" && t !== null && !Array.isArray(t), o = Ne[e == null ? void 0 : e.valueUse] || _e;
|
|
430
|
+
return n && o(t) || t || void 0;
|
|
431
431
|
}
|
|
432
432
|
const Y = (e) => {
|
|
433
|
-
const { decision: t, loading:
|
|
433
|
+
const { decision: t, loading: n = !1, textValues: o } = e, l = {
|
|
434
434
|
name: (t == null ? void 0 : t.name) || "",
|
|
435
435
|
dataType: (t == null ? void 0 : t.dataType) || "alphabetical",
|
|
436
436
|
value: D(t),
|
|
437
437
|
valueUse: (t == null ? void 0 : t.valueUse) || "equal"
|
|
438
438
|
};
|
|
439
|
-
return !
|
|
440
|
-
t && /* @__PURE__ */ r(
|
|
441
|
-
|
|
439
|
+
return !n && t && o ? /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
|
|
440
|
+
t && /* @__PURE__ */ r(d, { direction: "column", alignItems: "center", children: /* @__PURE__ */ r(
|
|
441
|
+
_,
|
|
442
442
|
{
|
|
443
|
-
element:
|
|
444
|
-
valueData: D(
|
|
443
|
+
element: l,
|
|
444
|
+
valueData: D(l),
|
|
445
445
|
type: "decision"
|
|
446
446
|
}
|
|
447
447
|
) }, t.name),
|
|
448
448
|
/* @__PURE__ */ r(w, { dashed: !0 }),
|
|
449
449
|
/* @__PURE__ */ r(G, { children: /* @__PURE__ */ u(
|
|
450
|
-
|
|
450
|
+
d,
|
|
451
451
|
{
|
|
452
452
|
direction: "column",
|
|
453
453
|
gap: "12px",
|
|
@@ -462,36 +462,32 @@ const Y = (e) => {
|
|
|
462
462
|
appearance: "dark",
|
|
463
463
|
weight: "bold",
|
|
464
464
|
textAlign: "center",
|
|
465
|
-
children:
|
|
465
|
+
children: o.factsThatConditionIt
|
|
466
466
|
}
|
|
467
467
|
),
|
|
468
|
-
t.conditions && t.conditions.map((
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
valueData: D(l)
|
|
479
|
-
}
|
|
480
|
-
) }) }, l.name);
|
|
481
|
-
}),
|
|
468
|
+
t.conditions && t.conditions.map((a) => a.hidden ? null : (console.log("condition: ", a), /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(d, { direction: "column", padding: "8px", children: /* @__PURE__ */ r(
|
|
469
|
+
_,
|
|
470
|
+
{
|
|
471
|
+
element: {
|
|
472
|
+
...a,
|
|
473
|
+
value: a.value
|
|
474
|
+
},
|
|
475
|
+
valueData: D(a)
|
|
476
|
+
}
|
|
477
|
+
) }) }, a.name))),
|
|
482
478
|
/* @__PURE__ */ r(w, { dashed: !0 }),
|
|
483
|
-
/* @__PURE__ */ u(
|
|
479
|
+
/* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
|
|
484
480
|
(t == null ? void 0 : t.startDate) && (t == null ? void 0 : t.endDate) && /* @__PURE__ */ r(
|
|
485
|
-
|
|
481
|
+
_,
|
|
486
482
|
{
|
|
487
483
|
element: {
|
|
488
|
-
name:
|
|
484
|
+
name: o.terms,
|
|
489
485
|
value: String(t.startDate),
|
|
490
486
|
valueUse: b.RANGE,
|
|
491
487
|
dataType: k.DATE
|
|
492
488
|
},
|
|
493
489
|
valueData: D({
|
|
494
|
-
name:
|
|
490
|
+
name: o.terms,
|
|
495
491
|
value: {
|
|
496
492
|
from: String(t.startDate),
|
|
497
493
|
to: String(t.endDate)
|
|
@@ -501,49 +497,49 @@ const Y = (e) => {
|
|
|
501
497
|
}),
|
|
502
498
|
type: "decision"
|
|
503
499
|
},
|
|
504
|
-
|
|
500
|
+
o.terms
|
|
505
501
|
),
|
|
506
502
|
(t == null ? void 0 : t.startDate) && !(t != null && t.endDate) && /* @__PURE__ */ r(
|
|
507
|
-
|
|
503
|
+
_,
|
|
508
504
|
{
|
|
509
505
|
element: {
|
|
510
|
-
name:
|
|
506
|
+
name: o.terms,
|
|
511
507
|
value: String(t.startDate),
|
|
512
508
|
valueUse: b.EQUAL,
|
|
513
509
|
dataType: k.DATE
|
|
514
510
|
},
|
|
515
511
|
valueData: D({
|
|
516
|
-
name:
|
|
512
|
+
name: o.terms,
|
|
517
513
|
value: String(t.startDate),
|
|
518
514
|
valueUse: b.EQUAL,
|
|
519
515
|
dataType: k.DATE
|
|
520
516
|
}),
|
|
521
517
|
type: "decision"
|
|
522
518
|
},
|
|
523
|
-
|
|
519
|
+
o.terms
|
|
524
520
|
)
|
|
525
521
|
] })
|
|
526
522
|
]
|
|
527
523
|
}
|
|
528
524
|
) })
|
|
529
|
-
] }) : /* @__PURE__ */ u(
|
|
530
|
-
/* @__PURE__ */ u(
|
|
525
|
+
] }) : /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
|
|
526
|
+
/* @__PURE__ */ u(d, { direction: "column", alignItems: "center", gap: "4px", children: [
|
|
531
527
|
/* @__PURE__ */ r(T, { animated: !0, width: "180px" }),
|
|
532
528
|
/* @__PURE__ */ r(T, { animated: !0, width: "85px" })
|
|
533
529
|
] }, "loading"),
|
|
534
|
-
/* @__PURE__ */ u(
|
|
530
|
+
/* @__PURE__ */ u(d, { direction: "column", gap: "12px", alignItems: "center", children: [
|
|
535
531
|
/* @__PURE__ */ r(w, { dashed: !0 }),
|
|
536
532
|
/* @__PURE__ */ r(T, { animated: !0, width: "150px" })
|
|
537
533
|
] }),
|
|
538
534
|
/* @__PURE__ */ r(G, { children: /* @__PURE__ */ r(
|
|
539
|
-
|
|
535
|
+
d,
|
|
540
536
|
{
|
|
541
537
|
direction: "column",
|
|
542
538
|
gap: "12px",
|
|
543
539
|
justifyContent: "space-between",
|
|
544
540
|
height: "203px",
|
|
545
|
-
children: Array.from({ length: 5 }).map((
|
|
546
|
-
|
|
541
|
+
children: Array.from({ length: 5 }).map((a, s) => /* @__PURE__ */ r(j, { children: /* @__PURE__ */ u(
|
|
542
|
+
d,
|
|
547
543
|
{
|
|
548
544
|
direction: "column",
|
|
549
545
|
gap: "12px",
|
|
@@ -554,7 +550,7 @@ const Y = (e) => {
|
|
|
554
550
|
/* @__PURE__ */ r(T, { animated: !0, width: "85px" })
|
|
555
551
|
]
|
|
556
552
|
}
|
|
557
|
-
) }, `condition-${
|
|
553
|
+
) }, `condition-${s}`))
|
|
558
554
|
}
|
|
559
555
|
) })
|
|
560
556
|
] });
|
|
@@ -590,12 +586,12 @@ g.div`
|
|
|
590
586
|
}
|
|
591
587
|
`;
|
|
592
588
|
const F = (e) => {
|
|
593
|
-
const { children: t, controls:
|
|
594
|
-
return /* @__PURE__ */ r(Le, { children: /* @__PURE__ */ u(
|
|
589
|
+
const { children: t, controls: n = !0, handleDelete: o, id: l } = e;
|
|
590
|
+
return /* @__PURE__ */ r(Le, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "16px", padding: "12px 16px", children: [
|
|
595
591
|
t,
|
|
596
|
-
|
|
592
|
+
n && /* @__PURE__ */ u(E, { children: [
|
|
597
593
|
/* @__PURE__ */ r(w, {}),
|
|
598
|
-
/* @__PURE__ */ r(
|
|
594
|
+
/* @__PURE__ */ r(d, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ r(
|
|
599
595
|
Q,
|
|
600
596
|
{
|
|
601
597
|
cursorHover: !0,
|
|
@@ -603,7 +599,7 @@ const F = (e) => {
|
|
|
603
599
|
size: "24px",
|
|
604
600
|
icon: /* @__PURE__ */ r(oe, {}),
|
|
605
601
|
onClick: () => {
|
|
606
|
-
|
|
602
|
+
o(l);
|
|
607
603
|
}
|
|
608
604
|
}
|
|
609
605
|
) })
|
|
@@ -616,8 +612,8 @@ const F = (e) => {
|
|
|
616
612
|
}
|
|
617
613
|
`, Re = g.div`
|
|
618
614
|
background-color: ${({ theme: e }) => {
|
|
619
|
-
var t,
|
|
620
|
-
return ((
|
|
615
|
+
var t, n;
|
|
616
|
+
return ((n = (t = e == null ? void 0 : e.palette) == null ? void 0 : t.neutral) == null ? void 0 : n.N0) || v.palette.neutral.N0;
|
|
621
617
|
}};
|
|
622
618
|
max-width: 450px;
|
|
623
619
|
max-height: 90vh;
|
|
@@ -646,20 +642,20 @@ const F = (e) => {
|
|
|
646
642
|
border-radius: 8px;
|
|
647
643
|
}
|
|
648
644
|
`, Ue = (e) => {
|
|
649
|
-
const { children: t, portalId:
|
|
650
|
-
if (!
|
|
645
|
+
const { children: t, portalId: n, onCloseModal: o, title: l } = e, a = document.getElementById(n);
|
|
646
|
+
if (!a)
|
|
651
647
|
throw new Error(
|
|
652
648
|
"The portal node is not defined. This can occur when the specific node used to render the portal has not been defined correctly."
|
|
653
649
|
);
|
|
654
650
|
return le(
|
|
655
|
-
/* @__PURE__ */ r(Ve, { children: /* @__PURE__ */ r(se, { children: /* @__PURE__ */ r(Re, { children: /* @__PURE__ */ u(
|
|
656
|
-
/* @__PURE__ */ r(
|
|
657
|
-
/* @__PURE__ */ r(x, { type: "title", size: "large", appearance: "dark", weight: "bold", children:
|
|
658
|
-
/* @__PURE__ */ r(ie, { size: "24px", cursor: "pointer", onClick:
|
|
651
|
+
/* @__PURE__ */ r(Ve, { children: /* @__PURE__ */ r(se, { children: /* @__PURE__ */ r(Re, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "24px", children: [
|
|
652
|
+
/* @__PURE__ */ r(d, { direction: "column", gap: "24px", children: /* @__PURE__ */ u(d, { alignItems: "center", justifyContent: "space-between", children: [
|
|
653
|
+
/* @__PURE__ */ r(x, { type: "title", size: "large", appearance: "dark", weight: "bold", children: l }),
|
|
654
|
+
/* @__PURE__ */ r(ie, { size: "24px", cursor: "pointer", onClick: o })
|
|
659
655
|
] }) }),
|
|
660
656
|
t
|
|
661
657
|
] }) }) }) }),
|
|
662
|
-
|
|
658
|
+
a
|
|
663
659
|
);
|
|
664
660
|
}, Ie = ae`
|
|
665
661
|
from {
|
|
@@ -749,32 +745,32 @@ function qe({
|
|
|
749
745
|
`loading-card-${e}`
|
|
750
746
|
);
|
|
751
747
|
}
|
|
752
|
-
function
|
|
748
|
+
function Me({
|
|
753
749
|
decision: e,
|
|
754
750
|
controls: t,
|
|
755
|
-
handleOpenModal:
|
|
756
|
-
handleDelete:
|
|
757
|
-
textValues:
|
|
751
|
+
handleOpenModal: n,
|
|
752
|
+
handleDelete: o,
|
|
753
|
+
textValues: l
|
|
758
754
|
}) {
|
|
759
|
-
return e ? /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(
|
|
755
|
+
return e ? /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "4px", width: "100%", padding: "0 0 12px 0", children: [
|
|
760
756
|
/* @__PURE__ */ r(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: e.id }),
|
|
761
757
|
/* @__PURE__ */ r(
|
|
762
758
|
F,
|
|
763
759
|
{
|
|
764
760
|
id: e.id,
|
|
765
|
-
handleDelete: () =>
|
|
766
|
-
handleView: () =>
|
|
761
|
+
handleDelete: () => o(e.id),
|
|
762
|
+
handleView: () => n(e),
|
|
767
763
|
controls: t,
|
|
768
|
-
children: /* @__PURE__ */ r(Y, { decision: e, textValues:
|
|
764
|
+
children: /* @__PURE__ */ r(Y, { decision: e, textValues: l })
|
|
769
765
|
}
|
|
770
766
|
)
|
|
771
767
|
] }) }, e.id) : null;
|
|
772
768
|
}
|
|
773
|
-
function
|
|
769
|
+
function He({
|
|
774
770
|
index: e,
|
|
775
771
|
handleOpenModal: t
|
|
776
772
|
}) {
|
|
777
|
-
return /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(
|
|
773
|
+
return /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "4px", width: "100%", height: "100%", children: [
|
|
778
774
|
/* @__PURE__ */ r(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: "Nueva decisión" }),
|
|
779
775
|
/* @__PURE__ */ r(ze, { onClick: () => t(), children: /* @__PURE__ */ r(
|
|
780
776
|
F,
|
|
@@ -784,7 +780,7 @@ function je({
|
|
|
784
780
|
},
|
|
785
781
|
handleView: () => t(),
|
|
786
782
|
controls: !1,
|
|
787
|
-
children: /* @__PURE__ */ u(
|
|
783
|
+
children: /* @__PURE__ */ u(d, { direction: "column", gap: "12px", alignItems: "center", children: [
|
|
788
784
|
/* @__PURE__ */ r(Q, { appearance: "gray", icon: /* @__PURE__ */ r(de, {}), size: "35px" }),
|
|
789
785
|
/* @__PURE__ */ r(x, { appearance: "gray", type: "body", size: "large", children: "Agregar decisión" })
|
|
790
786
|
] })
|
|
@@ -792,70 +788,70 @@ function je({
|
|
|
792
788
|
) })
|
|
793
789
|
] }) }, `add-decision-${e}`);
|
|
794
790
|
}
|
|
795
|
-
const
|
|
791
|
+
const Oe = {
|
|
796
792
|
loading: qe,
|
|
797
|
-
decision:
|
|
798
|
-
add:
|
|
793
|
+
decision: Me,
|
|
794
|
+
add: He
|
|
799
795
|
};
|
|
800
796
|
function U(e) {
|
|
801
|
-
const { type: t } = e,
|
|
802
|
-
return
|
|
797
|
+
const { type: t } = e, n = Oe[t];
|
|
798
|
+
return n ? n(e) : null;
|
|
803
799
|
}
|
|
804
|
-
function
|
|
800
|
+
function je({
|
|
805
801
|
controls: e,
|
|
806
802
|
decisions: t,
|
|
807
|
-
loading:
|
|
808
|
-
handleOpenModal:
|
|
809
|
-
handleDelete:
|
|
810
|
-
textValues:
|
|
803
|
+
loading: n,
|
|
804
|
+
handleOpenModal: o,
|
|
805
|
+
handleDelete: l,
|
|
806
|
+
textValues: a
|
|
811
807
|
}) {
|
|
812
|
-
const
|
|
813
|
-
(h,
|
|
808
|
+
const s = n ? Array.from({ length: 3 }).map(
|
|
809
|
+
(h, i) => U({
|
|
814
810
|
type: "loading",
|
|
815
|
-
index:
|
|
811
|
+
index: i,
|
|
816
812
|
controls: e,
|
|
817
|
-
loading:
|
|
818
|
-
handleOpenModal:
|
|
819
|
-
handleDelete:
|
|
820
|
-
textValues:
|
|
813
|
+
loading: n,
|
|
814
|
+
handleOpenModal: o,
|
|
815
|
+
handleDelete: l,
|
|
816
|
+
textValues: a
|
|
821
817
|
})
|
|
822
818
|
) : t.map(
|
|
823
819
|
(h) => U({
|
|
824
820
|
type: "decision",
|
|
825
821
|
decision: h,
|
|
826
822
|
controls: e,
|
|
827
|
-
loading:
|
|
828
|
-
handleOpenModal:
|
|
829
|
-
handleDelete:
|
|
830
|
-
textValues:
|
|
823
|
+
loading: n,
|
|
824
|
+
handleOpenModal: o,
|
|
825
|
+
handleDelete: l,
|
|
826
|
+
textValues: a
|
|
831
827
|
})
|
|
832
|
-
),
|
|
833
|
-
return { renderedCards:
|
|
828
|
+
), c = (t.length === 0 || t.length < Math.floor(window.innerWidth / 300)) && !n && e;
|
|
829
|
+
return { renderedCards: s, shouldRenderAddCard: c };
|
|
834
830
|
}
|
|
835
831
|
const mt = (e) => {
|
|
836
832
|
const {
|
|
837
833
|
controls: t = !0,
|
|
838
|
-
decisions:
|
|
839
|
-
textValues:
|
|
840
|
-
decisionTemplate:
|
|
841
|
-
isModalOpen:
|
|
842
|
-
selectedDecision:
|
|
843
|
-
loading:
|
|
834
|
+
decisions: n,
|
|
835
|
+
textValues: o,
|
|
836
|
+
decisionTemplate: l,
|
|
837
|
+
isModalOpen: a,
|
|
838
|
+
selectedDecision: s,
|
|
839
|
+
loading: c,
|
|
844
840
|
handleOpenModal: h,
|
|
845
|
-
handleCloseModal:
|
|
841
|
+
handleCloseModal: i,
|
|
846
842
|
handleSubmitForm: m,
|
|
847
843
|
handleDelete: p
|
|
848
|
-
} = e, f = ue("(max-width: 681px)"), { renderedCards: S, shouldRenderAddCard: A } =
|
|
844
|
+
} = e, f = ue("(max-width: 681px)"), { renderedCards: S, shouldRenderAddCard: A } = je({
|
|
849
845
|
controls: t,
|
|
850
|
-
decisions:
|
|
851
|
-
loading:
|
|
846
|
+
decisions: n,
|
|
847
|
+
loading: c,
|
|
852
848
|
handleOpenModal: h,
|
|
853
849
|
handleDelete: p,
|
|
854
|
-
textValues:
|
|
850
|
+
textValues: o
|
|
855
851
|
});
|
|
856
852
|
return /* @__PURE__ */ u(E, { children: [
|
|
857
|
-
/* @__PURE__ */ r($e, { children: /* @__PURE__ */ r(Fe, { children: /* @__PURE__ */ u(
|
|
858
|
-
|
|
853
|
+
/* @__PURE__ */ r($e, { children: /* @__PURE__ */ r(Fe, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "16px", padding: "6px", children: [
|
|
854
|
+
n.length === 0 && !c && /* @__PURE__ */ u(x, { as: "span", type: "label", size: "large", appearance: "gray", children: [
|
|
859
855
|
"Aún no tienes definidas tasas de interés efectivas. Presiona",
|
|
860
856
|
/* @__PURE__ */ r(
|
|
861
857
|
x,
|
|
@@ -886,30 +882,30 @@ const mt = (e) => {
|
|
|
886
882
|
S,
|
|
887
883
|
A && U({
|
|
888
884
|
type: "add",
|
|
889
|
-
index:
|
|
885
|
+
index: n.length,
|
|
890
886
|
controls: t,
|
|
891
|
-
loading:
|
|
887
|
+
loading: c,
|
|
892
888
|
handleOpenModal: h,
|
|
893
889
|
handleDelete: p,
|
|
894
|
-
textValues:
|
|
890
|
+
textValues: o
|
|
895
891
|
})
|
|
896
892
|
]
|
|
897
893
|
}
|
|
898
894
|
)
|
|
899
895
|
] }) }) }),
|
|
900
|
-
|
|
896
|
+
a && /* @__PURE__ */ r(
|
|
901
897
|
Ue,
|
|
902
898
|
{
|
|
903
899
|
portalId: "modal-portal",
|
|
904
|
-
onCloseModal:
|
|
905
|
-
title:
|
|
900
|
+
onCloseModal: i,
|
|
901
|
+
title: s ? "Editar Decisión" : "Nueva decisión",
|
|
906
902
|
children: /* @__PURE__ */ r(
|
|
907
903
|
we,
|
|
908
904
|
{
|
|
909
|
-
decision:
|
|
905
|
+
decision: s || l,
|
|
910
906
|
onSubmitEvent: m,
|
|
911
|
-
textValues:
|
|
912
|
-
onCancel: () =>
|
|
907
|
+
textValues: o,
|
|
908
|
+
onCancel: () => i()
|
|
913
909
|
}
|
|
914
910
|
)
|
|
915
911
|
}
|