jett.admin.npmpackage 2.0.24 → 2.0.26
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.css +1486 -1486
- package/dist/index.js +2114 -2113
- package/dist/index.mjs +2083 -2082
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2113 +1,2114 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/index.js
|
|
30
|
-
var index_exports = {};
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
AppSideBar: () => AppSideBar,
|
|
33
|
-
Calendar: () => Calendar,
|
|
34
|
-
Chip: () => Chip,
|
|
35
|
-
CustomAutocomplete: () => CustomAutocomplete,
|
|
36
|
-
CustomButton: () => CustomButton,
|
|
37
|
-
CustomCheckbox: () => CustomCheckbox,
|
|
38
|
-
CustomInput: () => CustomInput,
|
|
39
|
-
CustomSearch: () => CustomSearch,
|
|
40
|
-
CustomSelect: () => CustomSelect,
|
|
41
|
-
CustomSwitch: () => CustomSwitch,
|
|
42
|
-
CustomTable: () => CustomTable,
|
|
43
|
-
CustomTextarea: () => CustomTextarea,
|
|
44
|
-
CustomUpload: () => CustomUpload,
|
|
45
|
-
Dropdown: () => Dropdown,
|
|
46
|
-
Pagination: () => Pagination,
|
|
47
|
-
ProgressBar: () => ProgressBar,
|
|
48
|
-
RightSheet: () => RightSheet
|
|
49
|
-
});
|
|
50
|
-
module.exports = __toCommonJS(index_exports);
|
|
51
|
-
|
|
52
|
-
// src/utils/cn.ts
|
|
53
|
-
var import_clsx = require("clsx");
|
|
54
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
55
|
-
function cn(...inputs) {
|
|
56
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// src/Button.jsx
|
|
60
|
-
var import_react = __toESM(require("react"));
|
|
61
|
-
var variantStyles = {
|
|
62
|
-
PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
|
|
63
|
-
SECONDARY: "bg-primary text-white dark:text-white",
|
|
64
|
-
DEFAULT: "bg-white text-black dark:text-white",
|
|
65
|
-
DANGER: "bg-[#ef4444] text-white dark:text-white"
|
|
66
|
-
};
|
|
67
|
-
var CustomButton = ({
|
|
68
|
-
id = "button",
|
|
69
|
-
variant = "DEFAULT",
|
|
70
|
-
children,
|
|
71
|
-
className,
|
|
72
|
-
onClick,
|
|
73
|
-
disabled = false,
|
|
74
|
-
icon
|
|
75
|
-
}) => {
|
|
76
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
77
|
-
"div",
|
|
78
|
-
{
|
|
79
|
-
className: cn(
|
|
80
|
-
`cursor-pointer flex items-center py-2 px-3 min-h-10 justify-center border rounded-[6px] border-[#e5e5e5] dark:border-[#303036] ${variant == "DANGER" ? "bg-[#ef4444]" : "dark:bg-[#1d1d20]"} gap-2`,
|
|
81
|
-
variantStyles[variant],
|
|
82
|
-
className
|
|
83
|
-
),
|
|
84
|
-
onClick,
|
|
85
|
-
id: `${id}-div-1`
|
|
86
|
-
},
|
|
87
|
-
icon && /* @__PURE__ */ import_react.default.createElement("div", { id: `${id}-div-2` }, icon),
|
|
88
|
-
children
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// src/inputs/Autocomplete.jsx
|
|
93
|
-
var import_react2 = __toESM(require("react"));
|
|
94
|
-
var import_lucide_react = require("lucide-react");
|
|
95
|
-
var CustomAutocomplete = ({
|
|
96
|
-
id = "autocomplete",
|
|
97
|
-
label,
|
|
98
|
-
value,
|
|
99
|
-
onChange,
|
|
100
|
-
options,
|
|
101
|
-
placeholder = "Search & select...",
|
|
102
|
-
isRequired = false,
|
|
103
|
-
error,
|
|
104
|
-
heading,
|
|
105
|
-
disabled = false
|
|
106
|
-
}) => {
|
|
107
|
-
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
108
|
-
const [search, setSearch] = (0, import_react2.useState)("");
|
|
109
|
-
const wrapperRef = (0, import_react2.useRef)(null);
|
|
110
|
-
const selectedOptions = options.filter((opt) => value.includes(opt.value));
|
|
111
|
-
const handleBlur = (e) => {
|
|
112
|
-
var _a;
|
|
113
|
-
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
114
|
-
setOpen(false);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const filteredOptions = options.filter(
|
|
118
|
-
(opt) => opt.label.toLowerCase().includes(search.toLowerCase())
|
|
119
|
-
);
|
|
120
|
-
const toggleValue = (val) => {
|
|
121
|
-
if (value.includes(val)) {
|
|
122
|
-
onChange(value.filter((v) => v !== val));
|
|
123
|
-
} else {
|
|
124
|
-
onChange([...value, val]);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
128
|
-
"div",
|
|
129
|
-
{
|
|
130
|
-
className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
|
|
131
|
-
ref: wrapperRef,
|
|
132
|
-
tabIndex: disabled ? -1 : 0,
|
|
133
|
-
onBlur: handleBlur,
|
|
134
|
-
id: `${id}-div-1`
|
|
135
|
-
},
|
|
136
|
-
heading && /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
|
|
137
|
-
label && /* @__PURE__ */ import_react2.default.createElement(
|
|
138
|
-
"label",
|
|
139
|
-
{
|
|
140
|
-
className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
|
|
141
|
-
id: `${id}-label-1`
|
|
142
|
-
},
|
|
143
|
-
label,
|
|
144
|
-
" ",
|
|
145
|
-
isRequired && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
146
|
-
),
|
|
147
|
-
/* @__PURE__ */ import_react2.default.createElement(
|
|
148
|
-
"div",
|
|
149
|
-
{
|
|
150
|
-
onClick: () => {
|
|
151
|
-
if (!disabled) setOpen((prev) => !prev);
|
|
152
|
-
},
|
|
153
|
-
className: `flex justify-between items-center flex-wrap gap-1 rounded-md px-3 py-2 text-sm transition border dark:border-[#303036] h-auto min-h-10 dark:bg-[#18181b] dark:text-white
|
|
154
|
-
${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
|
|
155
|
-
${error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)] hover:border-gray-400 dark:bg-[#18181b] dark:text-white"}
|
|
156
|
-
`,
|
|
157
|
-
id: `${id}-div-2`
|
|
158
|
-
},
|
|
159
|
-
/* @__PURE__ */ import_react2.default.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ import_react2.default.createElement(
|
|
160
|
-
"span",
|
|
161
|
-
{
|
|
162
|
-
key: opt.value,
|
|
163
|
-
className: "bg-[#F7FAFC] dark:bg-[#303036] border border-gray-300 px-2 dark:text-white py-0.5 rounded text-xs flex items-center gap-1",
|
|
164
|
-
id: `${id}-span-2`
|
|
165
|
-
},
|
|
166
|
-
opt.label,
|
|
167
|
-
/* @__PURE__ */ import_react2.default.createElement(
|
|
168
|
-
"button",
|
|
169
|
-
{
|
|
170
|
-
onClick: (e) => {
|
|
171
|
-
e.stopPropagation();
|
|
172
|
-
toggleValue(opt.value);
|
|
173
|
-
},
|
|
174
|
-
className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
|
|
175
|
-
id: `${id}-button-1`
|
|
176
|
-
},
|
|
177
|
-
"\u2715"
|
|
178
|
-
)
|
|
179
|
-
)) : /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
|
|
180
|
-
/* @__PURE__ */ import_react2.default.createElement(
|
|
181
|
-
import_lucide_react.ChevronDown,
|
|
182
|
-
{
|
|
183
|
-
className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
),
|
|
187
|
-
!disabled && open && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react2.default.createElement(
|
|
188
|
-
"input",
|
|
189
|
-
{
|
|
190
|
-
type: "text",
|
|
191
|
-
value: search,
|
|
192
|
-
onChange: (e) => setSearch(e.target.value),
|
|
193
|
-
placeholder: "Search...",
|
|
194
|
-
className: "flex-1 text-sm focus:outline-none",
|
|
195
|
-
id: `${id}-input-1`
|
|
196
|
-
}
|
|
197
|
-
)), /* @__PURE__ */ import_react2.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
|
|
198
|
-
const selected = value.includes(opt.value);
|
|
199
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
200
|
-
"li",
|
|
201
|
-
{
|
|
202
|
-
key: opt.value,
|
|
203
|
-
onClick: () => toggleValue(opt.value),
|
|
204
|
-
className: `flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-[#F7FAFC] dark:hover:bg-[#303036] ${selected ? "bg-[#F7FAFC] dark:bg-[#303036] font-medium" : ""}`,
|
|
205
|
-
id: `${id}-li-1`
|
|
206
|
-
},
|
|
207
|
-
/* @__PURE__ */ import_react2.default.createElement(
|
|
208
|
-
"span",
|
|
209
|
-
{
|
|
210
|
-
className: `w-4 h-4 flex items-center justify-center border rounded-sm ${selected ? "bg-blue-600 border-blue-600 text-white" : "border-gray-300"}`,
|
|
211
|
-
id: `${id}-span-4`
|
|
212
|
-
},
|
|
213
|
-
selected && /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Check, { size: 14 })
|
|
214
|
-
),
|
|
215
|
-
opt.label
|
|
216
|
-
);
|
|
217
|
-
}) : /* @__PURE__ */ import_react2.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
|
|
218
|
-
);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// src/inputs/Checkbox.jsx
|
|
222
|
-
var import_react3 = __toESM(require("react"));
|
|
223
|
-
var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
|
|
224
|
-
const handleChange = (e) => {
|
|
225
|
-
onChange(e.target.checked);
|
|
226
|
-
};
|
|
227
|
-
return /* @__PURE__ */ import_react3.default.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ import_react3.default.createElement(
|
|
228
|
-
"input",
|
|
229
|
-
{
|
|
230
|
-
type: "checkbox",
|
|
231
|
-
checked,
|
|
232
|
-
onChange: handleChange,
|
|
233
|
-
className: "peer hidden",
|
|
234
|
-
id: `${id}-input-1`
|
|
235
|
-
}
|
|
236
|
-
), /* @__PURE__ */ import_react3.default.createElement(
|
|
237
|
-
"span",
|
|
238
|
-
{
|
|
239
|
-
className: "\r\n w-4 h-4 flex items-center justify-center border-2 border-gray-400 rounded \r\n peer-checked:bg-primary peer-checked:border-primary\r\n transition-colors\r\n ",
|
|
240
|
-
id: `${id}-span-1`
|
|
241
|
-
},
|
|
242
|
-
checked && /* @__PURE__ */ import_react3.default.createElement(
|
|
243
|
-
"svg",
|
|
244
|
-
{
|
|
245
|
-
className: "w-4 h-4 text-white",
|
|
246
|
-
fill: "none",
|
|
247
|
-
stroke: "currentColor",
|
|
248
|
-
strokeWidth: "3",
|
|
249
|
-
viewBox: "0 0 24 24",
|
|
250
|
-
id: `${id}-svg-1`
|
|
251
|
-
},
|
|
252
|
-
/* @__PURE__ */ import_react3.default.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
|
|
253
|
-
)
|
|
254
|
-
));
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
// src/inputs/Chip.jsx
|
|
258
|
-
var import_react4 = __toESM(require("react"));
|
|
259
|
-
var VARIANTS = {
|
|
260
|
-
PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
|
|
261
|
-
GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
|
|
262
|
-
RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
|
|
263
|
-
YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
|
|
264
|
-
};
|
|
265
|
-
var Chip = ({ id = "chip", label, variant }) => {
|
|
266
|
-
return /* @__PURE__ */ import_react4.default.createElement(
|
|
267
|
-
"div",
|
|
268
|
-
{
|
|
269
|
-
className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
|
|
270
|
-
id: `${id}-div-1`
|
|
271
|
-
},
|
|
272
|
-
label
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
// src/inputs/CustomSwitch.jsx
|
|
277
|
-
var import_react5 = __toESM(require("react"));
|
|
278
|
-
var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
|
|
279
|
-
return /* @__PURE__ */ import_react5.default.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ import_react5.default.createElement(
|
|
280
|
-
"button",
|
|
281
|
-
{
|
|
282
|
-
type: "button",
|
|
283
|
-
role: "switch",
|
|
284
|
-
"aria-checked": checked,
|
|
285
|
-
onClick: () => onChange(!checked),
|
|
286
|
-
className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
|
|
287
|
-
id: `${id}-button-1`
|
|
288
|
-
},
|
|
289
|
-
/* @__PURE__ */ import_react5.default.createElement(
|
|
290
|
-
"span",
|
|
291
|
-
{
|
|
292
|
-
className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
|
|
293
|
-
id: `${id}-span-1`
|
|
294
|
-
}
|
|
295
|
-
)
|
|
296
|
-
), /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ import_react5.default.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// src/inputs/Input.jsx
|
|
300
|
-
var import_react6 = __toESM(require("react"));
|
|
301
|
-
var CustomInput = ({
|
|
302
|
-
id = "input",
|
|
303
|
-
label,
|
|
304
|
-
isRequired,
|
|
305
|
-
value,
|
|
306
|
-
onChange,
|
|
307
|
-
placeholder,
|
|
308
|
-
disabled = false,
|
|
309
|
-
error,
|
|
310
|
-
heading
|
|
311
|
-
}) => {
|
|
312
|
-
return /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react6.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react6.default.createElement(
|
|
313
|
-
"label",
|
|
314
|
-
{
|
|
315
|
-
className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
|
|
316
|
-
id: `${id}-label-1`
|
|
317
|
-
},
|
|
318
|
-
label,
|
|
319
|
-
" ",
|
|
320
|
-
isRequired && /* @__PURE__ */ import_react6.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
321
|
-
), /* @__PURE__ */ import_react6.default.createElement(
|
|
322
|
-
"input",
|
|
323
|
-
{
|
|
324
|
-
className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
|
|
325
|
-
placeholder:text-[14px] placeholder:font-normal placeholder:text-[#6b7280]
|
|
326
|
-
focus:outline-2 outline-black dark:outline-white outline-offset-2
|
|
327
|
-
dark:bg-transparent dark:text-white dark:border-[#303036]
|
|
328
|
-
${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
|
|
329
|
-
`,
|
|
330
|
-
value,
|
|
331
|
-
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
332
|
-
placeholder,
|
|
333
|
-
disabled,
|
|
334
|
-
readOnly: disabled,
|
|
335
|
-
id: `${id}-input-1`
|
|
336
|
-
}
|
|
337
|
-
));
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
// src/inputs/ProgressBar.jsx
|
|
341
|
-
var import_react7 = __toESM(require("react"));
|
|
342
|
-
var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
|
|
343
|
-
const progress = step / totalSteps * 100;
|
|
344
|
-
return /* @__PURE__ */ import_react7.default.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ import_react7.default.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ import_react7.default.createElement(
|
|
345
|
-
"div",
|
|
346
|
-
{
|
|
347
|
-
className: "bg-black h-2 rounded-full transition-all duration-300",
|
|
348
|
-
style: { width: `${progress}%` },
|
|
349
|
-
id: `${id}-div-3`
|
|
350
|
-
}
|
|
351
|
-
)));
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
// src/inputs/Search.jsx
|
|
355
|
-
var import_react8 = __toESM(require("react"));
|
|
356
|
-
var import_lucide_react2 = require("lucide-react");
|
|
357
|
-
var CustomSearch = ({
|
|
358
|
-
id = "search",
|
|
359
|
-
value,
|
|
360
|
-
onChange,
|
|
361
|
-
placeholder = "Search Markets..."
|
|
362
|
-
}) => {
|
|
363
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ import_react8.default.createElement(import_lucide_react2.Search, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ import_react8.default.createElement(
|
|
364
|
-
"input",
|
|
365
|
-
{
|
|
366
|
-
type: "text",
|
|
367
|
-
value,
|
|
368
|
-
onChange,
|
|
369
|
-
placeholder,
|
|
370
|
-
className: "bg-transparent w-full h-full focus:outline-none",
|
|
371
|
-
id: `${id}-input-1`
|
|
372
|
-
}
|
|
373
|
-
));
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
// src/inputs/TextArea.jsx
|
|
377
|
-
var import_react9 = __toESM(require("react"));
|
|
378
|
-
var CustomTextarea = ({
|
|
379
|
-
id = "text-area",
|
|
380
|
-
label,
|
|
381
|
-
isRequired,
|
|
382
|
-
value,
|
|
383
|
-
onChange,
|
|
384
|
-
placeholder,
|
|
385
|
-
disabled = false,
|
|
386
|
-
error,
|
|
387
|
-
heading,
|
|
388
|
-
rows = 4
|
|
389
|
-
}) => {
|
|
390
|
-
return /* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react9.default.createElement(
|
|
391
|
-
"label",
|
|
392
|
-
{
|
|
393
|
-
className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
|
|
394
|
-
id: `${id}-label-1`
|
|
395
|
-
},
|
|
396
|
-
label,
|
|
397
|
-
" ",
|
|
398
|
-
isRequired && /* @__PURE__ */ import_react9.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
399
|
-
), /* @__PURE__ */ import_react9.default.createElement(
|
|
400
|
-
"textarea",
|
|
401
|
-
{
|
|
402
|
-
rows,
|
|
403
|
-
className: `border rounded-md px-4 py-2 w-full text-[14px]
|
|
404
|
-
focus:outline-2 focus:outline-black focus:outline-offset-2
|
|
405
|
-
focus:ring-0 focus:shadow-none focus:border-black
|
|
406
|
-
${disabled ? "bg-gray-100 text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
|
|
407
|
-
`,
|
|
408
|
-
value,
|
|
409
|
-
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
410
|
-
placeholder,
|
|
411
|
-
disabled,
|
|
412
|
-
readOnly: disabled,
|
|
413
|
-
id: `${id}-textarea-1`
|
|
414
|
-
}
|
|
415
|
-
));
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
// src/inputs/Upload.jsx
|
|
419
|
-
var import_react10 = __toESM(require("react"));
|
|
420
|
-
var import_lucide_react3 = require("lucide-react");
|
|
421
|
-
var CustomUpload = ({
|
|
422
|
-
id = "upload",
|
|
423
|
-
label = "Supporting documents",
|
|
424
|
-
description = "Drop items here or Browse Files",
|
|
425
|
-
accept = ".pdf,.jpg,.jpeg,.png",
|
|
426
|
-
maxSizeMB = 5,
|
|
427
|
-
onChange,
|
|
428
|
-
error,
|
|
429
|
-
value
|
|
430
|
-
}) => {
|
|
431
|
-
const inputRef = (0, import_react10.useRef)(null);
|
|
432
|
-
const handleFileSelect = (files) => {
|
|
433
|
-
if (!files || files.length === 0) return;
|
|
434
|
-
const selectedFile = files[0];
|
|
435
|
-
if (selectedFile.size > maxSizeMB * 1024 * 1024) {
|
|
436
|
-
alert(`File size must be less than ${maxSizeMB} MB`);
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
onChange == null ? void 0 : onChange(selectedFile);
|
|
440
|
-
};
|
|
441
|
-
return /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ import_react10.default.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ import_react10.default.createElement(
|
|
442
|
-
"div",
|
|
443
|
-
{
|
|
444
|
-
className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
|
|
445
|
-
${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
|
|
446
|
-
onClick: () => {
|
|
447
|
-
var _a;
|
|
448
|
-
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
449
|
-
},
|
|
450
|
-
onDragOver: (e) => e.preventDefault(),
|
|
451
|
-
onDrop: (e) => {
|
|
452
|
-
e.preventDefault();
|
|
453
|
-
handleFileSelect(e.dataTransfer.files);
|
|
454
|
-
},
|
|
455
|
-
id: `${id}-div-2`
|
|
456
|
-
},
|
|
457
|
-
/* @__PURE__ */ import_react10.default.createElement(import_lucide_react3.Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
|
|
458
|
-
/* @__PURE__ */ import_react10.default.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
|
|
459
|
-
/* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
|
|
460
|
-
/* @__PURE__ */ import_react10.default.createElement(
|
|
461
|
-
"input",
|
|
462
|
-
{
|
|
463
|
-
ref: inputRef,
|
|
464
|
-
type: "file",
|
|
465
|
-
accept,
|
|
466
|
-
className: "hidden",
|
|
467
|
-
onChange: (e) => handleFileSelect(e.target.files),
|
|
468
|
-
id: `${id}-input-1`
|
|
469
|
-
}
|
|
470
|
-
)
|
|
471
|
-
), value && /* @__PURE__ */ import_react10.default.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
// src/sideBar/SideBar.jsx
|
|
475
|
-
var import_lucide_react8 = require("lucide-react");
|
|
476
|
-
var import_react14 = __toESM(require("react"));
|
|
477
|
-
|
|
478
|
-
// ConstantUI.js
|
|
479
|
-
var import_lucide_react4 = require("lucide-react");
|
|
480
|
-
var encodedAuthData = localStorage.getItem("encodedAuthData");
|
|
481
|
-
var navItemsConstant = [
|
|
482
|
-
{
|
|
483
|
-
Icon: import_lucide_react4.Home,
|
|
484
|
-
label: "Home",
|
|
485
|
-
onClick: () => {
|
|
486
|
-
window.location.href = "/";
|
|
487
|
-
},
|
|
488
|
-
isDropDown: false
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
Icon: import_lucide_react4.Building,
|
|
492
|
-
label: "Consumer Ecosystem",
|
|
493
|
-
onClick: () => {
|
|
494
|
-
},
|
|
495
|
-
options: [
|
|
496
|
-
{
|
|
497
|
-
label: "Corporate",
|
|
498
|
-
onClick: () => {
|
|
499
|
-
window.location.href = "/corporate/";
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
label: "Trips",
|
|
504
|
-
onClick: () => {
|
|
505
|
-
window.location.href = "/corporate/trips/";
|
|
506
|
-
}
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
label: "Users",
|
|
510
|
-
onClick: () => {
|
|
511
|
-
window.location.href = "/users/users";
|
|
512
|
-
}
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
label: "Tags (Custom Variables)",
|
|
516
|
-
onClick: () => {
|
|
517
|
-
window.location.href = "/orgselector/?path=tag";
|
|
518
|
-
}
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
label: "Special Request",
|
|
522
|
-
onClick: () => {
|
|
523
|
-
window.location.href = "/orgselector/?path=special-requests";
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
label: "Support Tickets (Coming Soon)",
|
|
528
|
-
isDisabled: true
|
|
529
|
-
// onClick: () => {},
|
|
530
|
-
}
|
|
531
|
-
],
|
|
532
|
-
isDropDown: true
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
Icon: import_lucide_react4.Banknote,
|
|
536
|
-
label: "Finance",
|
|
537
|
-
onClick: () => {
|
|
538
|
-
},
|
|
539
|
-
isDropDown: true,
|
|
540
|
-
options: [
|
|
541
|
-
{
|
|
542
|
-
label: "Credit Management",
|
|
543
|
-
onClick: () => {
|
|
544
|
-
window.location.href = "/finance/paymentsLedger/";
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
label: "Booking & Invoices",
|
|
549
|
-
onClick: () => {
|
|
550
|
-
window.location.href = "/finance/bookingHistory/";
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
]
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
Icon: import_lucide_react4.DollarSign,
|
|
557
|
-
label: "Revenue Management",
|
|
558
|
-
onClick: () => {
|
|
559
|
-
},
|
|
560
|
-
isDropDown: true,
|
|
561
|
-
options: [
|
|
562
|
-
{
|
|
563
|
-
label: "Pricing Engine",
|
|
564
|
-
onClick: () => {
|
|
565
|
-
window.location.href = "/orgselector/?path=pricing-policy";
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
label: "Offers",
|
|
570
|
-
onClick: () => {
|
|
571
|
-
window.location.href = "/orgselector/?path=offer";
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
label: "Vouchers",
|
|
576
|
-
onClick: () => {
|
|
577
|
-
window.location.href = "/orgselector/?path=voucher";
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
]
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
Icon: import_lucide_react4.Handshake,
|
|
584
|
-
label: "Supplier Ecosystem",
|
|
585
|
-
onClick: () => {
|
|
586
|
-
},
|
|
587
|
-
isDropDown: true,
|
|
588
|
-
options: [
|
|
589
|
-
{
|
|
590
|
-
label: "Suppliers List",
|
|
591
|
-
onClick: () => {
|
|
592
|
-
window.location.href = "/orgselector/?path=supplier-list";
|
|
593
|
-
}
|
|
594
|
-
},
|
|
595
|
-
{
|
|
596
|
-
label: "Supplier Deals",
|
|
597
|
-
onClick: () => {
|
|
598
|
-
window.location.href = "/supplierdeals/";
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
]
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
Icon: import_lucide_react4.BarChart3,
|
|
605
|
-
label: "Reports",
|
|
606
|
-
onClick: () => {
|
|
607
|
-
},
|
|
608
|
-
isDropDown: true,
|
|
609
|
-
options: [
|
|
610
|
-
{
|
|
611
|
-
label: "Reports
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
]
|
|
650
|
-
}
|
|
651
|
-
];
|
|
652
|
-
var additionalItemsConstant = [
|
|
653
|
-
{
|
|
654
|
-
Icon: import_lucide_react4.LifeBuoy,
|
|
655
|
-
label: "Help",
|
|
656
|
-
onClick: () => {
|
|
657
|
-
window.location.href = "/help";
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
];
|
|
661
|
-
|
|
662
|
-
// src/sideBar/SideBar.jsx
|
|
663
|
-
var import_js_cookie = __toESM(require("js-cookie"));
|
|
664
|
-
|
|
665
|
-
// src/inputs/CustomSelect.jsx
|
|
666
|
-
var import_react11 = __toESM(require("react"));
|
|
667
|
-
var import_lucide_react5 = require("lucide-react");
|
|
668
|
-
var CustomSelect = ({
|
|
669
|
-
id = "custom-select",
|
|
670
|
-
label,
|
|
671
|
-
value,
|
|
672
|
-
onChange,
|
|
673
|
-
options,
|
|
674
|
-
placeholder = "Select...",
|
|
675
|
-
isRequired = false,
|
|
676
|
-
error,
|
|
677
|
-
heading,
|
|
678
|
-
disabled = false
|
|
679
|
-
}) => {
|
|
680
|
-
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
681
|
-
const [search, setSearch] = (0, import_react11.useState)("");
|
|
682
|
-
const wrapperRef = (0, import_react11.useRef)(null);
|
|
683
|
-
const handleBlur = (e) => {
|
|
684
|
-
var _a;
|
|
685
|
-
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
686
|
-
setOpen(false);
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
const filteredOptions = options.filter(
|
|
690
|
-
(opt) => opt.label.toLowerCase().includes(search.toLowerCase())
|
|
691
|
-
);
|
|
692
|
-
const handleSelect = (val) => {
|
|
693
|
-
onChange(val);
|
|
694
|
-
setOpen(false);
|
|
695
|
-
};
|
|
696
|
-
const selectedOption = options.find((opt) => opt.value === value);
|
|
697
|
-
return /* @__PURE__ */ import_react11.default.createElement(
|
|
698
|
-
"div",
|
|
699
|
-
{
|
|
700
|
-
className: "flex flex-col w-full relative",
|
|
701
|
-
ref: wrapperRef,
|
|
702
|
-
tabIndex: disabled ? -1 : 0,
|
|
703
|
-
onBlur: handleBlur,
|
|
704
|
-
id: `${id}-div-1`
|
|
705
|
-
},
|
|
706
|
-
heading && /* @__PURE__ */ import_react11.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
|
|
707
|
-
label && /* @__PURE__ */ import_react11.default.createElement(
|
|
708
|
-
"label",
|
|
709
|
-
{
|
|
710
|
-
className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
|
|
711
|
-
id: `${id}-label-1`
|
|
712
|
-
},
|
|
713
|
-
label,
|
|
714
|
-
" ",
|
|
715
|
-
isRequired && /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
716
|
-
),
|
|
717
|
-
/* @__PURE__ */ import_react11.default.createElement(
|
|
718
|
-
"div",
|
|
719
|
-
{
|
|
720
|
-
onClick: () => !disabled && setOpen((prev) => !prev),
|
|
721
|
-
className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
|
|
722
|
-
${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
|
|
723
|
-
${error ? "border-red-500" : "border-gray-300"}
|
|
724
|
-
`,
|
|
725
|
-
id: `${id}-div-2`
|
|
726
|
-
},
|
|
727
|
-
/* @__PURE__ */ import_react11.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
|
|
728
|
-
/* @__PURE__ */ import_react11.default.createElement(
|
|
729
|
-
import_lucide_react5.ChevronDown,
|
|
730
|
-
{
|
|
731
|
-
className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
|
|
732
|
-
}
|
|
733
|
-
)
|
|
734
|
-
),
|
|
735
|
-
open && !disabled && /* @__PURE__ */ import_react11.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react11.default.createElement(
|
|
736
|
-
"input",
|
|
737
|
-
{
|
|
738
|
-
type: "text",
|
|
739
|
-
value: search,
|
|
740
|
-
onChange: (e) => setSearch(e.target.value),
|
|
741
|
-
placeholder: "Search...",
|
|
742
|
-
className: "flex-1 text-sm focus:outline-none",
|
|
743
|
-
id: `${id}-input-1`
|
|
744
|
-
}
|
|
745
|
-
)), /* @__PURE__ */ import_react11.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react11.default.createElement(
|
|
746
|
-
"li",
|
|
747
|
-
{
|
|
748
|
-
key: opt.value,
|
|
749
|
-
onClick: () => handleSelect(opt.value),
|
|
750
|
-
className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
|
|
751
|
-
id: `${id}-li-1`
|
|
752
|
-
},
|
|
753
|
-
opt.label
|
|
754
|
-
)) : /* @__PURE__ */ import_react11.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
|
|
755
|
-
);
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
// src/utils/cookieHelpers.js
|
|
759
|
-
var JETT_ID_COOKIE_NAME = "jett-id";
|
|
760
|
-
function getCookie(name) {
|
|
761
|
-
if (typeof document === "undefined" || !document.cookie) return null;
|
|
762
|
-
const match = document.cookie.match(
|
|
763
|
-
new RegExp("(^|\\s)" + name + "=([^;]+)")
|
|
764
|
-
);
|
|
765
|
-
return match ? decodeURIComponent(match[2].trim()) : null;
|
|
766
|
-
}
|
|
767
|
-
function decodeBase64(value) {
|
|
768
|
-
try {
|
|
769
|
-
let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
770
|
-
const pad = base64.length % 4;
|
|
771
|
-
if (pad) base64 += "=".repeat(4 - pad);
|
|
772
|
-
return atob(base64);
|
|
773
|
-
} catch {
|
|
774
|
-
return "";
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
function getJettIdCookieData() {
|
|
778
|
-
const raw = getCookie(JETT_ID_COOKIE_NAME);
|
|
779
|
-
if (!raw) return null;
|
|
780
|
-
try {
|
|
781
|
-
const decoded = decodeBase64(raw);
|
|
782
|
-
if (!decoded) return null;
|
|
783
|
-
const data = JSON.parse(decoded);
|
|
784
|
-
return data && typeof data === "object" ? data : null;
|
|
785
|
-
} catch {
|
|
786
|
-
return null;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
function getLogoFromJettIdCookie() {
|
|
790
|
-
const data = getJettIdCookieData();
|
|
791
|
-
if (!(data == null ? void 0 : data.CDNBasePath)) return null;
|
|
792
|
-
const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
|
|
793
|
-
if (!logoPath) return null;
|
|
794
|
-
return {
|
|
795
|
-
logoPath,
|
|
796
|
-
CDNBasePath: data.CDNBasePath
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
function getScopeFromJettIdCookie() {
|
|
800
|
-
const data = getJettIdCookieData();
|
|
801
|
-
return (data == null ? void 0 : data.Scope) ?? null;
|
|
802
|
-
}
|
|
803
|
-
function getProfilesFromJettIdCookie(all) {
|
|
804
|
-
const data = getJettIdCookieData();
|
|
805
|
-
if (!(data == null ? void 0 : data.Profiles)) return [];
|
|
806
|
-
if (all) return data.Profiles;
|
|
807
|
-
return data.Profiles.filter((profile) => {
|
|
808
|
-
var _a;
|
|
809
|
-
return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
function buildLogoUrl(CDNBasePath, logoPath) {
|
|
813
|
-
const base = (CDNBasePath || "").replace(/\/$/, "");
|
|
814
|
-
const path = (logoPath || "").replace(/^\//, "");
|
|
815
|
-
if (!base || !path) return "";
|
|
816
|
-
return `${base}/${path}`;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
// src/sideBar/SwitchProfileSection.jsx
|
|
820
|
-
var import_react13 = __toESM(require("react"));
|
|
821
|
-
var import_react_dom2 = require("react-dom");
|
|
822
|
-
var import_lucide_react7 = require("lucide-react");
|
|
823
|
-
|
|
824
|
-
// src/sideBar/LogoutConfirmModal.jsx
|
|
825
|
-
var import_react12 = __toESM(require("react"));
|
|
826
|
-
var import_react_dom = require("react-dom");
|
|
827
|
-
var import_lucide_react6 = require("lucide-react");
|
|
828
|
-
var LogoutConfirmModal = ({
|
|
829
|
-
id = "logout-confirm",
|
|
830
|
-
open,
|
|
831
|
-
onConfirm,
|
|
832
|
-
onCancel,
|
|
833
|
-
loading = false
|
|
834
|
-
}) => {
|
|
835
|
-
if (!open || typeof document === "undefined") return null;
|
|
836
|
-
const handleOverlayClick = (e) => {
|
|
837
|
-
if (e.target === e.currentTarget && !loading) onCancel();
|
|
838
|
-
};
|
|
839
|
-
return (0, import_react_dom.createPortal)(
|
|
840
|
-
/* @__PURE__ */ import_react12.default.createElement(
|
|
841
|
-
"div",
|
|
842
|
-
{
|
|
843
|
-
className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
|
|
844
|
-
onClick: handleOverlayClick,
|
|
845
|
-
id: `${id}-overlay`
|
|
846
|
-
},
|
|
847
|
-
/* @__PURE__ */ import_react12.default.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ import_react12.default.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
848
|
-
"button",
|
|
849
|
-
{
|
|
850
|
-
type: "button",
|
|
851
|
-
onClick: onCancel,
|
|
852
|
-
disabled: loading,
|
|
853
|
-
className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
|
|
854
|
-
id: `${id}-cancel-button`
|
|
855
|
-
},
|
|
856
|
-
"No, Keep me in"
|
|
857
|
-
), /* @__PURE__ */ import_react12.default.createElement(
|
|
858
|
-
"button",
|
|
859
|
-
{
|
|
860
|
-
type: "button",
|
|
861
|
-
onClick: onConfirm,
|
|
862
|
-
disabled: loading,
|
|
863
|
-
className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
|
|
864
|
-
id: `${id}-confirm-button`
|
|
865
|
-
},
|
|
866
|
-
loading ? "Logging out..." : "Yes, logout"
|
|
867
|
-
)))
|
|
868
|
-
),
|
|
869
|
-
document.body
|
|
870
|
-
);
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
// src/utils/switchProfileEncryption.js
|
|
874
|
-
var import_node_forge = __toESM(require("node-forge"));
|
|
875
|
-
var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
|
|
876
|
-
var RSA_EXPONENT_BASE64 = "AQAB";
|
|
877
|
-
var convertModulusExponentToPem = (modulus, exponent) => {
|
|
878
|
-
const decodedModulus = import_node_forge.default.util.decode64(modulus);
|
|
879
|
-
const decodedExponent = import_node_forge.default.util.decode64(exponent);
|
|
880
|
-
const publicKey = import_node_forge.default.pki.setRsaPublicKey(
|
|
881
|
-
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
|
|
882
|
-
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
|
|
883
|
-
);
|
|
884
|
-
return import_node_forge.default.pki.publicKeyToPem(publicKey);
|
|
885
|
-
};
|
|
886
|
-
var cachedPemKey = null;
|
|
887
|
-
var getPemKey = () => {
|
|
888
|
-
if (!cachedPemKey) {
|
|
889
|
-
cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
|
|
890
|
-
}
|
|
891
|
-
return cachedPemKey;
|
|
892
|
-
};
|
|
893
|
-
var encryptForSwitchProfile = (plainText) => {
|
|
894
|
-
const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
|
|
895
|
-
const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
|
|
896
|
-
return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
// src/sideBar/SwitchProfileSection.jsx
|
|
900
|
-
var SwitchProfileSection = ({
|
|
901
|
-
id = "switch-profile",
|
|
902
|
-
open,
|
|
903
|
-
anchorRef,
|
|
904
|
-
onClose,
|
|
905
|
-
onManageProfile,
|
|
906
|
-
onProfileSwitch,
|
|
907
|
-
onTmcSettings,
|
|
908
|
-
onLogout
|
|
909
|
-
}) => {
|
|
910
|
-
const [position, setPosition] = (0, import_react13.useState)(null);
|
|
911
|
-
const [showLogoutConfirm, setShowLogoutConfirm] = (0, import_react13.useState)(false);
|
|
912
|
-
const [switchingProfileId, setSwitchingProfileId] = (0, import_react13.useState)(null);
|
|
913
|
-
const [switchError, setSwitchError] = (0, import_react13.useState)(null);
|
|
914
|
-
(0, import_react13.useLayoutEffect)(() => {
|
|
915
|
-
if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
|
|
916
|
-
const updatePosition = () => {
|
|
917
|
-
const rect = anchorRef.current.getBoundingClientRect();
|
|
918
|
-
setPosition({
|
|
919
|
-
left: rect.right + 2,
|
|
920
|
-
bottom: window.innerHeight - rect.bottom
|
|
921
|
-
});
|
|
922
|
-
};
|
|
923
|
-
updatePosition();
|
|
924
|
-
window.addEventListener("resize", updatePosition);
|
|
925
|
-
window.addEventListener("scroll", updatePosition, true);
|
|
926
|
-
return () => {
|
|
927
|
-
window.removeEventListener("resize", updatePosition);
|
|
928
|
-
window.removeEventListener("scroll", updatePosition, true);
|
|
929
|
-
};
|
|
930
|
-
}, [open, anchorRef]);
|
|
931
|
-
(0, import_react13.useEffect)(() => {
|
|
932
|
-
if (!open) setSwitchError(null);
|
|
933
|
-
}, [open]);
|
|
934
|
-
(0, import_react13.useEffect)(() => {
|
|
935
|
-
if (!switchError) return;
|
|
936
|
-
const timer = setTimeout(() => setSwitchError(null), 5e3);
|
|
937
|
-
return () => clearTimeout(timer);
|
|
938
|
-
}, [switchError]);
|
|
939
|
-
if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
|
|
940
|
-
const jettIdData = getJettIdCookieData();
|
|
941
|
-
const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
|
|
942
|
-
const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
|
|
943
|
-
const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
|
|
944
|
-
const allMarkets = getProfilesFromJettIdCookie(true);
|
|
945
|
-
const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
|
|
946
|
-
const handleConfirmLogout = () => {
|
|
947
|
-
setShowLogoutConfirm(false);
|
|
948
|
-
onLogout == null ? void 0 : onLogout();
|
|
949
|
-
};
|
|
950
|
-
const buildRequestContext = () => ({
|
|
951
|
-
UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
|
|
952
|
-
TrackingId: crypto.randomUUID(),
|
|
953
|
-
TransactionId: crypto.randomUUID(),
|
|
954
|
-
CountryCode: "IN",
|
|
955
|
-
IpAddress: "127.0.0.1"
|
|
956
|
-
// Client IP cannot be retrieved from browser
|
|
957
|
-
});
|
|
958
|
-
const handleProfileSwitch = async (profile) => {
|
|
959
|
-
var _a, _b, _c;
|
|
960
|
-
if (switchingProfileId) return;
|
|
961
|
-
setSwitchingProfileId(profile.ProfileId);
|
|
962
|
-
setSwitchError(null);
|
|
963
|
-
try {
|
|
964
|
-
const encryptedRequest = encryptForSwitchProfile(
|
|
965
|
-
JSON.stringify({
|
|
966
|
-
ProfileToken: profile.ProfileToken,
|
|
967
|
-
ProfileId: profile.ProfileId
|
|
968
|
-
})
|
|
969
|
-
);
|
|
970
|
-
const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
|
|
971
|
-
method: "POST",
|
|
972
|
-
credentials: "include",
|
|
973
|
-
headers: { "Content-Type": "application/json" },
|
|
974
|
-
body: JSON.stringify({
|
|
975
|
-
Context: buildRequestContext(),
|
|
976
|
-
Request: encryptedRequest
|
|
977
|
-
})
|
|
978
|
-
}).then((res) => res.json());
|
|
979
|
-
const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
|
|
980
|
-
const isSuccess = !statusCode || statusCode === 200;
|
|
981
|
-
if (!isSuccess) {
|
|
982
|
-
setSwitchError(((_b = response == null ? void 0 : response.Context) == null ? void 0 : _b.Message) || "Unable to switch profile. Please try again.");
|
|
983
|
-
setSwitchingProfileId(null);
|
|
984
|
-
return;
|
|
985
|
-
}
|
|
986
|
-
if ((_c = response == null ? void 0 : response.Response) == null ? void 0 : _c.RedirectUrl) {
|
|
987
|
-
window.location.href = response.Response.RedirectUrl;
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
setSwitchingProfileId(null);
|
|
991
|
-
onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
|
|
992
|
-
} catch (error) {
|
|
993
|
-
console.error("Switch profile request failed:", error);
|
|
994
|
-
setSwitchError("Something went wrong while switching profile. Please try again.");
|
|
995
|
-
setSwitchingProfileId(null);
|
|
996
|
-
}
|
|
997
|
-
};
|
|
998
|
-
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, open && (0, import_react_dom2.createPortal)(
|
|
999
|
-
/* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop` }), /* @__PURE__ */ import_react13.default.createElement(
|
|
1000
|
-
"div",
|
|
1001
|
-
{
|
|
1002
|
-
className: "fixed w-[320px] max-h-[75vh] flex p-4 flex-col overflow-hidden bg-white dark:bg-[#18181b] rounded-xl shadow-xl border border-gray-200 dark:border-[#303036] z-[9999]",
|
|
1003
|
-
style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
|
|
1004
|
-
id: `${id}-panel`
|
|
1005
|
-
},
|
|
1006
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between gap-3 pb-4", id: `${id}-header` }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center gap-3 min-w-0", id: `${id}-header-user` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden rounded-full h-10 w-10", id: `${id}-avatar` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border-2 border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white" }, userName ? userName.charAt(0) : "40 * 40")), /* @__PURE__ */ import_react13.default.createElement("div", { className: "min-w-0", id: `${id}-header-text` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "!font-semibold dark:text-white !text-[14px] truncate" }, userName || "Admin"), /* @__PURE__ */ import_react13.default.createElement("p", { className: "!text-[10px] !font-normal text-gray-500 dark:text-[#f4f4f5cc] truncate" }, userEmail))), /* @__PURE__ */ import_react13.default.createElement(
|
|
1007
|
-
"button",
|
|
1008
|
-
{
|
|
1009
|
-
type: "button",
|
|
1010
|
-
onClick: onManageProfile,
|
|
1011
|
-
className: "shrink-0 whitespace-nowrap rounded-md border border-gray-300 dark:border-[#303036] px-3 py-1.5 text-[10px] font-bold uppercase tracking-wide text-[#0A0A0A] dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors duration-200",
|
|
1012
|
-
id: `${id}-manage-profile-button`
|
|
1013
|
-
},
|
|
1014
|
-
"Manage Profile"
|
|
1015
|
-
)),
|
|
1016
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
|
|
1017
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "pb-4 text-[10px] font-bold tracking-wider text-[#737373] uppercase", id: `${id}-markets-label` }, "Your Markets"), switchError && /* @__PURE__ */ import_react13.default.createElement(
|
|
1018
|
-
"div",
|
|
1019
|
-
{
|
|
1020
|
-
className: "mb-3 rounded-lg border border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-[12px] font-medium text-red-600",
|
|
1021
|
-
id: `${id}-switch-error`
|
|
1022
|
-
},
|
|
1023
|
-
switchError
|
|
1024
|
-
), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-2 pb-4", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react13.default.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
|
|
1025
|
-
const isCurrent = profile.ProfileId === currentProfileId;
|
|
1026
|
-
const isSwitching = switchingProfileId === profile.ProfileId;
|
|
1027
|
-
return /* @__PURE__ */ import_react13.default.createElement(
|
|
1028
|
-
"div",
|
|
1029
|
-
{
|
|
1030
|
-
key: profile.ProfileId,
|
|
1031
|
-
onClick: () => !isCurrent && handleProfileSwitch(profile),
|
|
1032
|
-
"aria-disabled": isSwitching,
|
|
1033
|
-
className: `flex items-center justify-between gap-2 rounded-lg p-3 cursor-pointer hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] transition-colors duration-200 ${isCurrent ? "border border-gray-800 dark:border-white bg-[#f4f4f5] text-[#0A0A0A]" : "border border-transparent"} ${isSwitching ? "opacity-50 pointer-events-none" : ""}`,
|
|
1034
|
-
id: `${id}-market-${profile.ProfileId}`
|
|
1035
|
-
},
|
|
1036
|
-
/* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-bold !text-[14px] text-gray-900 dark:text-[#f4f4f5cc] truncate" }, profile.EntityName),
|
|
1037
|
-
isCurrent && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 rounded-full bg-blue-600 px-2.5 py-0.5 border-2 border-white text-[9px] font-bold uppercase tracking-wide text-white" }, "Logged In"),
|
|
1038
|
-
isSwitching && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 text-[11px] text-gray-400" }, "Switching...")
|
|
1039
|
-
);
|
|
1040
|
-
}))),
|
|
1041
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
|
|
1042
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "", id: `${id}-footer` }, /* @__PURE__ */ import_react13.default.createElement(
|
|
1043
|
-
"div",
|
|
1044
|
-
{
|
|
1045
|
-
onClick: () => {
|
|
1046
|
-
onClose == null ? void 0 : onClose();
|
|
1047
|
-
setShowLogoutConfirm(true);
|
|
1048
|
-
},
|
|
1049
|
-
className: "flex items-center gap-3 p-3 rounded-lg cursor-pointer text-red-600 hover:bg-red-50 dark:hover:bg-[#27272a] transition-colors duration-200",
|
|
1050
|
-
id: `${id}-logout`
|
|
1051
|
-
},
|
|
1052
|
-
/* @__PURE__ */ import_react13.default.createElement(import_lucide_react7.LogOut, { width: 18, height: 18 }),
|
|
1053
|
-
/* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-bold !text-[14px]" }, "Logout")
|
|
1054
|
-
))
|
|
1055
|
-
)),
|
|
1056
|
-
document.body
|
|
1057
|
-
), /* @__PURE__ */ import_react13.default.createElement(
|
|
1058
|
-
LogoutConfirmModal,
|
|
1059
|
-
{
|
|
1060
|
-
id: `${id}-logout-confirm`,
|
|
1061
|
-
open: showLogoutConfirm,
|
|
1062
|
-
onCancel: () => setShowLogoutConfirm(false),
|
|
1063
|
-
onConfirm: handleConfirmLogout
|
|
1064
|
-
}
|
|
1065
|
-
));
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
// src/sideBar/SideBar.jsx
|
|
1069
|
-
var SCOPE_LABELS = {
|
|
1070
|
-
TMC: "TMC Manager",
|
|
1071
|
-
TMC_ENTITY: "TMC Entity Manager"
|
|
1072
|
-
};
|
|
1073
|
-
var AppSideBar = ({
|
|
1074
|
-
id = "side-bar",
|
|
1075
|
-
username,
|
|
1076
|
-
navItems,
|
|
1077
|
-
additionalItems,
|
|
1078
|
-
sideBarLogo,
|
|
1079
|
-
onManageProfile,
|
|
1080
|
-
onProfileSwitch,
|
|
1081
|
-
onTmcSettings,
|
|
1082
|
-
onLogout
|
|
1083
|
-
}) => {
|
|
1084
|
-
var _a, _b;
|
|
1085
|
-
const profileCardRef = (0, import_react14.useRef)(null);
|
|
1086
|
-
const [authData, setAuthData] = (0, import_react14.useState)(null);
|
|
1087
|
-
const [cookieUserName, setCookieUserName] = (0, import_react14.useState)(null);
|
|
1088
|
-
const [scope, setScope] = (0, import_react14.useState)(null);
|
|
1089
|
-
const [selectedCountry, setSelectedCountry] = (0, import_react14.useState)("dubai");
|
|
1090
|
-
const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react14.useState)(false);
|
|
1091
|
-
const [isSwitchProfileOpen, setIsSwitchProfileOpen] = (0, import_react14.useState)(false);
|
|
1092
|
-
const [openMenus, setOpenMenus] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
|
|
1093
|
-
const [activeMenuPath, setActiveMenuPath] = (0, import_react14.useState)(null);
|
|
1094
|
-
const [currAppearance, setCurrAppearance] = (0, import_react14.useState)("light");
|
|
1095
|
-
(0, import_react14.useEffect)(() => {
|
|
1096
|
-
setCurrAppearance("light");
|
|
1097
|
-
}, []);
|
|
1098
|
-
const countryOptions = [
|
|
1099
|
-
{ label: "India", value: "india" },
|
|
1100
|
-
{ label: "Dubai", value: "dubai" },
|
|
1101
|
-
{ label: "Singapore", value: "singapore" },
|
|
1102
|
-
{ label: "Qatar", value: "qatar" }
|
|
1103
|
-
];
|
|
1104
|
-
const toggleMenu = (menuKey) => {
|
|
1105
|
-
setOpenMenus((prev) => {
|
|
1106
|
-
const newSet = new Set(prev);
|
|
1107
|
-
if (newSet.has(menuKey)) {
|
|
1108
|
-
newSet.delete(menuKey);
|
|
1109
|
-
} else {
|
|
1110
|
-
newSet.add(menuKey);
|
|
1111
|
-
}
|
|
1112
|
-
return newSet;
|
|
1113
|
-
});
|
|
1114
|
-
};
|
|
1115
|
-
const isMenuOpen = (menuKey) => {
|
|
1116
|
-
return openMenus.has(menuKey);
|
|
1117
|
-
};
|
|
1118
|
-
const handleMenuClick = (item, index, e) => {
|
|
1119
|
-
if (item.isDropDown) {
|
|
1120
|
-
e.preventDefault();
|
|
1121
|
-
const menuKey = `menu-${index}`;
|
|
1122
|
-
toggleMenu(menuKey);
|
|
1123
|
-
setActiveMenuPath(`menu-${index}`);
|
|
1124
|
-
} else {
|
|
1125
|
-
setActiveMenuPath(`menu-${index}`);
|
|
1126
|
-
if (item.onClick) {
|
|
1127
|
-
item.onClick(e);
|
|
1128
|
-
}
|
|
1129
|
-
closeMobileMenu();
|
|
1130
|
-
}
|
|
1131
|
-
};
|
|
1132
|
-
const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
|
|
1133
|
-
const parentMenuKey = `menu-${parentIndex}`;
|
|
1134
|
-
setOpenMenus((prev) => {
|
|
1135
|
-
const newSet = new Set(prev);
|
|
1136
|
-
newSet.add(parentMenuKey);
|
|
1137
|
-
return newSet;
|
|
1138
|
-
});
|
|
1139
|
-
if (option.isDropDown) {
|
|
1140
|
-
e.preventDefault();
|
|
1141
|
-
const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
|
|
1142
|
-
toggleMenu(menuKey);
|
|
1143
|
-
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
|
|
1144
|
-
} else {
|
|
1145
|
-
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
|
|
1146
|
-
if (option.onClick) {
|
|
1147
|
-
option.onClick();
|
|
1148
|
-
}
|
|
1149
|
-
closeMobileMenu();
|
|
1150
|
-
}
|
|
1151
|
-
};
|
|
1152
|
-
const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
|
|
1153
|
-
const parentMenuKey = `menu-${parentIndex}`;
|
|
1154
|
-
const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
|
|
1155
|
-
setOpenMenus((prev) => {
|
|
1156
|
-
const newSet = new Set(prev);
|
|
1157
|
-
newSet.add(parentMenuKey);
|
|
1158
|
-
newSet.add(subMenuKey);
|
|
1159
|
-
return newSet;
|
|
1160
|
-
});
|
|
1161
|
-
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
|
|
1162
|
-
if (subOption.onClick) {
|
|
1163
|
-
subOption.onClick();
|
|
1164
|
-
}
|
|
1165
|
-
closeMobileMenu();
|
|
1166
|
-
};
|
|
1167
|
-
(0, import_react14.useEffect)(() => {
|
|
1168
|
-
const storedAuthData = localStorage.getItem("authData");
|
|
1169
|
-
if (storedAuthData) {
|
|
1170
|
-
let parseData = JSON.parse(storedAuthData);
|
|
1171
|
-
setAuthData(parseData);
|
|
1172
|
-
}
|
|
1173
|
-
}, [localStorage.getItem("authData")]);
|
|
1174
|
-
(0, import_react14.useEffect)(() => {
|
|
1175
|
-
const jettIdData = getJettIdCookieData();
|
|
1176
|
-
if (jettIdData == null ? void 0 : jettIdData.UserName) {
|
|
1177
|
-
setCookieUserName(jettIdData.UserName);
|
|
1178
|
-
}
|
|
1179
|
-
const cookieScope = getScopeFromJettIdCookie();
|
|
1180
|
-
if (cookieScope) {
|
|
1181
|
-
setScope(cookieScope);
|
|
1182
|
-
}
|
|
1183
|
-
}, []);
|
|
1184
|
-
const extractUrlFromOnClick = (onClick) => {
|
|
1185
|
-
if (!onClick || typeof onClick !== "function") return null;
|
|
1186
|
-
const funcString = onClick.toString();
|
|
1187
|
-
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
1188
|
-
if (!match) {
|
|
1189
|
-
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
1190
|
-
}
|
|
1191
|
-
if (match && match[1]) {
|
|
1192
|
-
try {
|
|
1193
|
-
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
1194
|
-
const url = new URL(match[1]);
|
|
1195
|
-
return {
|
|
1196
|
-
pathname: url.pathname,
|
|
1197
|
-
search: url.search,
|
|
1198
|
-
fullPath: url.pathname + url.search
|
|
1199
|
-
};
|
|
1200
|
-
}
|
|
1201
|
-
if (match[1].startsWith("/")) {
|
|
1202
|
-
const url = new URL(match[1], window.location.origin);
|
|
1203
|
-
return {
|
|
1204
|
-
pathname: url.pathname,
|
|
1205
|
-
search: url.search,
|
|
1206
|
-
fullPath: url.pathname + url.search
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1209
|
-
return null;
|
|
1210
|
-
} catch {
|
|
1211
|
-
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
1212
|
-
if (pathMatch) {
|
|
1213
|
-
return {
|
|
1214
|
-
pathname: pathMatch[1],
|
|
1215
|
-
search: pathMatch[2] || "",
|
|
1216
|
-
fullPath: match[1]
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
return null;
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
return null;
|
|
1223
|
-
};
|
|
1224
|
-
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
1225
|
-
if (!menuUrlData || !currentPath) return false;
|
|
1226
|
-
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
1227
|
-
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
1228
|
-
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
1229
|
-
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1230
|
-
const currentParams = new URLSearchParams(currentSearch);
|
|
1231
|
-
const menuRole = menuParams.get("role");
|
|
1232
|
-
const currentRole = currentParams.get("role");
|
|
1233
|
-
if (menuRole && currentRole) {
|
|
1234
|
-
return menuRole === currentRole;
|
|
1235
|
-
}
|
|
1236
|
-
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
1237
|
-
return false;
|
|
1238
|
-
}
|
|
1239
|
-
return true;
|
|
1240
|
-
}
|
|
1241
|
-
if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
|
|
1242
|
-
return true;
|
|
1243
|
-
}
|
|
1244
|
-
if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
|
|
1245
|
-
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1246
|
-
if (currentPathParam === "supplier-list") {
|
|
1247
|
-
return true;
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
|
|
1251
|
-
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1252
|
-
if (currentPathParam === "supplier-deals") {
|
|
1253
|
-
return true;
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
if (normalizedMenuPath === "/corporate/trips") {
|
|
1257
|
-
if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
|
|
1258
|
-
return true;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
|
|
1262
|
-
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
1263
|
-
if (menuPathParam) {
|
|
1264
|
-
const pathRouteMap = {
|
|
1265
|
-
"offer": "/offer/offer",
|
|
1266
|
-
"voucher": "/voucher/voucher",
|
|
1267
|
-
"tag": "/tags/tags",
|
|
1268
|
-
"special-requests": "/corporate/special-requests",
|
|
1269
|
-
"pricing-policy": "/policies/pricing-policy",
|
|
1270
|
-
"supplier-list": "/supplier",
|
|
1271
|
-
"users": "/users/users"
|
|
1272
|
-
// Consumer Ecosystem Users (no role param)
|
|
1273
|
-
};
|
|
1274
|
-
const expectedRoute = pathRouteMap[menuPathParam];
|
|
1275
|
-
if (expectedRoute) {
|
|
1276
|
-
if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
|
|
1277
|
-
if (menuPathParam === "users") {
|
|
1278
|
-
const currentParams = new URLSearchParams(currentSearch);
|
|
1279
|
-
const currentRole = currentParams.get("role");
|
|
1280
|
-
return currentRole !== "admin";
|
|
1281
|
-
}
|
|
1282
|
-
return true;
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
if (normalizedCurrentPath === "/orgselector") {
|
|
1287
|
-
const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
|
|
1288
|
-
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1289
|
-
if (menuPathParam2 && currentPathParam) {
|
|
1290
|
-
return menuPathParam2 === currentPathParam;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
1295
|
-
if (menuUrlData.search) {
|
|
1296
|
-
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1297
|
-
const currentParams = new URLSearchParams(currentSearch);
|
|
1298
|
-
for (const [key, value] of menuParams.entries()) {
|
|
1299
|
-
if (key === "auth") {
|
|
1300
|
-
continue;
|
|
1301
|
-
}
|
|
1302
|
-
if (currentParams.get(key) !== value) {
|
|
1303
|
-
return false;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
return true;
|
|
1307
|
-
}
|
|
1308
|
-
return true;
|
|
1309
|
-
}
|
|
1310
|
-
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
1311
|
-
return true;
|
|
1312
|
-
}
|
|
1313
|
-
return false;
|
|
1314
|
-
};
|
|
1315
|
-
const navItemsLocal = navItems ?? navItemsConstant;
|
|
1316
|
-
const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
|
|
1317
|
-
const logoFromCookie = getLogoFromJettIdCookie();
|
|
1318
|
-
const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
|
|
1319
|
-
const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
|
|
1320
|
-
authData.userInfo.CDNBasePath,
|
|
1321
|
-
authData.userInfo.OrgLogo
|
|
1322
|
-
) : null;
|
|
1323
|
-
const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
|
|
1324
|
-
const detectAndSetActiveMenu = (0, import_react14.useCallback)(() => {
|
|
1325
|
-
const currentPath = window.location.pathname;
|
|
1326
|
-
const currentSearch = window.location.search;
|
|
1327
|
-
const newOpenMenus = /* @__PURE__ */ new Set();
|
|
1328
|
-
let foundActivePath = null;
|
|
1329
|
-
navItemsLocal.forEach((item, index) => {
|
|
1330
|
-
if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
|
|
1331
|
-
const itemUrlData = extractUrlFromOnClick(item.onClick);
|
|
1332
|
-
if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
|
|
1333
|
-
foundActivePath = `menu-${index}`;
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
if (item.options && item.options.length > 0) {
|
|
1337
|
-
item.options.forEach((option, optionsIndex) => {
|
|
1338
|
-
if (option.onClick && typeof option.onClick === "function") {
|
|
1339
|
-
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
1340
|
-
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
1341
|
-
const menuKey = `menu-${index}`;
|
|
1342
|
-
newOpenMenus.add(menuKey);
|
|
1343
|
-
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
1344
|
-
if (option.options && option.options.length > 0) {
|
|
1345
|
-
option.options.forEach((subOption, subIndex) => {
|
|
1346
|
-
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
1347
|
-
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
1348
|
-
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
1349
|
-
newOpenMenus.add(subMenuKey);
|
|
1350
|
-
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
1351
|
-
}
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
});
|
|
1357
|
-
}
|
|
1358
|
-
});
|
|
1359
|
-
if (foundActivePath) {
|
|
1360
|
-
setOpenMenus(newOpenMenus);
|
|
1361
|
-
setActiveMenuPath(foundActivePath);
|
|
1362
|
-
}
|
|
1363
|
-
}, [navItemsLocal]);
|
|
1364
|
-
const [currentUrl, setCurrentUrl] = (0, import_react14.useState)(
|
|
1365
|
-
() => window.location.pathname + window.location.search
|
|
1366
|
-
);
|
|
1367
|
-
(0, import_react14.useEffect)(() => {
|
|
1368
|
-
detectAndSetActiveMenu();
|
|
1369
|
-
setCurrentUrl(window.location.pathname + window.location.search);
|
|
1370
|
-
}, [detectAndSetActiveMenu]);
|
|
1371
|
-
(0, import_react14.useEffect)(() => {
|
|
1372
|
-
let lastUrl = window.location.pathname + window.location.search;
|
|
1373
|
-
const handleLocationChange = () => {
|
|
1374
|
-
const newUrl = window.location.pathname + window.location.search;
|
|
1375
|
-
if (newUrl !== lastUrl) {
|
|
1376
|
-
lastUrl = newUrl;
|
|
1377
|
-
setCurrentUrl(newUrl);
|
|
1378
|
-
detectAndSetActiveMenu();
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
window.addEventListener("popstate", handleLocationChange);
|
|
1382
|
-
const checkInterval = setInterval(() => {
|
|
1383
|
-
const newUrl = window.location.pathname + window.location.search;
|
|
1384
|
-
if (newUrl !== lastUrl) {
|
|
1385
|
-
handleLocationChange();
|
|
1386
|
-
}
|
|
1387
|
-
}, 250);
|
|
1388
|
-
return () => {
|
|
1389
|
-
window.removeEventListener("popstate", handleLocationChange);
|
|
1390
|
-
clearInterval(checkInterval);
|
|
1391
|
-
};
|
|
1392
|
-
}, [detectAndSetActiveMenu]);
|
|
1393
|
-
(0, import_react14.useEffect)(() => {
|
|
1394
|
-
detectAndSetActiveMenu();
|
|
1395
|
-
}, [currentUrl, detectAndSetActiveMenu]);
|
|
1396
|
-
const toggleMobileMenu = () => {
|
|
1397
|
-
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
1398
|
-
};
|
|
1399
|
-
const closeMobileMenu = () => {
|
|
1400
|
-
setIsMobileMenuOpen(false);
|
|
1401
|
-
};
|
|
1402
|
-
return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1403
|
-
"button",
|
|
1404
|
-
{
|
|
1405
|
-
onClick: toggleMobileMenu,
|
|
1406
|
-
className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
|
|
1407
|
-
"aria-label": "Toggle menu",
|
|
1408
|
-
id: `${id}-button-1`
|
|
1409
|
-
},
|
|
1410
|
-
isMobileMenuOpen ? /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
|
|
1411
|
-
), /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
|
|
1412
|
-
"img",
|
|
1413
|
-
{
|
|
1414
|
-
src: sideBarLogoLocal,
|
|
1415
|
-
alt: "sidebarLogo",
|
|
1416
|
-
width: 208,
|
|
1417
|
-
height: 40,
|
|
1418
|
-
className: "object-contain",
|
|
1419
|
-
id: `${id}-img-1`
|
|
1420
|
-
}
|
|
1421
|
-
)), /* @__PURE__ */ import_react14.default.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ import_react14.default.createElement(
|
|
1422
|
-
"div",
|
|
1423
|
-
{
|
|
1424
|
-
className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
|
|
1425
|
-
onClick: closeMobileMenu,
|
|
1426
|
-
id: `${id}-div-4`
|
|
1427
|
-
}
|
|
1428
|
-
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1429
|
-
"div",
|
|
1430
|
-
{
|
|
1431
|
-
className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
|
|
1432
|
-
id: `${id}-div-5`
|
|
1433
|
-
},
|
|
1434
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
|
|
1435
|
-
"img",
|
|
1436
|
-
{
|
|
1437
|
-
src: sideBarLogoLocal,
|
|
1438
|
-
alt: "sidebarLogo",
|
|
1439
|
-
width: 108,
|
|
1440
|
-
height: 40,
|
|
1441
|
-
className: "object-contain",
|
|
1442
|
-
id: `${id}-img-2`
|
|
1443
|
-
}
|
|
1444
|
-
))),
|
|
1445
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
|
|
1446
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
|
|
1447
|
-
const menuKey = `menu-${index}`;
|
|
1448
|
-
const isOpen = isMenuOpen(menuKey);
|
|
1449
|
-
const isActive = activeMenuPath === menuKey;
|
|
1450
|
-
return /* @__PURE__ */ import_react14.default.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1451
|
-
"div",
|
|
1452
|
-
{
|
|
1453
|
-
className: `flex items-center gap-3 p-2.5 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer rounded-lg ml-2 mr-2 transition-colors duration-200 ${isActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
|
|
1454
|
-
onClick: (e) => handleMenuClick(item, index, e),
|
|
1455
|
-
id: `${id}-div-12`
|
|
1456
|
-
},
|
|
1457
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ import_react14.default.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
|
|
1458
|
-
/* @__PURE__ */ import_react14.default.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
|
|
1459
|
-
item.isDropDown && /* @__PURE__ */ import_react14.default.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
|
|
1460
|
-
), item.options && item.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
|
|
1461
|
-
"div",
|
|
1462
|
-
{
|
|
1463
|
-
className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
|
|
1464
|
-
id: `${id}-div-15`
|
|
1465
|
-
},
|
|
1466
|
-
item.options.map((options, optionsIndex) => {
|
|
1467
|
-
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
1468
|
-
const isSubMenuOpen = isMenuOpen(subMenuKey);
|
|
1469
|
-
const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
|
|
1470
|
-
const isDisabled = options.isDisabled;
|
|
1471
|
-
return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1472
|
-
"div",
|
|
1473
|
-
{
|
|
1474
|
-
className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
|
|
1475
|
-
onClick: (e) => {
|
|
1476
|
-
if (isDisabled) {
|
|
1477
|
-
e.preventDefault();
|
|
1478
|
-
return;
|
|
1479
|
-
}
|
|
1480
|
-
handleSubMenuClick(options, optionsIndex, index, e);
|
|
1481
|
-
},
|
|
1482
|
-
id: `${id}-div-17-${optionsIndex}`
|
|
1483
|
-
},
|
|
1484
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
|
|
1485
|
-
/* @__PURE__ */ import_react14.default.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
|
|
1486
|
-
options.isDropDown && /* @__PURE__ */ import_react14.default.createElement(
|
|
1487
|
-
"div",
|
|
1488
|
-
{
|
|
1489
|
-
className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
|
|
1490
|
-
id: `${id}-div-19-${optionsIndex}`
|
|
1491
|
-
},
|
|
1492
|
-
/* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
|
|
1493
|
-
)
|
|
1494
|
-
), options.options && options.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
|
|
1495
|
-
"div",
|
|
1496
|
-
{
|
|
1497
|
-
className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
|
|
1498
|
-
id: `${id}-div-20-${optionsIndex}`
|
|
1499
|
-
},
|
|
1500
|
-
options.options.map((subOption, subIndex) => {
|
|
1501
|
-
const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
1502
|
-
return /* @__PURE__ */ import_react14.default.createElement(
|
|
1503
|
-
"div",
|
|
1504
|
-
{
|
|
1505
|
-
key: subIndex,
|
|
1506
|
-
className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
|
|
1507
|
-
onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
|
|
1508
|
-
id: `${id}-div-21-${subIndex}`
|
|
1509
|
-
},
|
|
1510
|
-
subOption.label
|
|
1511
|
-
);
|
|
1512
|
-
})
|
|
1513
|
-
));
|
|
1514
|
-
})
|
|
1515
|
-
));
|
|
1516
|
-
}))),
|
|
1517
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1518
|
-
"div",
|
|
1519
|
-
{
|
|
1520
|
-
className: "group flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
|
|
1521
|
-
onClick: () => setIsSwitchProfileOpen((prev) => !prev),
|
|
1522
|
-
id: `${id}-div-23`
|
|
1523
|
-
},
|
|
1524
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ import_react14.default.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ import_react14.default.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope))),
|
|
1525
|
-
/* @__PURE__ */ import_react14.default.createElement(
|
|
1526
|
-
"span",
|
|
1527
|
-
{
|
|
1528
|
-
className: "text-gray-600 dark:text-gray-400",
|
|
1529
|
-
id: `${id}-span-switch`
|
|
1530
|
-
},
|
|
1531
|
-
/* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronRight, { width: 20, height: 22 })
|
|
1532
|
-
)
|
|
1533
|
-
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1534
|
-
SwitchProfileSection,
|
|
1535
|
-
{
|
|
1536
|
-
id: `${id}-switch-profile`,
|
|
1537
|
-
open: isSwitchProfileOpen,
|
|
1538
|
-
anchorRef: profileCardRef,
|
|
1539
|
-
onClose: () => setIsSwitchProfileOpen(false),
|
|
1540
|
-
onManageProfile: () => {
|
|
1541
|
-
setIsSwitchProfileOpen(false);
|
|
1542
|
-
window.location.href = "/profile";
|
|
1543
|
-
},
|
|
1544
|
-
onProfileSwitch: (profile) => {
|
|
1545
|
-
setIsSwitchProfileOpen(false);
|
|
1546
|
-
onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
|
|
1547
|
-
},
|
|
1548
|
-
onTmcSettings: () => {
|
|
1549
|
-
setIsSwitchProfileOpen(false);
|
|
1550
|
-
onTmcSettings == null ? void 0 : onTmcSettings();
|
|
1551
|
-
},
|
|
1552
|
-
onLogout: () => {
|
|
1553
|
-
setIsSwitchProfileOpen(false);
|
|
1554
|
-
if (onLogout) {
|
|
1555
|
-
onLogout();
|
|
1556
|
-
} else {
|
|
1557
|
-
window.location.href = `${window.location.origin}/login/logout`;
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
))
|
|
1562
|
-
));
|
|
1563
|
-
};
|
|
1564
|
-
|
|
1565
|
-
// src/RightSheet/RightSheet.jsx
|
|
1566
|
-
var import_react15 = __toESM(require("react"));
|
|
1567
|
-
var RightSheet = ({
|
|
1568
|
-
id = "right-sheet",
|
|
1569
|
-
open,
|
|
1570
|
-
setOpen,
|
|
1571
|
-
children,
|
|
1572
|
-
callBack,
|
|
1573
|
-
actionLabel = "Save",
|
|
1574
|
-
onAction = () => {
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
(0, import_react15.
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
/* @__PURE__ */ import_react15.default.createElement("div", { className: "
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
var
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
};
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
var
|
|
1663
|
-
var
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
"
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
"
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
const
|
|
1765
|
-
const
|
|
1766
|
-
const
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
var
|
|
1810
|
-
var
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
const
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
const [
|
|
1833
|
-
const
|
|
1834
|
-
(0
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
};
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
var
|
|
1893
|
-
var
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
const [
|
|
1918
|
-
const
|
|
1919
|
-
const
|
|
1920
|
-
const
|
|
1921
|
-
const
|
|
1922
|
-
const
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
const
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
const
|
|
1943
|
-
|
|
1944
|
-
let
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
const
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
const
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
...
|
|
1987
|
-
...
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
...
|
|
2010
|
-
...
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
...
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.js
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
AppSideBar: () => AppSideBar,
|
|
33
|
+
Calendar: () => Calendar,
|
|
34
|
+
Chip: () => Chip,
|
|
35
|
+
CustomAutocomplete: () => CustomAutocomplete,
|
|
36
|
+
CustomButton: () => CustomButton,
|
|
37
|
+
CustomCheckbox: () => CustomCheckbox,
|
|
38
|
+
CustomInput: () => CustomInput,
|
|
39
|
+
CustomSearch: () => CustomSearch,
|
|
40
|
+
CustomSelect: () => CustomSelect,
|
|
41
|
+
CustomSwitch: () => CustomSwitch,
|
|
42
|
+
CustomTable: () => CustomTable,
|
|
43
|
+
CustomTextarea: () => CustomTextarea,
|
|
44
|
+
CustomUpload: () => CustomUpload,
|
|
45
|
+
Dropdown: () => Dropdown,
|
|
46
|
+
Pagination: () => Pagination,
|
|
47
|
+
ProgressBar: () => ProgressBar,
|
|
48
|
+
RightSheet: () => RightSheet
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(index_exports);
|
|
51
|
+
|
|
52
|
+
// src/utils/cn.ts
|
|
53
|
+
var import_clsx = require("clsx");
|
|
54
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
55
|
+
function cn(...inputs) {
|
|
56
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/Button.jsx
|
|
60
|
+
var import_react = __toESM(require("react"));
|
|
61
|
+
var variantStyles = {
|
|
62
|
+
PRIMARY: "bg-white dark:bg-[#18181b] dark:text-white",
|
|
63
|
+
SECONDARY: "bg-primary text-white dark:text-white",
|
|
64
|
+
DEFAULT: "bg-white text-black dark:text-white",
|
|
65
|
+
DANGER: "bg-[#ef4444] text-white dark:text-white"
|
|
66
|
+
};
|
|
67
|
+
var CustomButton = ({
|
|
68
|
+
id = "button",
|
|
69
|
+
variant = "DEFAULT",
|
|
70
|
+
children,
|
|
71
|
+
className,
|
|
72
|
+
onClick,
|
|
73
|
+
disabled = false,
|
|
74
|
+
icon
|
|
75
|
+
}) => {
|
|
76
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
className: cn(
|
|
80
|
+
`cursor-pointer flex items-center py-2 px-3 min-h-10 justify-center border rounded-[6px] border-[#e5e5e5] dark:border-[#303036] ${variant == "DANGER" ? "bg-[#ef4444]" : "dark:bg-[#1d1d20]"} gap-2`,
|
|
81
|
+
variantStyles[variant],
|
|
82
|
+
className
|
|
83
|
+
),
|
|
84
|
+
onClick,
|
|
85
|
+
id: `${id}-div-1`
|
|
86
|
+
},
|
|
87
|
+
icon && /* @__PURE__ */ import_react.default.createElement("div", { id: `${id}-div-2` }, icon),
|
|
88
|
+
children
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/inputs/Autocomplete.jsx
|
|
93
|
+
var import_react2 = __toESM(require("react"));
|
|
94
|
+
var import_lucide_react = require("lucide-react");
|
|
95
|
+
var CustomAutocomplete = ({
|
|
96
|
+
id = "autocomplete",
|
|
97
|
+
label,
|
|
98
|
+
value,
|
|
99
|
+
onChange,
|
|
100
|
+
options,
|
|
101
|
+
placeholder = "Search & select...",
|
|
102
|
+
isRequired = false,
|
|
103
|
+
error,
|
|
104
|
+
heading,
|
|
105
|
+
disabled = false
|
|
106
|
+
}) => {
|
|
107
|
+
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
108
|
+
const [search, setSearch] = (0, import_react2.useState)("");
|
|
109
|
+
const wrapperRef = (0, import_react2.useRef)(null);
|
|
110
|
+
const selectedOptions = options.filter((opt) => value.includes(opt.value));
|
|
111
|
+
const handleBlur = (e) => {
|
|
112
|
+
var _a;
|
|
113
|
+
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
114
|
+
setOpen(false);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const filteredOptions = options.filter(
|
|
118
|
+
(opt) => opt.label.toLowerCase().includes(search.toLowerCase())
|
|
119
|
+
);
|
|
120
|
+
const toggleValue = (val) => {
|
|
121
|
+
if (value.includes(val)) {
|
|
122
|
+
onChange(value.filter((v) => v !== val));
|
|
123
|
+
} else {
|
|
124
|
+
onChange([...value, val]);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return /* @__PURE__ */ import_react2.default.createElement(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: "flex flex-col w-full relative dark:bg-[#18181b] dark:text-white",
|
|
131
|
+
ref: wrapperRef,
|
|
132
|
+
tabIndex: disabled ? -1 : 0,
|
|
133
|
+
onBlur: handleBlur,
|
|
134
|
+
id: `${id}-div-1`
|
|
135
|
+
},
|
|
136
|
+
heading && /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-lg font-semibold leading-6 mb-1", id: `${id}-h3-1` }, heading),
|
|
137
|
+
label && /* @__PURE__ */ import_react2.default.createElement(
|
|
138
|
+
"label",
|
|
139
|
+
{
|
|
140
|
+
className: `font-[500] text-sm leading-5 mb-1 ${heading ? "text-[#737373]" : "text-black dark:text-white"}`,
|
|
141
|
+
id: `${id}-label-1`
|
|
142
|
+
},
|
|
143
|
+
label,
|
|
144
|
+
" ",
|
|
145
|
+
isRequired && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ import_react2.default.createElement(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
onClick: () => {
|
|
151
|
+
if (!disabled) setOpen((prev) => !prev);
|
|
152
|
+
},
|
|
153
|
+
className: `flex justify-between items-center flex-wrap gap-1 rounded-md px-3 py-2 text-sm transition border dark:border-[#303036] h-auto min-h-10 dark:bg-[#18181b] dark:text-white
|
|
154
|
+
${disabled ? "bg-gray-100 cursor-not-allowed text-gray-400" : "cursor-text"}
|
|
155
|
+
${error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)] hover:border-gray-400 dark:bg-[#18181b] dark:text-white"}
|
|
156
|
+
`,
|
|
157
|
+
id: `${id}-div-2`
|
|
158
|
+
},
|
|
159
|
+
/* @__PURE__ */ import_react2.default.createElement("div", { className: "flex flex-wrap gap-1 flex-1", id: `${id}-div-3` }, selectedOptions.length > 0 ? selectedOptions.map((opt) => /* @__PURE__ */ import_react2.default.createElement(
|
|
160
|
+
"span",
|
|
161
|
+
{
|
|
162
|
+
key: opt.value,
|
|
163
|
+
className: "bg-[#F7FAFC] dark:bg-[#303036] border border-gray-300 px-2 dark:text-white py-0.5 rounded text-xs flex items-center gap-1",
|
|
164
|
+
id: `${id}-span-2`
|
|
165
|
+
},
|
|
166
|
+
opt.label,
|
|
167
|
+
/* @__PURE__ */ import_react2.default.createElement(
|
|
168
|
+
"button",
|
|
169
|
+
{
|
|
170
|
+
onClick: (e) => {
|
|
171
|
+
e.stopPropagation();
|
|
172
|
+
toggleValue(opt.value);
|
|
173
|
+
},
|
|
174
|
+
className: "text-gray-500 hover:text-gray-700 dark:text-white cursor-pointer dark:hover:text-white",
|
|
175
|
+
id: `${id}-button-1`
|
|
176
|
+
},
|
|
177
|
+
"\u2715"
|
|
178
|
+
)
|
|
179
|
+
)) : /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-gray-400", id: `${id}-span-3` }, placeholder)),
|
|
180
|
+
/* @__PURE__ */ import_react2.default.createElement(
|
|
181
|
+
import_lucide_react.ChevronDown,
|
|
182
|
+
{
|
|
183
|
+
className: `w-4 h-4 text-gray-500 transition-transform ${open ? "rotate-180" : ""}`
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
),
|
|
187
|
+
!disabled && open && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-5` }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react2.default.createElement(
|
|
188
|
+
"input",
|
|
189
|
+
{
|
|
190
|
+
type: "text",
|
|
191
|
+
value: search,
|
|
192
|
+
onChange: (e) => setSearch(e.target.value),
|
|
193
|
+
placeholder: "Search...",
|
|
194
|
+
className: "flex-1 text-sm focus:outline-none",
|
|
195
|
+
id: `${id}-input-1`
|
|
196
|
+
}
|
|
197
|
+
)), /* @__PURE__ */ import_react2.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => {
|
|
198
|
+
const selected = value.includes(opt.value);
|
|
199
|
+
return /* @__PURE__ */ import_react2.default.createElement(
|
|
200
|
+
"li",
|
|
201
|
+
{
|
|
202
|
+
key: opt.value,
|
|
203
|
+
onClick: () => toggleValue(opt.value),
|
|
204
|
+
className: `flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-[#F7FAFC] dark:hover:bg-[#303036] ${selected ? "bg-[#F7FAFC] dark:bg-[#303036] font-medium" : ""}`,
|
|
205
|
+
id: `${id}-li-1`
|
|
206
|
+
},
|
|
207
|
+
/* @__PURE__ */ import_react2.default.createElement(
|
|
208
|
+
"span",
|
|
209
|
+
{
|
|
210
|
+
className: `w-4 h-4 flex items-center justify-center border rounded-sm ${selected ? "bg-blue-600 border-blue-600 text-white" : "border-gray-300"}`,
|
|
211
|
+
id: `${id}-span-4`
|
|
212
|
+
},
|
|
213
|
+
selected && /* @__PURE__ */ import_react2.default.createElement(import_lucide_react.Check, { size: 14 })
|
|
214
|
+
),
|
|
215
|
+
opt.label
|
|
216
|
+
);
|
|
217
|
+
}) : /* @__PURE__ */ import_react2.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400", id: `${id}-li-2` }, "No results found")))
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/inputs/Checkbox.jsx
|
|
222
|
+
var import_react3 = __toESM(require("react"));
|
|
223
|
+
var CustomCheckbox = ({ id = "checkbox", onChange, checked }) => {
|
|
224
|
+
const handleChange = (e) => {
|
|
225
|
+
onChange(e.target.checked);
|
|
226
|
+
};
|
|
227
|
+
return /* @__PURE__ */ import_react3.default.createElement("label", { className: "inline-flex items-center cursor-pointer select-none", id: `${id}-label-1` }, /* @__PURE__ */ import_react3.default.createElement(
|
|
228
|
+
"input",
|
|
229
|
+
{
|
|
230
|
+
type: "checkbox",
|
|
231
|
+
checked,
|
|
232
|
+
onChange: handleChange,
|
|
233
|
+
className: "peer hidden",
|
|
234
|
+
id: `${id}-input-1`
|
|
235
|
+
}
|
|
236
|
+
), /* @__PURE__ */ import_react3.default.createElement(
|
|
237
|
+
"span",
|
|
238
|
+
{
|
|
239
|
+
className: "\r\n w-4 h-4 flex items-center justify-center border-2 border-gray-400 rounded \r\n peer-checked:bg-primary peer-checked:border-primary\r\n transition-colors\r\n ",
|
|
240
|
+
id: `${id}-span-1`
|
|
241
|
+
},
|
|
242
|
+
checked && /* @__PURE__ */ import_react3.default.createElement(
|
|
243
|
+
"svg",
|
|
244
|
+
{
|
|
245
|
+
className: "w-4 h-4 text-white",
|
|
246
|
+
fill: "none",
|
|
247
|
+
stroke: "currentColor",
|
|
248
|
+
strokeWidth: "3",
|
|
249
|
+
viewBox: "0 0 24 24",
|
|
250
|
+
id: `${id}-svg-1`
|
|
251
|
+
},
|
|
252
|
+
/* @__PURE__ */ import_react3.default.createElement("path", { d: "M5 13l4 4L19 7", id: `${id}-path-1` })
|
|
253
|
+
)
|
|
254
|
+
));
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// src/inputs/Chip.jsx
|
|
258
|
+
var import_react4 = __toESM(require("react"));
|
|
259
|
+
var VARIANTS = {
|
|
260
|
+
PRIMARY: "bg-gray-100 text-black dark:bg-gray-800 dark:text-white",
|
|
261
|
+
GREEN: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
|
|
262
|
+
RED: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
|
|
263
|
+
YELLOW: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100"
|
|
264
|
+
};
|
|
265
|
+
var Chip = ({ id = "chip", label, variant }) => {
|
|
266
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
className: `inline-flex text-[12px] items-center px-3 py-1 rounded-full ${VARIANTS[variant] || VARIANTS.PRIMARY} text-sm font-[600]`,
|
|
270
|
+
id: `${id}-div-1`
|
|
271
|
+
},
|
|
272
|
+
label
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// src/inputs/CustomSwitch.jsx
|
|
277
|
+
var import_react5 = __toESM(require("react"));
|
|
278
|
+
var CustomSwitch = ({ id = "custom-switch", checked, onChange, label, description }) => {
|
|
279
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { id: `${id}-div-1` }, /* @__PURE__ */ import_react5.default.createElement(
|
|
280
|
+
"button",
|
|
281
|
+
{
|
|
282
|
+
type: "button",
|
|
283
|
+
role: "switch",
|
|
284
|
+
"aria-checked": checked,
|
|
285
|
+
onClick: () => onChange(!checked),
|
|
286
|
+
className: `relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors ${checked ? "bg-black" : "bg-gray-300"}`,
|
|
287
|
+
id: `${id}-button-1`
|
|
288
|
+
},
|
|
289
|
+
/* @__PURE__ */ import_react5.default.createElement(
|
|
290
|
+
"span",
|
|
291
|
+
{
|
|
292
|
+
className: `inline-block h-4 w-4 transform rounded-full bg-white shadow transition ${checked ? "translate-x-6" : "translate-x-1"}`,
|
|
293
|
+
id: `${id}-span-1`
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
), /* @__PURE__ */ import_react5.default.createElement("div", { className: "flex flex-col", id: `${id}-div-2` }, label && /* @__PURE__ */ import_react5.default.createElement("h3", { className: "font-[500] text-sm text-black mb-2", id: `${id}-h3-1` }, label), description && /* @__PURE__ */ import_react5.default.createElement("p", { className: "font-[500] text-sm text-[#737373]", id: `${id}-p-1` }, description)));
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// src/inputs/Input.jsx
|
|
300
|
+
var import_react6 = __toESM(require("react"));
|
|
301
|
+
var CustomInput = ({
|
|
302
|
+
id = "input",
|
|
303
|
+
label,
|
|
304
|
+
isRequired,
|
|
305
|
+
value,
|
|
306
|
+
onChange,
|
|
307
|
+
placeholder,
|
|
308
|
+
disabled = false,
|
|
309
|
+
error,
|
|
310
|
+
heading
|
|
311
|
+
}) => {
|
|
312
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react6.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react6.default.createElement(
|
|
313
|
+
"label",
|
|
314
|
+
{
|
|
315
|
+
className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
|
|
316
|
+
id: `${id}-label-1`
|
|
317
|
+
},
|
|
318
|
+
label,
|
|
319
|
+
" ",
|
|
320
|
+
isRequired && /* @__PURE__ */ import_react6.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
321
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
322
|
+
"input",
|
|
323
|
+
{
|
|
324
|
+
className: `border border-gray-200 rounded-md h-10 px-4 py-2 w-full text-[14px]
|
|
325
|
+
placeholder:text-[14px] placeholder:font-normal placeholder:text-[#6b7280]
|
|
326
|
+
focus:outline-2 outline-black dark:outline-white outline-offset-2
|
|
327
|
+
dark:bg-transparent dark:text-white dark:border-[#303036]
|
|
328
|
+
${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
|
|
329
|
+
`,
|
|
330
|
+
value,
|
|
331
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
332
|
+
placeholder,
|
|
333
|
+
disabled,
|
|
334
|
+
readOnly: disabled,
|
|
335
|
+
id: `${id}-input-1`
|
|
336
|
+
}
|
|
337
|
+
));
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/inputs/ProgressBar.jsx
|
|
341
|
+
var import_react7 = __toESM(require("react"));
|
|
342
|
+
var ProgressBar = ({ id = "progress-bar", step, totalSteps }) => {
|
|
343
|
+
const progress = step / totalSteps * 100;
|
|
344
|
+
return /* @__PURE__ */ import_react7.default.createElement("div", { className: "mb-6", id: `${id}-div-1` }, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-gray-600 text-sm mb-2", id: `${id}-p-1` }, "Step ", step, " of ", totalSteps), /* @__PURE__ */ import_react7.default.createElement("div", { className: "w-full bg-gray-200 rounded-full h-2", id: `${id}-div-2` }, /* @__PURE__ */ import_react7.default.createElement(
|
|
345
|
+
"div",
|
|
346
|
+
{
|
|
347
|
+
className: "bg-black h-2 rounded-full transition-all duration-300",
|
|
348
|
+
style: { width: `${progress}%` },
|
|
349
|
+
id: `${id}-div-3`
|
|
350
|
+
}
|
|
351
|
+
)));
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// src/inputs/Search.jsx
|
|
355
|
+
var import_react8 = __toESM(require("react"));
|
|
356
|
+
var import_lucide_react2 = require("lucide-react");
|
|
357
|
+
var CustomSearch = ({
|
|
358
|
+
id = "search",
|
|
359
|
+
value,
|
|
360
|
+
onChange,
|
|
361
|
+
placeholder = "Search Markets..."
|
|
362
|
+
}) => {
|
|
363
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "flex items-center border bg-transparent text-[14px] border-[hsl(0_0%_89.8%)] dark:border-[#303036] \r\n rounded-md h-10 px-2 w-full focus-within:outline-2 focus-within:outline-black focus-within:outline-offset-2 dark:text-white", id: `${id}-div-1` }, /* @__PURE__ */ import_react8.default.createElement(import_lucide_react2.Search, { width: 16, height: 16, color: "gray", className: "mr-2" }), /* @__PURE__ */ import_react8.default.createElement(
|
|
364
|
+
"input",
|
|
365
|
+
{
|
|
366
|
+
type: "text",
|
|
367
|
+
value,
|
|
368
|
+
onChange,
|
|
369
|
+
placeholder,
|
|
370
|
+
className: "bg-transparent w-full h-full focus:outline-none",
|
|
371
|
+
id: `${id}-input-1`
|
|
372
|
+
}
|
|
373
|
+
));
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
// src/inputs/TextArea.jsx
|
|
377
|
+
var import_react9 = __toESM(require("react"));
|
|
378
|
+
var CustomTextarea = ({
|
|
379
|
+
id = "text-area",
|
|
380
|
+
label,
|
|
381
|
+
isRequired,
|
|
382
|
+
value,
|
|
383
|
+
onChange,
|
|
384
|
+
placeholder,
|
|
385
|
+
disabled = false,
|
|
386
|
+
error,
|
|
387
|
+
heading,
|
|
388
|
+
rows = 4
|
|
389
|
+
}) => {
|
|
390
|
+
return /* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col gap-1 w-full", id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), /* @__PURE__ */ import_react9.default.createElement(
|
|
391
|
+
"label",
|
|
392
|
+
{
|
|
393
|
+
className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"}`,
|
|
394
|
+
id: `${id}-label-1`
|
|
395
|
+
},
|
|
396
|
+
label,
|
|
397
|
+
" ",
|
|
398
|
+
isRequired && /* @__PURE__ */ import_react9.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
399
|
+
), /* @__PURE__ */ import_react9.default.createElement(
|
|
400
|
+
"textarea",
|
|
401
|
+
{
|
|
402
|
+
rows,
|
|
403
|
+
className: `border rounded-md px-4 py-2 w-full text-[14px]
|
|
404
|
+
focus:outline-2 focus:outline-black focus:outline-offset-2
|
|
405
|
+
focus:ring-0 focus:shadow-none focus:border-black
|
|
406
|
+
${disabled ? "bg-gray-100 text-gray-500 border-gray-300" : error ? "border-red-500 bg-red-50" : "bg-white border-[hsl(0_0%_89.8%)]"}
|
|
407
|
+
`,
|
|
408
|
+
value,
|
|
409
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
|
|
410
|
+
placeholder,
|
|
411
|
+
disabled,
|
|
412
|
+
readOnly: disabled,
|
|
413
|
+
id: `${id}-textarea-1`
|
|
414
|
+
}
|
|
415
|
+
));
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
// src/inputs/Upload.jsx
|
|
419
|
+
var import_react10 = __toESM(require("react"));
|
|
420
|
+
var import_lucide_react3 = require("lucide-react");
|
|
421
|
+
var CustomUpload = ({
|
|
422
|
+
id = "upload",
|
|
423
|
+
label = "Supporting documents",
|
|
424
|
+
description = "Drop items here or Browse Files",
|
|
425
|
+
accept = ".pdf,.jpg,.jpeg,.png",
|
|
426
|
+
maxSizeMB = 5,
|
|
427
|
+
onChange,
|
|
428
|
+
error,
|
|
429
|
+
value
|
|
430
|
+
}) => {
|
|
431
|
+
const inputRef = (0, import_react10.useRef)(null);
|
|
432
|
+
const handleFileSelect = (files) => {
|
|
433
|
+
if (!files || files.length === 0) return;
|
|
434
|
+
const selectedFile = files[0];
|
|
435
|
+
if (selectedFile.size > maxSizeMB * 1024 * 1024) {
|
|
436
|
+
alert(`File size must be less than ${maxSizeMB} MB`);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
onChange == null ? void 0 : onChange(selectedFile);
|
|
440
|
+
};
|
|
441
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", { className: "flex flex-col gap-2 w-full", id: `${id}-div-1` }, label && /* @__PURE__ */ import_react10.default.createElement("label", { className: "text-sm font-medium", id: `${id}-label-1` }, label), /* @__PURE__ */ import_react10.default.createElement(
|
|
442
|
+
"div",
|
|
443
|
+
{
|
|
444
|
+
className: `border-2 border-dashed rounded-lg p-6 flex flex-col items-center justify-center text-center cursor-pointer transition
|
|
445
|
+
${error ? "border-red-500 bg-red-50" : "border-gray-300 hover:border-gray-400 bg-gray-50"}`,
|
|
446
|
+
onClick: () => {
|
|
447
|
+
var _a;
|
|
448
|
+
return (_a = inputRef.current) == null ? void 0 : _a.click();
|
|
449
|
+
},
|
|
450
|
+
onDragOver: (e) => e.preventDefault(),
|
|
451
|
+
onDrop: (e) => {
|
|
452
|
+
e.preventDefault();
|
|
453
|
+
handleFileSelect(e.dataTransfer.files);
|
|
454
|
+
},
|
|
455
|
+
id: `${id}-div-2`
|
|
456
|
+
},
|
|
457
|
+
/* @__PURE__ */ import_react10.default.createElement(import_lucide_react3.Upload, { className: "w-6 h-6 text-gray-500 mb-2" }),
|
|
458
|
+
/* @__PURE__ */ import_react10.default.createElement("p", { className: "text-sm text-gray-700", id: `${id}-p-1` }, description),
|
|
459
|
+
/* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-gray-500 mt-1", id: `${id}-p-2` }, "File Supported: PDF/JPG/PNG, up to ", maxSizeMB, " MB"),
|
|
460
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
461
|
+
"input",
|
|
462
|
+
{
|
|
463
|
+
ref: inputRef,
|
|
464
|
+
type: "file",
|
|
465
|
+
accept,
|
|
466
|
+
className: "hidden",
|
|
467
|
+
onChange: (e) => handleFileSelect(e.target.files),
|
|
468
|
+
id: `${id}-input-1`
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
), value && /* @__PURE__ */ import_react10.default.createElement("span", { className: "text-sm truncate text-gray-500", id: `${id}-span-1` }, "Selected: ", value.name), error && /* @__PURE__ */ import_react10.default.createElement("p", { className: "text-xs text-red-500", id: `${id}-p-3` }, error));
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// src/sideBar/SideBar.jsx
|
|
475
|
+
var import_lucide_react8 = require("lucide-react");
|
|
476
|
+
var import_react14 = __toESM(require("react"));
|
|
477
|
+
|
|
478
|
+
// ConstantUI.js
|
|
479
|
+
var import_lucide_react4 = require("lucide-react");
|
|
480
|
+
var encodedAuthData = localStorage.getItem("encodedAuthData");
|
|
481
|
+
var navItemsConstant = [
|
|
482
|
+
{
|
|
483
|
+
Icon: import_lucide_react4.Home,
|
|
484
|
+
label: "Home",
|
|
485
|
+
onClick: () => {
|
|
486
|
+
window.location.href = "/";
|
|
487
|
+
},
|
|
488
|
+
isDropDown: false
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
Icon: import_lucide_react4.Building,
|
|
492
|
+
label: "Consumer Ecosystem",
|
|
493
|
+
onClick: () => {
|
|
494
|
+
},
|
|
495
|
+
options: [
|
|
496
|
+
{
|
|
497
|
+
label: "Corporate",
|
|
498
|
+
onClick: () => {
|
|
499
|
+
window.location.href = "/corporate/";
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
label: "Trips",
|
|
504
|
+
onClick: () => {
|
|
505
|
+
window.location.href = "/corporate/trips/";
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
label: "Users",
|
|
510
|
+
onClick: () => {
|
|
511
|
+
window.location.href = "/users/users";
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
label: "Tags (Custom Variables)",
|
|
516
|
+
onClick: () => {
|
|
517
|
+
window.location.href = "/orgselector/?path=tag";
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
label: "Special Request",
|
|
522
|
+
onClick: () => {
|
|
523
|
+
window.location.href = "/orgselector/?path=special-requests";
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
label: "Support Tickets (Coming Soon)",
|
|
528
|
+
isDisabled: true
|
|
529
|
+
// onClick: () => {},
|
|
530
|
+
}
|
|
531
|
+
],
|
|
532
|
+
isDropDown: true
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
Icon: import_lucide_react4.Banknote,
|
|
536
|
+
label: "Finance",
|
|
537
|
+
onClick: () => {
|
|
538
|
+
},
|
|
539
|
+
isDropDown: true,
|
|
540
|
+
options: [
|
|
541
|
+
{
|
|
542
|
+
label: "Credit Management",
|
|
543
|
+
onClick: () => {
|
|
544
|
+
window.location.href = "/finance/paymentsLedger/";
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
label: "Booking & Invoices",
|
|
549
|
+
onClick: () => {
|
|
550
|
+
window.location.href = "/finance/bookingHistory/";
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
]
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
Icon: import_lucide_react4.DollarSign,
|
|
557
|
+
label: "Revenue Management",
|
|
558
|
+
onClick: () => {
|
|
559
|
+
},
|
|
560
|
+
isDropDown: true,
|
|
561
|
+
options: [
|
|
562
|
+
{
|
|
563
|
+
label: "Pricing Engine",
|
|
564
|
+
onClick: () => {
|
|
565
|
+
window.location.href = "/orgselector/?path=pricing-policy";
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
label: "Offers",
|
|
570
|
+
onClick: () => {
|
|
571
|
+
window.location.href = "/orgselector/?path=offer";
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
label: "Vouchers",
|
|
576
|
+
onClick: () => {
|
|
577
|
+
window.location.href = "/orgselector/?path=voucher";
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
]
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
Icon: import_lucide_react4.Handshake,
|
|
584
|
+
label: "Supplier Ecosystem",
|
|
585
|
+
onClick: () => {
|
|
586
|
+
},
|
|
587
|
+
isDropDown: true,
|
|
588
|
+
options: [
|
|
589
|
+
{
|
|
590
|
+
label: "Suppliers List",
|
|
591
|
+
onClick: () => {
|
|
592
|
+
window.location.href = "/orgselector/?path=supplier-list";
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
label: "Supplier Deals",
|
|
597
|
+
onClick: () => {
|
|
598
|
+
window.location.href = "/supplierdeals/";
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
]
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
Icon: import_lucide_react4.BarChart3,
|
|
605
|
+
label: "Reports",
|
|
606
|
+
onClick: () => {
|
|
607
|
+
},
|
|
608
|
+
isDropDown: true,
|
|
609
|
+
options: [
|
|
610
|
+
{
|
|
611
|
+
label: "Reports",
|
|
612
|
+
onClick: () => {
|
|
613
|
+
window.location.href = "/reports/";
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
]
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
Icon: import_lucide_react4.Cog,
|
|
620
|
+
label: "Settings",
|
|
621
|
+
onClick: () => {
|
|
622
|
+
},
|
|
623
|
+
isDropDown: true,
|
|
624
|
+
options: [
|
|
625
|
+
{
|
|
626
|
+
label: "Whitelabel",
|
|
627
|
+
onClick: () => {
|
|
628
|
+
window.location.href = "/whitelabel/";
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
label: "Markets",
|
|
633
|
+
onClick: () => {
|
|
634
|
+
window.location.href = "/market/";
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
label: "Users",
|
|
639
|
+
onClick: () => {
|
|
640
|
+
window.location.href = `/users/users?role=admin&auth=${encodedAuthData}`;
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
label: "Reports Configurations",
|
|
645
|
+
onClick: () => {
|
|
646
|
+
window.location.href = "/reports/";
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
];
|
|
652
|
+
var additionalItemsConstant = [
|
|
653
|
+
{
|
|
654
|
+
Icon: import_lucide_react4.LifeBuoy,
|
|
655
|
+
label: "Help",
|
|
656
|
+
onClick: () => {
|
|
657
|
+
window.location.href = "/help";
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
];
|
|
661
|
+
|
|
662
|
+
// src/sideBar/SideBar.jsx
|
|
663
|
+
var import_js_cookie = __toESM(require("js-cookie"));
|
|
664
|
+
|
|
665
|
+
// src/inputs/CustomSelect.jsx
|
|
666
|
+
var import_react11 = __toESM(require("react"));
|
|
667
|
+
var import_lucide_react5 = require("lucide-react");
|
|
668
|
+
var CustomSelect = ({
|
|
669
|
+
id = "custom-select",
|
|
670
|
+
label,
|
|
671
|
+
value,
|
|
672
|
+
onChange,
|
|
673
|
+
options,
|
|
674
|
+
placeholder = "Select...",
|
|
675
|
+
isRequired = false,
|
|
676
|
+
error,
|
|
677
|
+
heading,
|
|
678
|
+
disabled = false
|
|
679
|
+
}) => {
|
|
680
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
681
|
+
const [search, setSearch] = (0, import_react11.useState)("");
|
|
682
|
+
const wrapperRef = (0, import_react11.useRef)(null);
|
|
683
|
+
const handleBlur = (e) => {
|
|
684
|
+
var _a;
|
|
685
|
+
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
686
|
+
setOpen(false);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
const filteredOptions = options.filter(
|
|
690
|
+
(opt) => opt.label.toLowerCase().includes(search.toLowerCase())
|
|
691
|
+
);
|
|
692
|
+
const handleSelect = (val) => {
|
|
693
|
+
onChange(val);
|
|
694
|
+
setOpen(false);
|
|
695
|
+
};
|
|
696
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
697
|
+
return /* @__PURE__ */ import_react11.default.createElement(
|
|
698
|
+
"div",
|
|
699
|
+
{
|
|
700
|
+
className: "flex flex-col w-full relative",
|
|
701
|
+
ref: wrapperRef,
|
|
702
|
+
tabIndex: disabled ? -1 : 0,
|
|
703
|
+
onBlur: handleBlur,
|
|
704
|
+
id: `${id}-div-1`
|
|
705
|
+
},
|
|
706
|
+
heading && /* @__PURE__ */ import_react11.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
|
|
707
|
+
label && /* @__PURE__ */ import_react11.default.createElement(
|
|
708
|
+
"label",
|
|
709
|
+
{
|
|
710
|
+
className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
|
|
711
|
+
id: `${id}-label-1`
|
|
712
|
+
},
|
|
713
|
+
label,
|
|
714
|
+
" ",
|
|
715
|
+
isRequired && /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
716
|
+
),
|
|
717
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
718
|
+
"div",
|
|
719
|
+
{
|
|
720
|
+
onClick: () => !disabled && setOpen((prev) => !prev),
|
|
721
|
+
className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
|
|
722
|
+
${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
|
|
723
|
+
${error ? "border-red-500" : "border-gray-300"}
|
|
724
|
+
`,
|
|
725
|
+
id: `${id}-div-2`
|
|
726
|
+
},
|
|
727
|
+
/* @__PURE__ */ import_react11.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
|
|
728
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
729
|
+
import_lucide_react5.ChevronDown,
|
|
730
|
+
{
|
|
731
|
+
className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
),
|
|
735
|
+
open && !disabled && /* @__PURE__ */ import_react11.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react11.default.createElement(
|
|
736
|
+
"input",
|
|
737
|
+
{
|
|
738
|
+
type: "text",
|
|
739
|
+
value: search,
|
|
740
|
+
onChange: (e) => setSearch(e.target.value),
|
|
741
|
+
placeholder: "Search...",
|
|
742
|
+
className: "flex-1 text-sm focus:outline-none",
|
|
743
|
+
id: `${id}-input-1`
|
|
744
|
+
}
|
|
745
|
+
)), /* @__PURE__ */ import_react11.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react11.default.createElement(
|
|
746
|
+
"li",
|
|
747
|
+
{
|
|
748
|
+
key: opt.value,
|
|
749
|
+
onClick: () => handleSelect(opt.value),
|
|
750
|
+
className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
|
|
751
|
+
id: `${id}-li-1`
|
|
752
|
+
},
|
|
753
|
+
opt.label
|
|
754
|
+
)) : /* @__PURE__ */ import_react11.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
|
|
755
|
+
);
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// src/utils/cookieHelpers.js
|
|
759
|
+
var JETT_ID_COOKIE_NAME = "jett-id";
|
|
760
|
+
function getCookie(name) {
|
|
761
|
+
if (typeof document === "undefined" || !document.cookie) return null;
|
|
762
|
+
const match = document.cookie.match(
|
|
763
|
+
new RegExp("(^|\\s)" + name + "=([^;]+)")
|
|
764
|
+
);
|
|
765
|
+
return match ? decodeURIComponent(match[2].trim()) : null;
|
|
766
|
+
}
|
|
767
|
+
function decodeBase64(value) {
|
|
768
|
+
try {
|
|
769
|
+
let base64 = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
770
|
+
const pad = base64.length % 4;
|
|
771
|
+
if (pad) base64 += "=".repeat(4 - pad);
|
|
772
|
+
return atob(base64);
|
|
773
|
+
} catch {
|
|
774
|
+
return "";
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function getJettIdCookieData() {
|
|
778
|
+
const raw = getCookie(JETT_ID_COOKIE_NAME);
|
|
779
|
+
if (!raw) return null;
|
|
780
|
+
try {
|
|
781
|
+
const decoded = decodeBase64(raw);
|
|
782
|
+
if (!decoded) return null;
|
|
783
|
+
const data = JSON.parse(decoded);
|
|
784
|
+
return data && typeof data === "object" ? data : null;
|
|
785
|
+
} catch {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
function getLogoFromJettIdCookie() {
|
|
790
|
+
const data = getJettIdCookieData();
|
|
791
|
+
if (!(data == null ? void 0 : data.CDNBasePath)) return null;
|
|
792
|
+
const logoPath = (data.OrgLogo || data.TmcLogo || "").trim();
|
|
793
|
+
if (!logoPath) return null;
|
|
794
|
+
return {
|
|
795
|
+
logoPath,
|
|
796
|
+
CDNBasePath: data.CDNBasePath
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
function getScopeFromJettIdCookie() {
|
|
800
|
+
const data = getJettIdCookieData();
|
|
801
|
+
return (data == null ? void 0 : data.Scope) ?? null;
|
|
802
|
+
}
|
|
803
|
+
function getProfilesFromJettIdCookie(all) {
|
|
804
|
+
const data = getJettIdCookieData();
|
|
805
|
+
if (!(data == null ? void 0 : data.Profiles)) return [];
|
|
806
|
+
if (all) return data.Profiles;
|
|
807
|
+
return data.Profiles.filter((profile) => {
|
|
808
|
+
var _a;
|
|
809
|
+
return (_a = profile.Scope) == null ? void 0 : _a.endsWith("_ENTITY");
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
function buildLogoUrl(CDNBasePath, logoPath) {
|
|
813
|
+
const base = (CDNBasePath || "").replace(/\/$/, "");
|
|
814
|
+
const path = (logoPath || "").replace(/^\//, "");
|
|
815
|
+
if (!base || !path) return "";
|
|
816
|
+
return `${base}/${path}`;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// src/sideBar/SwitchProfileSection.jsx
|
|
820
|
+
var import_react13 = __toESM(require("react"));
|
|
821
|
+
var import_react_dom2 = require("react-dom");
|
|
822
|
+
var import_lucide_react7 = require("lucide-react");
|
|
823
|
+
|
|
824
|
+
// src/sideBar/LogoutConfirmModal.jsx
|
|
825
|
+
var import_react12 = __toESM(require("react"));
|
|
826
|
+
var import_react_dom = require("react-dom");
|
|
827
|
+
var import_lucide_react6 = require("lucide-react");
|
|
828
|
+
var LogoutConfirmModal = ({
|
|
829
|
+
id = "logout-confirm",
|
|
830
|
+
open,
|
|
831
|
+
onConfirm,
|
|
832
|
+
onCancel,
|
|
833
|
+
loading = false
|
|
834
|
+
}) => {
|
|
835
|
+
if (!open || typeof document === "undefined") return null;
|
|
836
|
+
const handleOverlayClick = (e) => {
|
|
837
|
+
if (e.target === e.currentTarget && !loading) onCancel();
|
|
838
|
+
};
|
|
839
|
+
return (0, import_react_dom.createPortal)(
|
|
840
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
841
|
+
"div",
|
|
842
|
+
{
|
|
843
|
+
className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
|
|
844
|
+
onClick: handleOverlayClick,
|
|
845
|
+
id: `${id}-overlay`
|
|
846
|
+
},
|
|
847
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ import_react12.default.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
848
|
+
"button",
|
|
849
|
+
{
|
|
850
|
+
type: "button",
|
|
851
|
+
onClick: onCancel,
|
|
852
|
+
disabled: loading,
|
|
853
|
+
className: "flex-1 no-wrap rounded-lg border border-gray-300 dark:border-[#303036] px-4 py-2 text-[14px] font-medium text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
|
|
854
|
+
id: `${id}-cancel-button`
|
|
855
|
+
},
|
|
856
|
+
"No, Keep me in"
|
|
857
|
+
), /* @__PURE__ */ import_react12.default.createElement(
|
|
858
|
+
"button",
|
|
859
|
+
{
|
|
860
|
+
type: "button",
|
|
861
|
+
onClick: onConfirm,
|
|
862
|
+
disabled: loading,
|
|
863
|
+
className: "flex-1 rounded-lg bg-red-600 px-4 py-2 text-[14px] font-medium text-white cursor-pointer hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
|
|
864
|
+
id: `${id}-confirm-button`
|
|
865
|
+
},
|
|
866
|
+
loading ? "Logging out..." : "Yes, logout"
|
|
867
|
+
)))
|
|
868
|
+
),
|
|
869
|
+
document.body
|
|
870
|
+
);
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
// src/utils/switchProfileEncryption.js
|
|
874
|
+
var import_node_forge = __toESM(require("node-forge"));
|
|
875
|
+
var RSA_MODULUS_BASE64 = "zktSGmyKa5SR8HO540HKTdgDPVmXafgGFrf4OYtRNApRssnt0hGoMU7Jitc/SVWbPstFshIi5XblbDL2NXWYhZtj4PWL4SKc1/bM02xxabPw/eFr3XAAPCF62WxAVPsJBbEoAB0AcOCeIcGHb+tzLtXQJAvOuIBsKLQiiB7/c9ltt5AVVM4si1RC3JsxpqcGTkgwnh+FMg8CFvLdHjh/oi789wj8zoGWLAdYSBBa8IoQgTuzZt1tft2LF0y4Ck3yT8F9TX5GbAiVXb0G9cM/hUmDNz/6xOvHuOfH5147tKDUNCT/sr5tEaLm5ePUmRdpoc5PZa04q1KGJ0rxf6T55E5pQ8Qh2EFr1yPyLh12wiSTRsnHwXwVsosbNNBBN3HdBOMklTQx2VJNDHpi19G+z4d1evlS8yDqNZe9QyRFKEsTd+xPg3ob3j/ObpYDOtXoMaw8fXWbvyG4MJTz7nWG5YL2s5oWSAFZ4mifgwOmM/OuTO/uholelws25k/a3+O/s5Xd/HOugBvpeb5azGLfMHrGvu6J9DSIVI28hfbaFm2+smjyLdS+5PWV2+hM9EQLgaw/euGx4Qhzo2nagLwl9+hNOZ2gjtNHJxJtbQJTNrE90d3mX2/yfxHzh8FiiAiraxiZCgdUQeEZbZNlAwQLHIYWazSqgmRhf4D1LGMMrak=";
|
|
876
|
+
var RSA_EXPONENT_BASE64 = "AQAB";
|
|
877
|
+
var convertModulusExponentToPem = (modulus, exponent) => {
|
|
878
|
+
const decodedModulus = import_node_forge.default.util.decode64(modulus);
|
|
879
|
+
const decodedExponent = import_node_forge.default.util.decode64(exponent);
|
|
880
|
+
const publicKey = import_node_forge.default.pki.setRsaPublicKey(
|
|
881
|
+
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedModulus), 16),
|
|
882
|
+
new import_node_forge.default.jsbn.BigInteger(import_node_forge.default.util.bytesToHex(decodedExponent), 16)
|
|
883
|
+
);
|
|
884
|
+
return import_node_forge.default.pki.publicKeyToPem(publicKey);
|
|
885
|
+
};
|
|
886
|
+
var cachedPemKey = null;
|
|
887
|
+
var getPemKey = () => {
|
|
888
|
+
if (!cachedPemKey) {
|
|
889
|
+
cachedPemKey = convertModulusExponentToPem(RSA_MODULUS_BASE64, RSA_EXPONENT_BASE64);
|
|
890
|
+
}
|
|
891
|
+
return cachedPemKey;
|
|
892
|
+
};
|
|
893
|
+
var encryptForSwitchProfile = (plainText) => {
|
|
894
|
+
const publicKey = import_node_forge.default.pki.publicKeyFromPem(getPemKey());
|
|
895
|
+
const encrypted = publicKey.encrypt(plainText, "RSAES-PKCS1-V1_5");
|
|
896
|
+
return import_node_forge.default.util.encode64(encrypted).replace(/\r?\n|\r/g, "");
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
// src/sideBar/SwitchProfileSection.jsx
|
|
900
|
+
var SwitchProfileSection = ({
|
|
901
|
+
id = "switch-profile",
|
|
902
|
+
open,
|
|
903
|
+
anchorRef,
|
|
904
|
+
onClose,
|
|
905
|
+
onManageProfile,
|
|
906
|
+
onProfileSwitch,
|
|
907
|
+
onTmcSettings,
|
|
908
|
+
onLogout
|
|
909
|
+
}) => {
|
|
910
|
+
const [position, setPosition] = (0, import_react13.useState)(null);
|
|
911
|
+
const [showLogoutConfirm, setShowLogoutConfirm] = (0, import_react13.useState)(false);
|
|
912
|
+
const [switchingProfileId, setSwitchingProfileId] = (0, import_react13.useState)(null);
|
|
913
|
+
const [switchError, setSwitchError] = (0, import_react13.useState)(null);
|
|
914
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
915
|
+
if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
|
|
916
|
+
const updatePosition = () => {
|
|
917
|
+
const rect = anchorRef.current.getBoundingClientRect();
|
|
918
|
+
setPosition({
|
|
919
|
+
left: rect.right + 2,
|
|
920
|
+
bottom: window.innerHeight - rect.bottom
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
updatePosition();
|
|
924
|
+
window.addEventListener("resize", updatePosition);
|
|
925
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
926
|
+
return () => {
|
|
927
|
+
window.removeEventListener("resize", updatePosition);
|
|
928
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
929
|
+
};
|
|
930
|
+
}, [open, anchorRef]);
|
|
931
|
+
(0, import_react13.useEffect)(() => {
|
|
932
|
+
if (!open) setSwitchError(null);
|
|
933
|
+
}, [open]);
|
|
934
|
+
(0, import_react13.useEffect)(() => {
|
|
935
|
+
if (!switchError) return;
|
|
936
|
+
const timer = setTimeout(() => setSwitchError(null), 5e3);
|
|
937
|
+
return () => clearTimeout(timer);
|
|
938
|
+
}, [switchError]);
|
|
939
|
+
if (!open && !showLogoutConfirm || typeof document === "undefined") return null;
|
|
940
|
+
const jettIdData = getJettIdCookieData();
|
|
941
|
+
const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
|
|
942
|
+
const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
|
|
943
|
+
const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
|
|
944
|
+
const allMarkets = getProfilesFromJettIdCookie(true);
|
|
945
|
+
const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
|
|
946
|
+
const handleConfirmLogout = () => {
|
|
947
|
+
setShowLogoutConfirm(false);
|
|
948
|
+
onLogout == null ? void 0 : onLogout();
|
|
949
|
+
};
|
|
950
|
+
const buildRequestContext = () => ({
|
|
951
|
+
UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
|
|
952
|
+
TrackingId: crypto.randomUUID(),
|
|
953
|
+
TransactionId: crypto.randomUUID(),
|
|
954
|
+
CountryCode: "IN",
|
|
955
|
+
IpAddress: "127.0.0.1"
|
|
956
|
+
// Client IP cannot be retrieved from browser
|
|
957
|
+
});
|
|
958
|
+
const handleProfileSwitch = async (profile) => {
|
|
959
|
+
var _a, _b, _c;
|
|
960
|
+
if (switchingProfileId) return;
|
|
961
|
+
setSwitchingProfileId(profile.ProfileId);
|
|
962
|
+
setSwitchError(null);
|
|
963
|
+
try {
|
|
964
|
+
const encryptedRequest = encryptForSwitchProfile(
|
|
965
|
+
JSON.stringify({
|
|
966
|
+
ProfileToken: profile.ProfileToken,
|
|
967
|
+
ProfileId: profile.ProfileId
|
|
968
|
+
})
|
|
969
|
+
);
|
|
970
|
+
const response = await fetch(`${window.location.origin}/auth/switch/profile`, {
|
|
971
|
+
method: "POST",
|
|
972
|
+
credentials: "include",
|
|
973
|
+
headers: { "Content-Type": "application/json" },
|
|
974
|
+
body: JSON.stringify({
|
|
975
|
+
Context: buildRequestContext(),
|
|
976
|
+
Request: encryptedRequest
|
|
977
|
+
})
|
|
978
|
+
}).then((res) => res.json());
|
|
979
|
+
const statusCode = (_a = response == null ? void 0 : response.Context) == null ? void 0 : _a.StatusCode;
|
|
980
|
+
const isSuccess = !statusCode || statusCode === 200;
|
|
981
|
+
if (!isSuccess) {
|
|
982
|
+
setSwitchError(((_b = response == null ? void 0 : response.Context) == null ? void 0 : _b.Message) || "Unable to switch profile. Please try again.");
|
|
983
|
+
setSwitchingProfileId(null);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
if ((_c = response == null ? void 0 : response.Response) == null ? void 0 : _c.RedirectUrl) {
|
|
987
|
+
window.location.href = response.Response.RedirectUrl;
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
setSwitchingProfileId(null);
|
|
991
|
+
onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
|
|
992
|
+
} catch (error) {
|
|
993
|
+
console.error("Switch profile request failed:", error);
|
|
994
|
+
setSwitchError("Something went wrong while switching profile. Please try again.");
|
|
995
|
+
setSwitchingProfileId(null);
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, open && (0, import_react_dom2.createPortal)(
|
|
999
|
+
/* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop` }), /* @__PURE__ */ import_react13.default.createElement(
|
|
1000
|
+
"div",
|
|
1001
|
+
{
|
|
1002
|
+
className: "fixed w-[320px] max-h-[75vh] flex p-4 flex-col overflow-hidden bg-white dark:bg-[#18181b] rounded-xl shadow-xl border border-gray-200 dark:border-[#303036] z-[9999]",
|
|
1003
|
+
style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
|
|
1004
|
+
id: `${id}-panel`
|
|
1005
|
+
},
|
|
1006
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between gap-3 pb-4", id: `${id}-header` }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center gap-3 min-w-0", id: `${id}-header-user` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden rounded-full h-10 w-10", id: `${id}-avatar` }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border-2 border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white" }, userName ? userName.charAt(0) : "40 * 40")), /* @__PURE__ */ import_react13.default.createElement("div", { className: "min-w-0", id: `${id}-header-text` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "!font-semibold dark:text-white !text-[14px] truncate" }, userName || "Admin"), /* @__PURE__ */ import_react13.default.createElement("p", { className: "!text-[10px] !font-normal text-gray-500 dark:text-[#f4f4f5cc] truncate" }, userEmail))), /* @__PURE__ */ import_react13.default.createElement(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
type: "button",
|
|
1010
|
+
onClick: onManageProfile,
|
|
1011
|
+
className: "shrink-0 whitespace-nowrap rounded-md border border-gray-300 dark:border-[#303036] px-3 py-1.5 text-[10px] font-bold uppercase tracking-wide text-[#0A0A0A] dark:text-[#f4f4f5cc] cursor-pointer hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors duration-200",
|
|
1012
|
+
id: `${id}-manage-profile-button`
|
|
1013
|
+
},
|
|
1014
|
+
"Manage Profile"
|
|
1015
|
+
)),
|
|
1016
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
|
|
1017
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "pb-4 text-[10px] font-bold tracking-wider text-[#737373] uppercase", id: `${id}-markets-label` }, "Your Markets"), switchError && /* @__PURE__ */ import_react13.default.createElement(
|
|
1018
|
+
"div",
|
|
1019
|
+
{
|
|
1020
|
+
className: "mb-3 rounded-lg border border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-[12px] font-medium text-red-600",
|
|
1021
|
+
id: `${id}-switch-error`
|
|
1022
|
+
},
|
|
1023
|
+
switchError
|
|
1024
|
+
), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-2 pb-4", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react13.default.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
|
|
1025
|
+
const isCurrent = profile.ProfileId === currentProfileId;
|
|
1026
|
+
const isSwitching = switchingProfileId === profile.ProfileId;
|
|
1027
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
1028
|
+
"div",
|
|
1029
|
+
{
|
|
1030
|
+
key: profile.ProfileId,
|
|
1031
|
+
onClick: () => !isCurrent && handleProfileSwitch(profile),
|
|
1032
|
+
"aria-disabled": isSwitching,
|
|
1033
|
+
className: `flex items-center justify-between gap-2 rounded-lg p-3 cursor-pointer hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] transition-colors duration-200 ${isCurrent ? "border border-gray-800 dark:border-white bg-[#f4f4f5] text-[#0A0A0A]" : "border border-transparent"} ${isSwitching ? "opacity-50 pointer-events-none" : ""}`,
|
|
1034
|
+
id: `${id}-market-${profile.ProfileId}`
|
|
1035
|
+
},
|
|
1036
|
+
/* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-bold !text-[14px] text-gray-900 dark:text-[#f4f4f5cc] truncate" }, profile.EntityName),
|
|
1037
|
+
isCurrent && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 rounded-full bg-blue-600 px-2.5 py-0.5 border-2 border-white text-[9px] font-bold uppercase tracking-wide text-white" }, "Logged In"),
|
|
1038
|
+
isSwitching && /* @__PURE__ */ import_react13.default.createElement("span", { className: "shrink-0 text-[11px] text-gray-400" }, "Switching...")
|
|
1039
|
+
);
|
|
1040
|
+
}))),
|
|
1041
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "border-t border-gray-200 dark:border-[#303036] mb-4" }),
|
|
1042
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "", id: `${id}-footer` }, /* @__PURE__ */ import_react13.default.createElement(
|
|
1043
|
+
"div",
|
|
1044
|
+
{
|
|
1045
|
+
onClick: () => {
|
|
1046
|
+
onClose == null ? void 0 : onClose();
|
|
1047
|
+
setShowLogoutConfirm(true);
|
|
1048
|
+
},
|
|
1049
|
+
className: "flex items-center gap-3 p-3 rounded-lg cursor-pointer text-red-600 hover:bg-red-50 dark:hover:bg-[#27272a] transition-colors duration-200",
|
|
1050
|
+
id: `${id}-logout`
|
|
1051
|
+
},
|
|
1052
|
+
/* @__PURE__ */ import_react13.default.createElement(import_lucide_react7.LogOut, { width: 18, height: 18 }),
|
|
1053
|
+
/* @__PURE__ */ import_react13.default.createElement("span", { className: "!font-bold !text-[14px]" }, "Logout")
|
|
1054
|
+
))
|
|
1055
|
+
)),
|
|
1056
|
+
document.body
|
|
1057
|
+
), /* @__PURE__ */ import_react13.default.createElement(
|
|
1058
|
+
LogoutConfirmModal,
|
|
1059
|
+
{
|
|
1060
|
+
id: `${id}-logout-confirm`,
|
|
1061
|
+
open: showLogoutConfirm,
|
|
1062
|
+
onCancel: () => setShowLogoutConfirm(false),
|
|
1063
|
+
onConfirm: handleConfirmLogout
|
|
1064
|
+
}
|
|
1065
|
+
));
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
// src/sideBar/SideBar.jsx
|
|
1069
|
+
var SCOPE_LABELS = {
|
|
1070
|
+
TMC: "TMC Manager",
|
|
1071
|
+
TMC_ENTITY: "TMC Entity Manager"
|
|
1072
|
+
};
|
|
1073
|
+
var AppSideBar = ({
|
|
1074
|
+
id = "side-bar",
|
|
1075
|
+
username,
|
|
1076
|
+
navItems,
|
|
1077
|
+
additionalItems,
|
|
1078
|
+
sideBarLogo,
|
|
1079
|
+
onManageProfile,
|
|
1080
|
+
onProfileSwitch,
|
|
1081
|
+
onTmcSettings,
|
|
1082
|
+
onLogout
|
|
1083
|
+
}) => {
|
|
1084
|
+
var _a, _b;
|
|
1085
|
+
const profileCardRef = (0, import_react14.useRef)(null);
|
|
1086
|
+
const [authData, setAuthData] = (0, import_react14.useState)(null);
|
|
1087
|
+
const [cookieUserName, setCookieUserName] = (0, import_react14.useState)(null);
|
|
1088
|
+
const [scope, setScope] = (0, import_react14.useState)(null);
|
|
1089
|
+
const [selectedCountry, setSelectedCountry] = (0, import_react14.useState)("dubai");
|
|
1090
|
+
const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react14.useState)(false);
|
|
1091
|
+
const [isSwitchProfileOpen, setIsSwitchProfileOpen] = (0, import_react14.useState)(false);
|
|
1092
|
+
const [openMenus, setOpenMenus] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
|
|
1093
|
+
const [activeMenuPath, setActiveMenuPath] = (0, import_react14.useState)(null);
|
|
1094
|
+
const [currAppearance, setCurrAppearance] = (0, import_react14.useState)("light");
|
|
1095
|
+
(0, import_react14.useEffect)(() => {
|
|
1096
|
+
setCurrAppearance("light");
|
|
1097
|
+
}, []);
|
|
1098
|
+
const countryOptions = [
|
|
1099
|
+
{ label: "India", value: "india" },
|
|
1100
|
+
{ label: "Dubai", value: "dubai" },
|
|
1101
|
+
{ label: "Singapore", value: "singapore" },
|
|
1102
|
+
{ label: "Qatar", value: "qatar" }
|
|
1103
|
+
];
|
|
1104
|
+
const toggleMenu = (menuKey) => {
|
|
1105
|
+
setOpenMenus((prev) => {
|
|
1106
|
+
const newSet = new Set(prev);
|
|
1107
|
+
if (newSet.has(menuKey)) {
|
|
1108
|
+
newSet.delete(menuKey);
|
|
1109
|
+
} else {
|
|
1110
|
+
newSet.add(menuKey);
|
|
1111
|
+
}
|
|
1112
|
+
return newSet;
|
|
1113
|
+
});
|
|
1114
|
+
};
|
|
1115
|
+
const isMenuOpen = (menuKey) => {
|
|
1116
|
+
return openMenus.has(menuKey);
|
|
1117
|
+
};
|
|
1118
|
+
const handleMenuClick = (item, index, e) => {
|
|
1119
|
+
if (item.isDropDown) {
|
|
1120
|
+
e.preventDefault();
|
|
1121
|
+
const menuKey = `menu-${index}`;
|
|
1122
|
+
toggleMenu(menuKey);
|
|
1123
|
+
setActiveMenuPath(`menu-${index}`);
|
|
1124
|
+
} else {
|
|
1125
|
+
setActiveMenuPath(`menu-${index}`);
|
|
1126
|
+
if (item.onClick) {
|
|
1127
|
+
item.onClick(e);
|
|
1128
|
+
}
|
|
1129
|
+
closeMobileMenu();
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
const handleSubMenuClick = (option, optionsIndex, parentIndex, e) => {
|
|
1133
|
+
const parentMenuKey = `menu-${parentIndex}`;
|
|
1134
|
+
setOpenMenus((prev) => {
|
|
1135
|
+
const newSet = new Set(prev);
|
|
1136
|
+
newSet.add(parentMenuKey);
|
|
1137
|
+
return newSet;
|
|
1138
|
+
});
|
|
1139
|
+
if (option.isDropDown) {
|
|
1140
|
+
e.preventDefault();
|
|
1141
|
+
const menuKey = `menu-${parentIndex}-option-${optionsIndex}`;
|
|
1142
|
+
toggleMenu(menuKey);
|
|
1143
|
+
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
|
|
1144
|
+
} else {
|
|
1145
|
+
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
|
|
1146
|
+
if (option.onClick) {
|
|
1147
|
+
option.onClick();
|
|
1148
|
+
}
|
|
1149
|
+
closeMobileMenu();
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
const handleSubSubMenuClick = (subOption, parentIndex, optionsIndex, e) => {
|
|
1153
|
+
const parentMenuKey = `menu-${parentIndex}`;
|
|
1154
|
+
const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
|
|
1155
|
+
setOpenMenus((prev) => {
|
|
1156
|
+
const newSet = new Set(prev);
|
|
1157
|
+
newSet.add(parentMenuKey);
|
|
1158
|
+
newSet.add(subMenuKey);
|
|
1159
|
+
return newSet;
|
|
1160
|
+
});
|
|
1161
|
+
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}-sub-${subOption.label}`);
|
|
1162
|
+
if (subOption.onClick) {
|
|
1163
|
+
subOption.onClick();
|
|
1164
|
+
}
|
|
1165
|
+
closeMobileMenu();
|
|
1166
|
+
};
|
|
1167
|
+
(0, import_react14.useEffect)(() => {
|
|
1168
|
+
const storedAuthData = localStorage.getItem("authData");
|
|
1169
|
+
if (storedAuthData) {
|
|
1170
|
+
let parseData = JSON.parse(storedAuthData);
|
|
1171
|
+
setAuthData(parseData);
|
|
1172
|
+
}
|
|
1173
|
+
}, [localStorage.getItem("authData")]);
|
|
1174
|
+
(0, import_react14.useEffect)(() => {
|
|
1175
|
+
const jettIdData = getJettIdCookieData();
|
|
1176
|
+
if (jettIdData == null ? void 0 : jettIdData.UserName) {
|
|
1177
|
+
setCookieUserName(jettIdData.UserName);
|
|
1178
|
+
}
|
|
1179
|
+
const cookieScope = getScopeFromJettIdCookie();
|
|
1180
|
+
if (cookieScope) {
|
|
1181
|
+
setScope(cookieScope);
|
|
1182
|
+
}
|
|
1183
|
+
}, []);
|
|
1184
|
+
const extractUrlFromOnClick = (onClick) => {
|
|
1185
|
+
if (!onClick || typeof onClick !== "function") return null;
|
|
1186
|
+
const funcString = onClick.toString();
|
|
1187
|
+
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
1188
|
+
if (!match) {
|
|
1189
|
+
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
1190
|
+
}
|
|
1191
|
+
if (match && match[1]) {
|
|
1192
|
+
try {
|
|
1193
|
+
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
1194
|
+
const url = new URL(match[1]);
|
|
1195
|
+
return {
|
|
1196
|
+
pathname: url.pathname,
|
|
1197
|
+
search: url.search,
|
|
1198
|
+
fullPath: url.pathname + url.search
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
if (match[1].startsWith("/")) {
|
|
1202
|
+
const url = new URL(match[1], window.location.origin);
|
|
1203
|
+
return {
|
|
1204
|
+
pathname: url.pathname,
|
|
1205
|
+
search: url.search,
|
|
1206
|
+
fullPath: url.pathname + url.search
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
return null;
|
|
1210
|
+
} catch {
|
|
1211
|
+
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
1212
|
+
if (pathMatch) {
|
|
1213
|
+
return {
|
|
1214
|
+
pathname: pathMatch[1],
|
|
1215
|
+
search: pathMatch[2] || "",
|
|
1216
|
+
fullPath: match[1]
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
return null;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
return null;
|
|
1223
|
+
};
|
|
1224
|
+
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
1225
|
+
if (!menuUrlData || !currentPath) return false;
|
|
1226
|
+
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
1227
|
+
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
1228
|
+
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
1229
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1230
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
1231
|
+
const menuRole = menuParams.get("role");
|
|
1232
|
+
const currentRole = currentParams.get("role");
|
|
1233
|
+
if (menuRole && currentRole) {
|
|
1234
|
+
return menuRole === currentRole;
|
|
1235
|
+
}
|
|
1236
|
+
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
return true;
|
|
1240
|
+
}
|
|
1241
|
+
if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
|
|
1242
|
+
return true;
|
|
1243
|
+
}
|
|
1244
|
+
if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
|
|
1245
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1246
|
+
if (currentPathParam === "supplier-list") {
|
|
1247
|
+
return true;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
|
|
1251
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1252
|
+
if (currentPathParam === "supplier-deals") {
|
|
1253
|
+
return true;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
if (normalizedMenuPath === "/corporate/trips") {
|
|
1257
|
+
if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
|
|
1262
|
+
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
1263
|
+
if (menuPathParam) {
|
|
1264
|
+
const pathRouteMap = {
|
|
1265
|
+
"offer": "/offer/offer",
|
|
1266
|
+
"voucher": "/voucher/voucher",
|
|
1267
|
+
"tag": "/tags/tags",
|
|
1268
|
+
"special-requests": "/corporate/special-requests",
|
|
1269
|
+
"pricing-policy": "/policies/pricing-policy",
|
|
1270
|
+
"supplier-list": "/supplier",
|
|
1271
|
+
"users": "/users/users"
|
|
1272
|
+
// Consumer Ecosystem Users (no role param)
|
|
1273
|
+
};
|
|
1274
|
+
const expectedRoute = pathRouteMap[menuPathParam];
|
|
1275
|
+
if (expectedRoute) {
|
|
1276
|
+
if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
|
|
1277
|
+
if (menuPathParam === "users") {
|
|
1278
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
1279
|
+
const currentRole = currentParams.get("role");
|
|
1280
|
+
return currentRole !== "admin";
|
|
1281
|
+
}
|
|
1282
|
+
return true;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
if (normalizedCurrentPath === "/orgselector") {
|
|
1287
|
+
const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
|
|
1288
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1289
|
+
if (menuPathParam2 && currentPathParam) {
|
|
1290
|
+
return menuPathParam2 === currentPathParam;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
1295
|
+
if (menuUrlData.search) {
|
|
1296
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1297
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
1298
|
+
for (const [key, value] of menuParams.entries()) {
|
|
1299
|
+
if (key === "auth") {
|
|
1300
|
+
continue;
|
|
1301
|
+
}
|
|
1302
|
+
if (currentParams.get(key) !== value) {
|
|
1303
|
+
return false;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
return true;
|
|
1307
|
+
}
|
|
1308
|
+
return true;
|
|
1309
|
+
}
|
|
1310
|
+
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
1311
|
+
return true;
|
|
1312
|
+
}
|
|
1313
|
+
return false;
|
|
1314
|
+
};
|
|
1315
|
+
const navItemsLocal = navItems ?? navItemsConstant;
|
|
1316
|
+
const additionalItemsLocal = additionalItems ?? additionalItemsConstant;
|
|
1317
|
+
const logoFromCookie = getLogoFromJettIdCookie();
|
|
1318
|
+
const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
|
|
1319
|
+
const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
|
|
1320
|
+
authData.userInfo.CDNBasePath,
|
|
1321
|
+
authData.userInfo.OrgLogo
|
|
1322
|
+
) : null;
|
|
1323
|
+
const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
|
|
1324
|
+
const detectAndSetActiveMenu = (0, import_react14.useCallback)(() => {
|
|
1325
|
+
const currentPath = window.location.pathname;
|
|
1326
|
+
const currentSearch = window.location.search;
|
|
1327
|
+
const newOpenMenus = /* @__PURE__ */ new Set();
|
|
1328
|
+
let foundActivePath = null;
|
|
1329
|
+
navItemsLocal.forEach((item, index) => {
|
|
1330
|
+
if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
|
|
1331
|
+
const itemUrlData = extractUrlFromOnClick(item.onClick);
|
|
1332
|
+
if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
|
|
1333
|
+
foundActivePath = `menu-${index}`;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
if (item.options && item.options.length > 0) {
|
|
1337
|
+
item.options.forEach((option, optionsIndex) => {
|
|
1338
|
+
if (option.onClick && typeof option.onClick === "function") {
|
|
1339
|
+
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
1340
|
+
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
1341
|
+
const menuKey = `menu-${index}`;
|
|
1342
|
+
newOpenMenus.add(menuKey);
|
|
1343
|
+
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
1344
|
+
if (option.options && option.options.length > 0) {
|
|
1345
|
+
option.options.forEach((subOption, subIndex) => {
|
|
1346
|
+
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
1347
|
+
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
1348
|
+
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
1349
|
+
newOpenMenus.add(subMenuKey);
|
|
1350
|
+
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
if (foundActivePath) {
|
|
1360
|
+
setOpenMenus(newOpenMenus);
|
|
1361
|
+
setActiveMenuPath(foundActivePath);
|
|
1362
|
+
}
|
|
1363
|
+
}, [navItemsLocal]);
|
|
1364
|
+
const [currentUrl, setCurrentUrl] = (0, import_react14.useState)(
|
|
1365
|
+
() => window.location.pathname + window.location.search
|
|
1366
|
+
);
|
|
1367
|
+
(0, import_react14.useEffect)(() => {
|
|
1368
|
+
detectAndSetActiveMenu();
|
|
1369
|
+
setCurrentUrl(window.location.pathname + window.location.search);
|
|
1370
|
+
}, [detectAndSetActiveMenu]);
|
|
1371
|
+
(0, import_react14.useEffect)(() => {
|
|
1372
|
+
let lastUrl = window.location.pathname + window.location.search;
|
|
1373
|
+
const handleLocationChange = () => {
|
|
1374
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
1375
|
+
if (newUrl !== lastUrl) {
|
|
1376
|
+
lastUrl = newUrl;
|
|
1377
|
+
setCurrentUrl(newUrl);
|
|
1378
|
+
detectAndSetActiveMenu();
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
window.addEventListener("popstate", handleLocationChange);
|
|
1382
|
+
const checkInterval = setInterval(() => {
|
|
1383
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
1384
|
+
if (newUrl !== lastUrl) {
|
|
1385
|
+
handleLocationChange();
|
|
1386
|
+
}
|
|
1387
|
+
}, 250);
|
|
1388
|
+
return () => {
|
|
1389
|
+
window.removeEventListener("popstate", handleLocationChange);
|
|
1390
|
+
clearInterval(checkInterval);
|
|
1391
|
+
};
|
|
1392
|
+
}, [detectAndSetActiveMenu]);
|
|
1393
|
+
(0, import_react14.useEffect)(() => {
|
|
1394
|
+
detectAndSetActiveMenu();
|
|
1395
|
+
}, [currentUrl, detectAndSetActiveMenu]);
|
|
1396
|
+
const toggleMobileMenu = () => {
|
|
1397
|
+
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
1398
|
+
};
|
|
1399
|
+
const closeMobileMenu = () => {
|
|
1400
|
+
setIsMobileMenuOpen(false);
|
|
1401
|
+
};
|
|
1402
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed top-0 left-0 w-full z-50 flex items-center justify-between px-4 py-3 bg-white dark:bg-[#18181b] border-b border-gray-200 dark:border-[#303036] shadow-lg md:hidden", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1403
|
+
"button",
|
|
1404
|
+
{
|
|
1405
|
+
onClick: toggleMobileMenu,
|
|
1406
|
+
className: "p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-[#27272a] transition-colors",
|
|
1407
|
+
"aria-label": "Toggle menu",
|
|
1408
|
+
id: `${id}-button-1`
|
|
1409
|
+
},
|
|
1410
|
+
isMobileMenuOpen ? /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.X, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" }) : /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.Menu, { className: "w-6 h-6 text-gray-700 dark:text-[#f4f4f5cc]" })
|
|
1411
|
+
), /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex-1 flex justify-center", id: `${id}-div-2` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
|
|
1412
|
+
"img",
|
|
1413
|
+
{
|
|
1414
|
+
src: sideBarLogoLocal,
|
|
1415
|
+
alt: "sidebarLogo",
|
|
1416
|
+
width: 208,
|
|
1417
|
+
height: 40,
|
|
1418
|
+
className: "object-contain",
|
|
1419
|
+
id: `${id}-img-1`
|
|
1420
|
+
}
|
|
1421
|
+
)), /* @__PURE__ */ import_react14.default.createElement("div", { className: "w-10", id: `${id}-div-3` })), isMobileMenuOpen && /* @__PURE__ */ import_react14.default.createElement(
|
|
1422
|
+
"div",
|
|
1423
|
+
{
|
|
1424
|
+
className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
|
|
1425
|
+
onClick: closeMobileMenu,
|
|
1426
|
+
id: `${id}-div-4`
|
|
1427
|
+
}
|
|
1428
|
+
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1429
|
+
"div",
|
|
1430
|
+
{
|
|
1431
|
+
className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
|
|
1432
|
+
id: `${id}-div-5`
|
|
1433
|
+
},
|
|
1434
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "p-2 mb-2 hidden md:block", id: `${id}-div-6` }, /* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center justify-center w-full h-[60px] mb-2", id: `${id}-div-7` }, sideBarLogoLocal && /* @__PURE__ */ import_react14.default.createElement(
|
|
1435
|
+
"img",
|
|
1436
|
+
{
|
|
1437
|
+
src: sideBarLogoLocal,
|
|
1438
|
+
alt: "sidebarLogo",
|
|
1439
|
+
width: 108,
|
|
1440
|
+
height: 40,
|
|
1441
|
+
className: "object-contain",
|
|
1442
|
+
id: `${id}-img-2`
|
|
1443
|
+
}
|
|
1444
|
+
))),
|
|
1445
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "mb-4", id: `${id}-div-8` }),
|
|
1446
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-div-9` }, /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-10` }, navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
|
|
1447
|
+
const menuKey = `menu-${index}`;
|
|
1448
|
+
const isOpen = isMenuOpen(menuKey);
|
|
1449
|
+
const isActive = activeMenuPath === menuKey;
|
|
1450
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", { key: index, className: "", id: `${id}-div-11` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1451
|
+
"div",
|
|
1452
|
+
{
|
|
1453
|
+
className: `flex items-center gap-3 p-2.5 hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-700 dark:text-[#f4f4f5cc] cursor-pointer rounded-lg ml-2 mr-2 transition-colors duration-200 ${isActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
|
|
1454
|
+
onClick: (e) => handleMenuClick(item, index, e),
|
|
1455
|
+
id: `${id}-div-12`
|
|
1456
|
+
},
|
|
1457
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "text-primary", id: `${id}-div-13` }, /* @__PURE__ */ import_react14.default.createElement(item.Icon, { width: 20, height: 20, id: `${id}-icon-1` })),
|
|
1458
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: "!font-medium !text-[16px] !text-[#000] dark:text-[#f4f4f5cc]", id: `${id}-span-1` }, item.label),
|
|
1459
|
+
item.isDropDown && /* @__PURE__ */ import_react14.default.createElement("div", { className: `ml-auto transition-all delay-75 ${isOpen ? "rotate-180" : ""}`, id: `${id}-div-14` }, /* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 20, height: 20, className: "text-gray-500 dark:text-gray-400" }))
|
|
1460
|
+
), item.options && item.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
|
|
1461
|
+
"div",
|
|
1462
|
+
{
|
|
1463
|
+
className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
|
|
1464
|
+
id: `${id}-div-15`
|
|
1465
|
+
},
|
|
1466
|
+
item.options.map((options, optionsIndex) => {
|
|
1467
|
+
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
1468
|
+
const isSubMenuOpen = isMenuOpen(subMenuKey);
|
|
1469
|
+
const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
|
|
1470
|
+
const isDisabled = options.isDisabled;
|
|
1471
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1472
|
+
"div",
|
|
1473
|
+
{
|
|
1474
|
+
className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
|
|
1475
|
+
onClick: (e) => {
|
|
1476
|
+
if (isDisabled) {
|
|
1477
|
+
e.preventDefault();
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
handleSubMenuClick(options, optionsIndex, index, e);
|
|
1481
|
+
},
|
|
1482
|
+
id: `${id}-div-17-${optionsIndex}`
|
|
1483
|
+
},
|
|
1484
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
|
|
1485
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
|
|
1486
|
+
options.isDropDown && /* @__PURE__ */ import_react14.default.createElement(
|
|
1487
|
+
"div",
|
|
1488
|
+
{
|
|
1489
|
+
className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
|
|
1490
|
+
id: `${id}-div-19-${optionsIndex}`
|
|
1491
|
+
},
|
|
1492
|
+
/* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
|
|
1493
|
+
)
|
|
1494
|
+
), options.options && options.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
|
|
1495
|
+
"div",
|
|
1496
|
+
{
|
|
1497
|
+
className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
|
|
1498
|
+
id: `${id}-div-20-${optionsIndex}`
|
|
1499
|
+
},
|
|
1500
|
+
options.options.map((subOption, subIndex) => {
|
|
1501
|
+
const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
1502
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
1503
|
+
"div",
|
|
1504
|
+
{
|
|
1505
|
+
key: subIndex,
|
|
1506
|
+
className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
|
|
1507
|
+
onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
|
|
1508
|
+
id: `${id}-div-21-${subIndex}`
|
|
1509
|
+
},
|
|
1510
|
+
subOption.label
|
|
1511
|
+
);
|
|
1512
|
+
})
|
|
1513
|
+
));
|
|
1514
|
+
})
|
|
1515
|
+
));
|
|
1516
|
+
}))),
|
|
1517
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1518
|
+
"div",
|
|
1519
|
+
{
|
|
1520
|
+
className: "group flex items-center justify-between p-2 rounded-lg hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] cursor-pointer transition-colors duration-200",
|
|
1521
|
+
onClick: () => setIsSwitchProfileOpen((prev) => !prev),
|
|
1522
|
+
id: `${id}-div-23`
|
|
1523
|
+
},
|
|
1524
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "flex items-center gap-3", id: `${id}-div-24` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "relative flex shrink-0 overflow-hidden dark:bg-[#27272a] rounded-full h-10 w-10", id: `${id}-span-3` }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-full w-full items-center justify-center !text-[16px] !font-normal border border-gray-200 dark:border-[#303036] rounded-full bg-muted dark:text-white", id: `${id}-span-4` }, cookieUserName ? cookieUserName.split("")[0] : "A")), /* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-25` }, /* @__PURE__ */ import_react14.default.createElement("p", { className: "!font-semibold dark:text-white !text-[16px]", id: `${id}-p-1` }, cookieUserName ? cookieUserName : "Admin"), /* @__PURE__ */ import_react14.default.createElement("p", { className: "!text-[14px] !font-normal dark:text-[#f4f4f5cc]", id: `${id}-p-2` }, SCOPE_LABELS[scope] ?? scope))),
|
|
1525
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
1526
|
+
"span",
|
|
1527
|
+
{
|
|
1528
|
+
className: "text-gray-600 dark:text-gray-400",
|
|
1529
|
+
id: `${id}-span-switch`
|
|
1530
|
+
},
|
|
1531
|
+
/* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronRight, { width: 20, height: 22 })
|
|
1532
|
+
)
|
|
1533
|
+
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1534
|
+
SwitchProfileSection,
|
|
1535
|
+
{
|
|
1536
|
+
id: `${id}-switch-profile`,
|
|
1537
|
+
open: isSwitchProfileOpen,
|
|
1538
|
+
anchorRef: profileCardRef,
|
|
1539
|
+
onClose: () => setIsSwitchProfileOpen(false),
|
|
1540
|
+
onManageProfile: () => {
|
|
1541
|
+
setIsSwitchProfileOpen(false);
|
|
1542
|
+
window.location.href = "/profile";
|
|
1543
|
+
},
|
|
1544
|
+
onProfileSwitch: (profile) => {
|
|
1545
|
+
setIsSwitchProfileOpen(false);
|
|
1546
|
+
onProfileSwitch == null ? void 0 : onProfileSwitch(profile);
|
|
1547
|
+
},
|
|
1548
|
+
onTmcSettings: () => {
|
|
1549
|
+
setIsSwitchProfileOpen(false);
|
|
1550
|
+
onTmcSettings == null ? void 0 : onTmcSettings();
|
|
1551
|
+
},
|
|
1552
|
+
onLogout: () => {
|
|
1553
|
+
setIsSwitchProfileOpen(false);
|
|
1554
|
+
if (onLogout) {
|
|
1555
|
+
onLogout();
|
|
1556
|
+
} else {
|
|
1557
|
+
window.location.href = `${window.location.origin}/login/logout`;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
))
|
|
1562
|
+
));
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
// src/RightSheet/RightSheet.jsx
|
|
1566
|
+
var import_react15 = __toESM(require("react"));
|
|
1567
|
+
var RightSheet = ({
|
|
1568
|
+
id = "right-sheet",
|
|
1569
|
+
open,
|
|
1570
|
+
setOpen,
|
|
1571
|
+
children,
|
|
1572
|
+
callBack,
|
|
1573
|
+
actionLabel = "Save",
|
|
1574
|
+
onAction = () => {
|
|
1575
|
+
},
|
|
1576
|
+
showFooter = true
|
|
1577
|
+
}) => {
|
|
1578
|
+
const [visible, setVisible] = (0, import_react15.useState)(open);
|
|
1579
|
+
(0, import_react15.useEffect)(() => {
|
|
1580
|
+
if (open) {
|
|
1581
|
+
document.body.style.overflow = "hidden";
|
|
1582
|
+
setVisible(true);
|
|
1583
|
+
}
|
|
1584
|
+
return () => {
|
|
1585
|
+
document.body.style.overflow = "auto";
|
|
1586
|
+
};
|
|
1587
|
+
}, [open]);
|
|
1588
|
+
const handleClose = () => {
|
|
1589
|
+
setVisible(false);
|
|
1590
|
+
setTimeout(() => {
|
|
1591
|
+
setOpen(false);
|
|
1592
|
+
callBack();
|
|
1593
|
+
}, 200);
|
|
1594
|
+
};
|
|
1595
|
+
const handleAction = () => {
|
|
1596
|
+
onAction();
|
|
1597
|
+
handleClose();
|
|
1598
|
+
};
|
|
1599
|
+
if (!visible) return null;
|
|
1600
|
+
return /* @__PURE__ */ import_react15.default.createElement(
|
|
1601
|
+
"div",
|
|
1602
|
+
{
|
|
1603
|
+
className: "fixed inset-0 overflow-x-hidden bg-black/80 sheetPopIn h-full overflow-auto ",
|
|
1604
|
+
onClick: handleClose,
|
|
1605
|
+
id: `${id}-div-1`
|
|
1606
|
+
},
|
|
1607
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
1608
|
+
"div",
|
|
1609
|
+
{
|
|
1610
|
+
className: `absolute flex flex-col right-0 top-0 min-h-full min-w-[100%] md:min-w-[576px]
|
|
1611
|
+
${visible ? "sheetRightSlide" : "transition-all duration-200 translate-x-[100%]"} justify-between bg-[#fff] dark:bg-[#18181b] dark:text-white`,
|
|
1612
|
+
onClick: (e) => e.stopPropagation(),
|
|
1613
|
+
id: `${id}-div-2`
|
|
1614
|
+
},
|
|
1615
|
+
/* @__PURE__ */ import_react15.default.createElement("div", { className: " min-h-full ", id: `${id}-div-3` }, children),
|
|
1616
|
+
showFooter && /* @__PURE__ */ import_react15.default.createElement("div", { className: "h-[90px] flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 p-6 border-t sticky bottom-0 bg-white border-[#e6e6e6] dark:border-[#303036] dark:bg-[#18181b] dark:text-white", id: `${id}-div-4` }, /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: () => handleClose(), id: `${id}-custom-button-1` }, "Cancel"), /* @__PURE__ */ import_react15.default.createElement(CustomButton, { variant: "SECONDARY", onClick: handleAction, id: `${id}-custom-button-2` }, actionLabel))
|
|
1617
|
+
)
|
|
1618
|
+
);
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
// src/Table/CustomTable.jsx
|
|
1622
|
+
var import_react16 = __toESM(require("react"));
|
|
1623
|
+
var CustomTable = ({
|
|
1624
|
+
id = "custom-table",
|
|
1625
|
+
tableHeader,
|
|
1626
|
+
setIsAllChecked,
|
|
1627
|
+
isAllChecked,
|
|
1628
|
+
children,
|
|
1629
|
+
isHideCheckbox = "false"
|
|
1630
|
+
}) => {
|
|
1631
|
+
return /* @__PURE__ */ import_react16.default.createElement("div", { className: "border border-[#e5e5e5] dark:border-[#303036] rounded-lg overflow-x-auto", id: `${id}-div-1` }, /* @__PURE__ */ import_react16.default.createElement("div", { className: "w-full relative overflow-x-auto", id: `${id}-div-2` }, /* @__PURE__ */ import_react16.default.createElement("table", { className: "w-full caption-bottom text-sm overflow-x-auto bg-white dark:bg-[#18181b] table-fixed border-collapse", id: `${id}-table-1` }, /* @__PURE__ */ import_react16.default.createElement("thead", { className: "border-b border-[#e5e5e5] dark:border-[#303036] dark:bg-[#18181b]", id: `${id}-thead-1` }, /* @__PURE__ */ import_react16.default.createElement(
|
|
1632
|
+
"tr",
|
|
1633
|
+
{
|
|
1634
|
+
className: "transition-colors text-[#737373] hover:bg-muted/50 \r\n data-[state=selected]:bg-muted",
|
|
1635
|
+
id: `${id}-tr-1`
|
|
1636
|
+
},
|
|
1637
|
+
!isHideCheckbox && /* @__PURE__ */ import_react16.default.createElement("th", { className: "px-4 py-3 text-left w-[50px]", id: `${id}-th-1` }, /* @__PURE__ */ import_react16.default.createElement(
|
|
1638
|
+
CustomCheckbox,
|
|
1639
|
+
{
|
|
1640
|
+
checked: isAllChecked,
|
|
1641
|
+
onChange: () => {
|
|
1642
|
+
setIsAllChecked(!isAllChecked);
|
|
1643
|
+
},
|
|
1644
|
+
id: `${id}-custom-checkbox-1`
|
|
1645
|
+
}
|
|
1646
|
+
)),
|
|
1647
|
+
tableHeader.map((header, index) => {
|
|
1648
|
+
return /* @__PURE__ */ import_react16.default.createElement(
|
|
1649
|
+
"th",
|
|
1650
|
+
{
|
|
1651
|
+
className: `text-[#737373] px-4 py-3 text-sm dark:bg-[#18181b] font-medium ${index == tableHeader.length - 1 ? "text-right" : "text-left"}`,
|
|
1652
|
+
key: header + index,
|
|
1653
|
+
id: `${id}-th-2-${index}`
|
|
1654
|
+
},
|
|
1655
|
+
header
|
|
1656
|
+
);
|
|
1657
|
+
})
|
|
1658
|
+
)), /* @__PURE__ */ import_react16.default.createElement("tbody", { id: `${id}-tbody-1` }, children))));
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// src/inputs/Dropdown.jsx
|
|
1662
|
+
var import_react17 = __toESM(require("react"));
|
|
1663
|
+
var import_react_select = __toESM(require("react-select"));
|
|
1664
|
+
var isDarkMode = () => typeof document !== "undefined" && document.documentElement.classList.contains("dark");
|
|
1665
|
+
function buildStyles(isDark, error) {
|
|
1666
|
+
return {
|
|
1667
|
+
control: (base, state) => ({
|
|
1668
|
+
...base,
|
|
1669
|
+
minHeight: "40px !important",
|
|
1670
|
+
fontSize: 14,
|
|
1671
|
+
borderRadius: "6px",
|
|
1672
|
+
boxShadow: "none",
|
|
1673
|
+
backgroundColor: state.isDisabled ? "#f3f4f6" : error ? "#fef2f2" : isDark ? "#18181b" : "#ffffff",
|
|
1674
|
+
borderColor: state.isDisabled ? "#d1d5db" : error ? "#ef4444" : isDark ? "#303036" : "#e5e5e5",
|
|
1675
|
+
outline: state.isFocused ? "2px solid #000" : "none",
|
|
1676
|
+
outlineOffset: "2px",
|
|
1677
|
+
"&:hover": {
|
|
1678
|
+
borderColor: error ? "#ef4444" : "none"
|
|
1679
|
+
}
|
|
1680
|
+
}),
|
|
1681
|
+
menu: (base) => ({
|
|
1682
|
+
...base,
|
|
1683
|
+
backgroundColor: isDark ? "#18181b" : "#ffffff",
|
|
1684
|
+
zIndex: 9999
|
|
1685
|
+
}),
|
|
1686
|
+
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
|
|
1687
|
+
option: (base, state) => ({
|
|
1688
|
+
...base,
|
|
1689
|
+
fontSize: 14,
|
|
1690
|
+
cursor: "pointer",
|
|
1691
|
+
backgroundColor: state.isSelected ? "#0087FA" : state.isFocused ? isDark ? "#303036" : "#EBF5FF" : "transparent",
|
|
1692
|
+
color: state.isSelected ? "#ffffff" : isDark ? "#f3f4f6" : "#111827",
|
|
1693
|
+
"&:active": { backgroundColor: "#0087FA", color: "#ffffff" }
|
|
1694
|
+
}),
|
|
1695
|
+
singleValue: (base, state) => ({
|
|
1696
|
+
...base,
|
|
1697
|
+
fontSize: 14,
|
|
1698
|
+
fontWeight: 400,
|
|
1699
|
+
color: state.isDisabled ? "#6b7280" : isDark ? "#f3f4f6" : "#111827"
|
|
1700
|
+
}),
|
|
1701
|
+
multiValue: (base) => ({
|
|
1702
|
+
...base,
|
|
1703
|
+
backgroundColor: isDark ? "#303036" : "#EBF5FF"
|
|
1704
|
+
}),
|
|
1705
|
+
multiValueLabel: (base) => ({
|
|
1706
|
+
...base,
|
|
1707
|
+
fontSize: 12,
|
|
1708
|
+
color: isDark ? "#f3f4f6" : "#0087FA"
|
|
1709
|
+
}),
|
|
1710
|
+
multiValueRemove: (base) => ({
|
|
1711
|
+
...base,
|
|
1712
|
+
color: isDark ? "#9ca3af" : "#0087FA",
|
|
1713
|
+
"&:hover": { backgroundColor: "#0087FA", color: "#ffffff" }
|
|
1714
|
+
}),
|
|
1715
|
+
placeholder: (base) => ({
|
|
1716
|
+
...base,
|
|
1717
|
+
fontSize: 14,
|
|
1718
|
+
fontWeight: 400,
|
|
1719
|
+
color: "#6b7280"
|
|
1720
|
+
}),
|
|
1721
|
+
input: (base) => ({
|
|
1722
|
+
...base,
|
|
1723
|
+
fontSize: 14,
|
|
1724
|
+
fontWeight: 400,
|
|
1725
|
+
color: isDark ? "#f3f4f6" : "#111827"
|
|
1726
|
+
}),
|
|
1727
|
+
indicatorSeparator: () => ({ display: "none" }),
|
|
1728
|
+
dropdownIndicator: (base) => ({
|
|
1729
|
+
...base,
|
|
1730
|
+
padding: "0 6px",
|
|
1731
|
+
color: isDark ? "#9ca3af" : "#6b7280"
|
|
1732
|
+
}),
|
|
1733
|
+
clearIndicator: (base) => ({
|
|
1734
|
+
...base,
|
|
1735
|
+
padding: "0 4px",
|
|
1736
|
+
color: isDark ? "#9ca3af" : "#6b7280",
|
|
1737
|
+
cursor: "pointer",
|
|
1738
|
+
"&:hover": { color: "#0087FA" }
|
|
1739
|
+
}),
|
|
1740
|
+
valueContainer: (base) => ({ ...base, padding: "2px 16px" })
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
var Dropdown = import_react17.default.forwardRef(
|
|
1744
|
+
({
|
|
1745
|
+
id = "dropdown",
|
|
1746
|
+
options,
|
|
1747
|
+
placeholder = "Select...",
|
|
1748
|
+
isDisabled = false,
|
|
1749
|
+
isClearable = true,
|
|
1750
|
+
isLoading = false,
|
|
1751
|
+
error = false,
|
|
1752
|
+
label,
|
|
1753
|
+
heading,
|
|
1754
|
+
isRequired = false,
|
|
1755
|
+
name,
|
|
1756
|
+
menuPortalTarget,
|
|
1757
|
+
menuPosition = "absolute",
|
|
1758
|
+
className,
|
|
1759
|
+
style,
|
|
1760
|
+
isMulti = false,
|
|
1761
|
+
value,
|
|
1762
|
+
onChange
|
|
1763
|
+
}, ref) => {
|
|
1764
|
+
const reactId = (0, import_react17.useId)();
|
|
1765
|
+
const isDark = isDarkMode();
|
|
1766
|
+
const styles = (0, import_react17.useMemo)(() => buildStyles(isDark, !!error), [isDark, error]);
|
|
1767
|
+
const selectedValue = isMulti ? options.filter((o) => (value ?? []).includes(o.value)) : options.find((o) => o.value === value) ?? null;
|
|
1768
|
+
const handleChange = (selected) => {
|
|
1769
|
+
if (isMulti) {
|
|
1770
|
+
onChange((selected ?? []).map((o) => o.value));
|
|
1771
|
+
} else {
|
|
1772
|
+
onChange((selected == null ? void 0 : selected.value) ?? null);
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", { className: `flex flex-col gap-1 w-full ${className ?? ""}`, style, id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react17.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), label && /* @__PURE__ */ import_react17.default.createElement(
|
|
1776
|
+
"label",
|
|
1777
|
+
{
|
|
1778
|
+
htmlFor: reactId,
|
|
1779
|
+
className: `font-[500] text-sm ${heading ? "text-[#737373]" : "text-black"} dark:text-white`,
|
|
1780
|
+
id: `${id}-label-1`
|
|
1781
|
+
},
|
|
1782
|
+
label,
|
|
1783
|
+
isRequired && /* @__PURE__ */ import_react17.default.createElement("span", { className: "text-red-500 ml-0.5", id: `${id}-span-1` }, "*")
|
|
1784
|
+
), /* @__PURE__ */ import_react17.default.createElement(
|
|
1785
|
+
import_react_select.default,
|
|
1786
|
+
{
|
|
1787
|
+
ref,
|
|
1788
|
+
inputId: reactId,
|
|
1789
|
+
name,
|
|
1790
|
+
options,
|
|
1791
|
+
value: selectedValue,
|
|
1792
|
+
onChange: handleChange,
|
|
1793
|
+
placeholder,
|
|
1794
|
+
isDisabled,
|
|
1795
|
+
isClearable,
|
|
1796
|
+
isLoading,
|
|
1797
|
+
isMulti,
|
|
1798
|
+
styles,
|
|
1799
|
+
menuPortalTarget,
|
|
1800
|
+
menuPosition,
|
|
1801
|
+
classNamePrefix: "jett-dropdown"
|
|
1802
|
+
}
|
|
1803
|
+
));
|
|
1804
|
+
}
|
|
1805
|
+
);
|
|
1806
|
+
Dropdown.displayName = "Dropdown";
|
|
1807
|
+
|
|
1808
|
+
// src/Calendar/Calendar.tsx
|
|
1809
|
+
var import_react18 = __toESM(require("react"));
|
|
1810
|
+
var import_dates = require("@mantine/dates");
|
|
1811
|
+
var Calendar = (props) => {
|
|
1812
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1813
|
+
const {
|
|
1814
|
+
minDate,
|
|
1815
|
+
maxDate,
|
|
1816
|
+
excludeDate,
|
|
1817
|
+
firstDayOfWeek = 1,
|
|
1818
|
+
locale,
|
|
1819
|
+
size,
|
|
1820
|
+
className,
|
|
1821
|
+
error
|
|
1822
|
+
} = props;
|
|
1823
|
+
const isRange = props.mode === "range";
|
|
1824
|
+
const isDateTime = props.mode === "datetime";
|
|
1825
|
+
const datesProviderSettings = {
|
|
1826
|
+
firstDayOfWeek,
|
|
1827
|
+
consistentWeeks: true
|
|
1828
|
+
};
|
|
1829
|
+
if (locale) {
|
|
1830
|
+
datesProviderSettings.locale = locale;
|
|
1831
|
+
}
|
|
1832
|
+
const anchorDate = isRange ? ((_a = props.value) == null ? void 0 : _a[0]) ?? ((_b = props.value) == null ? void 0 : _b[1]) ?? ((_c = props.defaultValue) == null ? void 0 : _c[0]) ?? ((_d = props.defaultValue) == null ? void 0 : _d[1]) ?? void 0 : !isDateTime ? props.value ?? props.defaultValue ?? void 0 : void 0;
|
|
1833
|
+
const [displayDate, setDisplayDate] = (0, import_react18.useState)(anchorDate ?? void 0);
|
|
1834
|
+
const anchorTime = isRange ? ((_f = (_e = props.value) == null ? void 0 : _e[0]) == null ? void 0 : _f.getTime()) ?? ((_h = (_g = props.value) == null ? void 0 : _g[1]) == null ? void 0 : _h.getTime()) : !isDateTime ? (_i = props.value) == null ? void 0 : _i.getTime() : void 0;
|
|
1835
|
+
(0, import_react18.useEffect)(() => {
|
|
1836
|
+
if (anchorTime !== void 0) {
|
|
1837
|
+
setDisplayDate(new Date(anchorTime));
|
|
1838
|
+
}
|
|
1839
|
+
}, [anchorTime]);
|
|
1840
|
+
const weekendColorStyle = {
|
|
1841
|
+
"--mantine-color-red-6": "var(--mantine-color-text)"
|
|
1842
|
+
};
|
|
1843
|
+
if (isRange) {
|
|
1844
|
+
const datePickerProps2 = {
|
|
1845
|
+
type: "range",
|
|
1846
|
+
value: props.value,
|
|
1847
|
+
defaultValue: props.defaultValue,
|
|
1848
|
+
onChange: props.onChange,
|
|
1849
|
+
minDate,
|
|
1850
|
+
maxDate,
|
|
1851
|
+
excludeDate,
|
|
1852
|
+
size,
|
|
1853
|
+
className,
|
|
1854
|
+
date: displayDate,
|
|
1855
|
+
onDateChange: setDisplayDate,
|
|
1856
|
+
style: weekendColorStyle
|
|
1857
|
+
};
|
|
1858
|
+
return /* @__PURE__ */ import_react18.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react18.default.createElement(import_dates.DatePicker, { ...datePickerProps2 }));
|
|
1859
|
+
}
|
|
1860
|
+
if (isDateTime) {
|
|
1861
|
+
const dateTimePickerProps = {
|
|
1862
|
+
value: props.value,
|
|
1863
|
+
defaultValue: props.defaultValue,
|
|
1864
|
+
onChange: props.onChange,
|
|
1865
|
+
minDate,
|
|
1866
|
+
maxDate,
|
|
1867
|
+
excludeDate,
|
|
1868
|
+
size,
|
|
1869
|
+
className,
|
|
1870
|
+
error,
|
|
1871
|
+
style: weekendColorStyle
|
|
1872
|
+
};
|
|
1873
|
+
return /* @__PURE__ */ import_react18.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react18.default.createElement(import_dates.DateTimePicker, { ...dateTimePickerProps }));
|
|
1874
|
+
}
|
|
1875
|
+
const datePickerProps = {
|
|
1876
|
+
value: props.value,
|
|
1877
|
+
defaultValue: props.defaultValue,
|
|
1878
|
+
onChange: props.onChange,
|
|
1879
|
+
minDate,
|
|
1880
|
+
maxDate,
|
|
1881
|
+
excludeDate,
|
|
1882
|
+
size,
|
|
1883
|
+
className,
|
|
1884
|
+
date: displayDate,
|
|
1885
|
+
onDateChange: setDisplayDate,
|
|
1886
|
+
style: weekendColorStyle
|
|
1887
|
+
};
|
|
1888
|
+
return /* @__PURE__ */ import_react18.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react18.default.createElement(import_dates.DatePicker, { ...datePickerProps }));
|
|
1889
|
+
};
|
|
1890
|
+
|
|
1891
|
+
// src/Pagination/Pagination.jsx
|
|
1892
|
+
var import_react19 = __toESM(require("react"));
|
|
1893
|
+
var import_lucide_react9 = require("lucide-react");
|
|
1894
|
+
var Pagination = ({
|
|
1895
|
+
id = "pagination",
|
|
1896
|
+
data = [],
|
|
1897
|
+
component: Component,
|
|
1898
|
+
itemsPerPage = 6,
|
|
1899
|
+
itemsPerPageOptions = [5, 10, 20, 50, 100],
|
|
1900
|
+
// Controlled props (optional)
|
|
1901
|
+
currentPage: controlledCurrentPage,
|
|
1902
|
+
onPageChange: controlledOnPageChange,
|
|
1903
|
+
onItemsPerPageChange: controlledOnItemsPerPageChange,
|
|
1904
|
+
// Legacy props for backward compatibility
|
|
1905
|
+
totalPages,
|
|
1906
|
+
totalItems: legacyTotalItems,
|
|
1907
|
+
onPageChange: legacyOnPageChange,
|
|
1908
|
+
onItemsPerPageChange: legacyOnItemsPerPageChange,
|
|
1909
|
+
tableHeader,
|
|
1910
|
+
isHideCheckbox,
|
|
1911
|
+
callback,
|
|
1912
|
+
isTable = false,
|
|
1913
|
+
// Component props - any additional props to pass to the component
|
|
1914
|
+
componentProps = {},
|
|
1915
|
+
...restProps
|
|
1916
|
+
}) => {
|
|
1917
|
+
const [internalCurrentPage, setInternalCurrentPage] = (0, import_react19.useState)(1);
|
|
1918
|
+
const [internalItemsPerPage, setInternalItemsPerPage] = (0, import_react19.useState)(itemsPerPage);
|
|
1919
|
+
const isControlled = controlledCurrentPage !== void 0;
|
|
1920
|
+
const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
|
|
1921
|
+
const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
|
|
1922
|
+
const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
|
|
1923
|
+
const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
|
|
1924
|
+
const calculatedTotalPages = (0, import_react19.useMemo)(() => {
|
|
1925
|
+
if (totalItems > 0 && activeItemsPerPage > 0) {
|
|
1926
|
+
return Math.ceil(totalItems / activeItemsPerPage);
|
|
1927
|
+
}
|
|
1928
|
+
return 1;
|
|
1929
|
+
}, [totalItems, activeItemsPerPage]);
|
|
1930
|
+
const paginatedData = (0, import_react19.useMemo)(() => {
|
|
1931
|
+
if (!data || data.length === 0) return [];
|
|
1932
|
+
const startIndex = (currentPage - 1) * activeItemsPerPage;
|
|
1933
|
+
const endIndex = startIndex + activeItemsPerPage;
|
|
1934
|
+
return data.slice(startIndex, endIndex);
|
|
1935
|
+
}, [data, currentPage, activeItemsPerPage]);
|
|
1936
|
+
(0, import_react19.useEffect)(() => {
|
|
1937
|
+
if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
|
|
1938
|
+
setInternalCurrentPage(1);
|
|
1939
|
+
}
|
|
1940
|
+
}, [calculatedTotalPages, isControlled, currentPage]);
|
|
1941
|
+
const getPageNumbers = () => {
|
|
1942
|
+
const pages = [];
|
|
1943
|
+
const maxVisible = 5;
|
|
1944
|
+
let startPage = Math.max(1, currentPage - Math.floor(maxVisible / 2));
|
|
1945
|
+
let endPage = Math.min(calculatedTotalPages, startPage + maxVisible - 1);
|
|
1946
|
+
if (endPage - startPage < maxVisible - 1) {
|
|
1947
|
+
startPage = Math.max(1, endPage - maxVisible + 1);
|
|
1948
|
+
}
|
|
1949
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
1950
|
+
pages.push(i);
|
|
1951
|
+
}
|
|
1952
|
+
return pages;
|
|
1953
|
+
};
|
|
1954
|
+
const handlePageChange = (page) => {
|
|
1955
|
+
if (page >= 1 && page <= calculatedTotalPages) {
|
|
1956
|
+
if (isControlled && controlledOnPageChange) {
|
|
1957
|
+
controlledOnPageChange(page);
|
|
1958
|
+
} else if (legacyOnPageChange) {
|
|
1959
|
+
legacyOnPageChange(page);
|
|
1960
|
+
} else {
|
|
1961
|
+
setInternalCurrentPage(page);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
const startItem = totalItems !== void 0 ? (currentPage - 1) * activeItemsPerPage + 1 : null;
|
|
1966
|
+
const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
|
|
1967
|
+
const renderContent = () => {
|
|
1968
|
+
if (Component) {
|
|
1969
|
+
if (import_react19.default.isValidElement(Component)) {
|
|
1970
|
+
const ComponentType = Component.type;
|
|
1971
|
+
const elementProps = Component.props;
|
|
1972
|
+
if (isTable) {
|
|
1973
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
1974
|
+
CustomTable,
|
|
1975
|
+
{
|
|
1976
|
+
tableHeader,
|
|
1977
|
+
isHideCheckbox,
|
|
1978
|
+
id: `${id}-custom-table-1`
|
|
1979
|
+
},
|
|
1980
|
+
data.map((item, index) => {
|
|
1981
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
1982
|
+
ComponentType,
|
|
1983
|
+
{
|
|
1984
|
+
key: item.id || item._id || index,
|
|
1985
|
+
data: item,
|
|
1986
|
+
...elementProps,
|
|
1987
|
+
...componentProps,
|
|
1988
|
+
...restProps,
|
|
1989
|
+
id: `${id}-component-type-1-${index}`
|
|
1990
|
+
}
|
|
1991
|
+
);
|
|
1992
|
+
})
|
|
1993
|
+
);
|
|
1994
|
+
} else {
|
|
1995
|
+
if (isTable) {
|
|
1996
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
1997
|
+
CustomTable,
|
|
1998
|
+
{
|
|
1999
|
+
tableHeader,
|
|
2000
|
+
isHideCheckbox,
|
|
2001
|
+
id: `${id}-custom-table-2`
|
|
2002
|
+
},
|
|
2003
|
+
paginatedData.map((item, index) => {
|
|
2004
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
2005
|
+
ComponentType,
|
|
2006
|
+
{
|
|
2007
|
+
key: item.id || item._id || index,
|
|
2008
|
+
data: item,
|
|
2009
|
+
...elementProps,
|
|
2010
|
+
...componentProps,
|
|
2011
|
+
...restProps,
|
|
2012
|
+
id: `${id}-component-type-2-${index}`
|
|
2013
|
+
}
|
|
2014
|
+
);
|
|
2015
|
+
})
|
|
2016
|
+
);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
} else {
|
|
2020
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
2021
|
+
CustomTable,
|
|
2022
|
+
{
|
|
2023
|
+
tableHeader,
|
|
2024
|
+
isHideCheckbox,
|
|
2025
|
+
id: `${id}-custom-table-3`
|
|
2026
|
+
},
|
|
2027
|
+
paginatedData.map((item, index) => {
|
|
2028
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
2029
|
+
Component,
|
|
2030
|
+
{
|
|
2031
|
+
key: item.id || item._id || index,
|
|
2032
|
+
data: item,
|
|
2033
|
+
...componentProps,
|
|
2034
|
+
...restProps,
|
|
2035
|
+
id: `${id}-component-1-${index}`
|
|
2036
|
+
}
|
|
2037
|
+
);
|
|
2038
|
+
})
|
|
2039
|
+
);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
return null;
|
|
2043
|
+
};
|
|
2044
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, renderContent()), /* @__PURE__ */ import_react19.default.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ import_react19.default.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ import_react19.default.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ import_react19.default.createElement(
|
|
2045
|
+
"button",
|
|
2046
|
+
{
|
|
2047
|
+
onClick: () => handlePageChange(1),
|
|
2048
|
+
disabled: currentPage === 1,
|
|
2049
|
+
className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
|
|
2050
|
+
title: "First page",
|
|
2051
|
+
id: `${id}-button-1`
|
|
2052
|
+
},
|
|
2053
|
+
/* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronsLeft, { size: 16 })
|
|
2054
|
+
), /* @__PURE__ */ import_react19.default.createElement(
|
|
2055
|
+
"button",
|
|
2056
|
+
{
|
|
2057
|
+
onClick: () => handlePageChange(currentPage - 1),
|
|
2058
|
+
disabled: currentPage === 1,
|
|
2059
|
+
className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === 1 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
|
|
2060
|
+
title: "Previous page",
|
|
2061
|
+
id: `${id}-button-2`
|
|
2062
|
+
},
|
|
2063
|
+
/* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronLeft, { size: 16 })
|
|
2064
|
+
), getPageNumbers().map((pageNum) => /* @__PURE__ */ import_react19.default.createElement(
|
|
2065
|
+
"button",
|
|
2066
|
+
{
|
|
2067
|
+
key: pageNum,
|
|
2068
|
+
onClick: () => handlePageChange(pageNum),
|
|
2069
|
+
className: `flex items-center justify-center min-w-9 h-9 px-3 cursor-pointer rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === pageNum ? "bg-primary text-white border-primary dark:bg-primary" : "bg-white text-black hover:bg-gray-50 dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
|
|
2070
|
+
id: `${id}-button-3`
|
|
2071
|
+
},
|
|
2072
|
+
pageNum
|
|
2073
|
+
)), /* @__PURE__ */ import_react19.default.createElement(
|
|
2074
|
+
"button",
|
|
2075
|
+
{
|
|
2076
|
+
onClick: () => handlePageChange(currentPage + 1),
|
|
2077
|
+
disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
|
|
2078
|
+
className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
|
|
2079
|
+
title: "Next page",
|
|
2080
|
+
id: `${id}-button-4`
|
|
2081
|
+
},
|
|
2082
|
+
/* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronRight, { size: 16 })
|
|
2083
|
+
), /* @__PURE__ */ import_react19.default.createElement(
|
|
2084
|
+
"button",
|
|
2085
|
+
{
|
|
2086
|
+
onClick: () => handlePageChange(calculatedTotalPages),
|
|
2087
|
+
disabled: currentPage === calculatedTotalPages || calculatedTotalPages === 0,
|
|
2088
|
+
className: `flex items-center justify-center w-9 h-9 rounded-md border border-[#e5e5e5] dark:border-[#303036] text-sm transition-colors ${currentPage === calculatedTotalPages || calculatedTotalPages === 0 ? "bg-gray-100 text-gray-400 cursor-not-allowed dark:bg-[#27272a] dark:text-gray-600" : "bg-white text-black hover:bg-gray-50 cursor-pointer dark:bg-[#18181b] dark:text-white dark:hover:bg-[#27272a]"}`,
|
|
2089
|
+
title: "Last page",
|
|
2090
|
+
id: `${id}-button-5`
|
|
2091
|
+
},
|
|
2092
|
+
/* @__PURE__ */ import_react19.default.createElement(import_lucide_react9.ChevronsRight, { size: 16 })
|
|
2093
|
+
))));
|
|
2094
|
+
};
|
|
2095
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2096
|
+
0 && (module.exports = {
|
|
2097
|
+
AppSideBar,
|
|
2098
|
+
Calendar,
|
|
2099
|
+
Chip,
|
|
2100
|
+
CustomAutocomplete,
|
|
2101
|
+
CustomButton,
|
|
2102
|
+
CustomCheckbox,
|
|
2103
|
+
CustomInput,
|
|
2104
|
+
CustomSearch,
|
|
2105
|
+
CustomSelect,
|
|
2106
|
+
CustomSwitch,
|
|
2107
|
+
CustomTable,
|
|
2108
|
+
CustomTextarea,
|
|
2109
|
+
CustomUpload,
|
|
2110
|
+
Dropdown,
|
|
2111
|
+
Pagination,
|
|
2112
|
+
ProgressBar,
|
|
2113
|
+
RightSheet
|
|
2114
|
+
});
|