amp-workflow-ui 0.1.5 → 0.1.6

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.mjs CHANGED
@@ -2,15 +2,14 @@ import React7, { createContext, useState, useEffect, useCallback, useContext, us
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import Button7 from '@mui/material/Button';
4
4
  import Dialog from '@mui/material/Dialog';
5
- import { useTheme } from '@mui/material/styles';
5
+ import { styled, useTheme } from '@mui/material/styles';
6
6
  import useMediaQuery from '@mui/material/useMediaQuery';
7
7
  import DialogActions5 from '@mui/material/DialogActions';
8
8
  import DialogContent from '@mui/material/DialogContent';
9
- import { styled, Chip, IconButton, useTheme as useTheme$1, Tooltip, Card, CardContent, Typography, Divider, CircularProgress, Box as Box$1, TextField, InputAdornment, Button, Menu, MenuItem, DialogTitle, Grid, DialogActions, FormControl, InputLabel, Select } from '@mui/material';
9
+ import { Card, styled as styled$1, Chip, IconButton, useTheme as useTheme$1, Tooltip, CardContent, Typography, Divider, CircularProgress, Box as Box$1, TextField, InputAdornment, Button, Menu, MenuItem, DialogTitle, Grid, DialogActions, Snackbar, Alert, FormControl, InputLabel, Select } from '@mui/material';
10
10
  import HighlightOffIcon from '@mui/icons-material/HighlightOff';
11
11
  import { Box } from '@mui/system';
12
12
  import moment from 'moment';
13
- import toast from 'react-hot-toast';
14
13
 
15
14
  // src/context.tsx
16
15
  var WorkflowContext = createContext(null);
@@ -32,6 +31,7 @@ var ActionMenu = ({
32
31
  onApprove,
33
32
  onReject,
34
33
  onHold,
34
+ level,
35
35
  statusList
36
36
  }) => {
37
37
  const [anchorEl, setAnchorEl] = useState(null);
@@ -42,31 +42,40 @@ var ActionMenu = ({
42
42
  const handleClose = () => setAnchorEl(null);
43
43
  return /* @__PURE__ */ jsxs(Fragment, { children: [
44
44
  /* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: handleActionClick, children: "Apply Action" }),
45
- /* @__PURE__ */ jsxs(Menu, { anchorEl, open, onClose: handleClose, MenuListProps: { "aria-labelledby": "basic-button" }, children: [
46
- /* @__PURE__ */ jsx(
47
- MenuItem,
48
- {
49
- onClick: () => {
50
- onSendBack();
51
- handleClose();
52
- },
53
- children: "Send Back"
54
- }
55
- ),
56
- statusList.map((list) => /* @__PURE__ */ jsx(
57
- MenuItem,
58
- {
59
- onClick: () => {
60
- if (list.status === 1) onApprove();
61
- else if (list.status === 2) onHold();
62
- else if (list.status === 3) onReject();
63
- handleClose();
64
- },
65
- children: list.name
66
- },
67
- list.id
68
- ))
69
- ] })
45
+ /* @__PURE__ */ jsxs(
46
+ Menu,
47
+ {
48
+ anchorEl,
49
+ open,
50
+ onClose: handleClose,
51
+ MenuListProps: { "aria-labelledby": "basic-button" },
52
+ children: [
53
+ !level && /* @__PURE__ */ jsx(
54
+ MenuItem,
55
+ {
56
+ onClick: () => {
57
+ onSendBack();
58
+ handleClose();
59
+ },
60
+ children: "Send Back"
61
+ }
62
+ ),
63
+ statusList.map((list) => /* @__PURE__ */ jsx(
64
+ MenuItem,
65
+ {
66
+ onClick: () => {
67
+ if (list.status === 1) onApprove();
68
+ else if (list.status === 2) onHold();
69
+ else if (list.status === 3) onReject();
70
+ handleClose();
71
+ },
72
+ children: list.name
73
+ },
74
+ list.id
75
+ ))
76
+ ]
77
+ }
78
+ )
70
79
  ] });
71
80
  };
72
81
  var Statusselector_default = ActionMenu;
@@ -84,6 +93,12 @@ function SendBackDialog({
84
93
  const [loading, setLoading] = useState(false);
85
94
  const [fileLoading, setFileLoading] = useState(false);
86
95
  const fileInputRef = useRef(null);
96
+ const [snackbar, setSnackbar] = useState({
97
+ open: false,
98
+ message: "",
99
+ severity: "success"
100
+ });
101
+ const handleCloseSnackbar = () => setSnackbar((prev) => ({ ...prev, open: false }));
87
102
  const handleAttachment = () => {
88
103
  var _a;
89
104
  return (_a = fileInputRef.current) == null ? void 0 : _a.click();
@@ -96,12 +111,22 @@ function SendBackDialog({
96
111
  const response = await api.post({
97
112
  url: "/workflow/upload-document",
98
113
  data: formData,
114
+ serviceURL: "api",
99
115
  headers: { "Content-Type": "multipart/form-data" }
100
116
  });
101
117
  setFileName(response.data.file);
102
118
  setSelectedFile(response.data.file);
119
+ setSnackbar({
120
+ open: true,
121
+ message: "File uploaded successfully!",
122
+ severity: "success"
123
+ });
103
124
  } catch (error2) {
104
- toast.error("File upload failed");
125
+ setSnackbar({
126
+ open: true,
127
+ message: "File upload failed.",
128
+ severity: "error"
129
+ });
105
130
  } finally {
106
131
  setFileLoading(false);
107
132
  }
@@ -127,7 +152,7 @@ function SendBackDialog({
127
152
  return isValid;
128
153
  };
129
154
  const onSubmit = async () => {
130
- var _a, _b, _c;
155
+ var _a, _b, _c, _d;
131
156
  if (!validateFields()) return;
132
157
  setLoading(true);
133
158
  try {
@@ -140,127 +165,186 @@ function SendBackDialog({
140
165
  },
141
166
  serviceURL: "api"
142
167
  });
143
- if ((res == null ? void 0 : res.status) === 200) toast.success("Successfully sent back!");
144
- if ((_b = res == null ? void 0 : res.error) == null ? void 0 : _b.message) {
145
- toast.error((_c = res == null ? void 0 : res.error) == null ? void 0 : _c.message, { duration: 2e3 });
168
+ if ((res == null ? void 0 : res.status) === 200) {
169
+ setSnackbar({
170
+ open: true,
171
+ message: "Workflow sent back successfully!",
172
+ severity: "success"
173
+ });
174
+ } else {
175
+ setSnackbar({
176
+ open: true,
177
+ message: ((_b = res == null ? void 0 : res.error) == null ? void 0 : _b.message) || "Something went wrong. Try again.",
178
+ severity: "error"
179
+ });
146
180
  }
147
- closeModal && closeModal();
148
- } catch {
149
- toast.error("Opps! something went wrong.");
181
+ } catch (e) {
182
+ setSnackbar({
183
+ open: true,
184
+ message: ((_d = (_c = e == null ? void 0 : e.response) == null ? void 0 : _c.data) == null ? void 0 : _d.message) || "Oops! Something went wrong.",
185
+ severity: "error"
186
+ });
150
187
  } finally {
188
+ setComment("");
189
+ setSelectedFile(null);
190
+ setFileName("");
151
191
  setLoading(false);
192
+ closeModal && closeModal();
152
193
  }
153
194
  };
154
- return /* @__PURE__ */ jsxs(
155
- Dialog,
156
- {
157
- open: openModal,
158
- onClose: closeModal,
159
- "aria-labelledby": "responsive-dialog-title",
160
- sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } },
161
- children: [
162
- /* @__PURE__ */ jsxs(
163
- Box$1,
164
- {
165
- sx: {
166
- display: "flex",
167
- justifyContent: "space-between",
168
- alignItems: "center"
169
- },
170
- children: [
171
- /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
172
- /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
173
- ]
174
- }
175
- ),
176
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 5, children: [
177
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
178
- TextField,
195
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
196
+ /* @__PURE__ */ jsxs(
197
+ Dialog,
198
+ {
199
+ open: openModal,
200
+ onClose: closeModal,
201
+ "aria-labelledby": "responsive-dialog-title",
202
+ sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } },
203
+ children: [
204
+ /* @__PURE__ */ jsxs(
205
+ Box$1,
179
206
  {
180
- fullWidth: true,
181
- label: "Comment",
182
- value: comment,
183
- placeholder: "Comment Here",
184
- onChange: (e) => setComment(e.target.value),
185
- required: true,
186
- error: !!error.comment,
187
- helperText: error.comment
207
+ sx: {
208
+ display: "flex",
209
+ justifyContent: "space-between",
210
+ alignItems: "center"
211
+ },
212
+ children: [
213
+ /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
214
+ /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
215
+ ]
188
216
  }
189
- ) }),
190
- /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
191
- /* @__PURE__ */ jsx(
217
+ ),
218
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 5, children: [
219
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
192
220
  TextField,
193
221
  {
194
- type: "text",
195
222
  fullWidth: true,
196
- label: "Attachment",
197
- placeholder: "Attachment",
198
- InputProps: {
199
- endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx("span", { className: "icon-export-1" }) })
200
- },
201
- onClick: handleAttachment,
202
- value: fileName,
203
- error: !!error.file,
204
- helperText: error.file
223
+ label: "Comment",
224
+ value: comment,
225
+ placeholder: "Comment Here",
226
+ onChange: (e) => setComment(e.target.value),
227
+ required: true,
228
+ error: !!error.comment,
229
+ helperText: error.comment
205
230
  }
206
- ),
207
- /* @__PURE__ */ jsx(
208
- "input",
209
- {
210
- type: "file",
211
- ref: fileInputRef,
212
- style: { display: "none" },
213
- onChange: handleFileChange
214
- }
215
- )
216
- ] })
217
- ] }) }) }),
218
- /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(
219
- Box$1,
220
- {
221
- sx: {
222
- display: "flex",
223
- justifyContent: "flex-end",
224
- alignItems: "center"
225
- },
226
- children: [
231
+ ) }),
232
+ /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
227
233
  /* @__PURE__ */ jsx(
228
- Button,
234
+ TextField,
229
235
  {
230
- onClick: closeModal,
231
- size: "large",
232
- variant: "outlined",
233
- color: "primary",
234
- sx: { mr: 2 },
235
- children: "Close"
236
+ type: "text",
237
+ fullWidth: true,
238
+ label: "Attachment",
239
+ placeholder: "Attachment",
240
+ InputProps: {
241
+ endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: fileLoading ? /* @__PURE__ */ jsx(CircularProgress, { size: 20, color: "inherit" }) : /* @__PURE__ */ jsx(
242
+ "span",
243
+ {
244
+ className: "icon-export-1",
245
+ style: { cursor: "pointer" },
246
+ onClick: handleAttachment
247
+ }
248
+ ) })
249
+ },
250
+ onClick: handleAttachment,
251
+ value: fileName,
252
+ error: !!error.file,
253
+ helperText: error.file
236
254
  }
237
255
  ),
238
256
  /* @__PURE__ */ jsx(
239
- Button,
257
+ "input",
240
258
  {
241
- onClick: onSubmit,
242
- size: "large",
243
- variant: "contained",
244
- color: "primary",
245
- disabled: loading || fileLoading,
246
- children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit"
259
+ type: "file",
260
+ ref: fileInputRef,
261
+ style: { display: "none" },
262
+ onChange: handleFileChange
247
263
  }
248
264
  )
249
- ]
265
+ ] })
266
+ ] }) }) }),
267
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(
268
+ Box$1,
269
+ {
270
+ sx: {
271
+ display: "flex",
272
+ justifyContent: "flex-end",
273
+ alignItems: "center"
274
+ },
275
+ children: [
276
+ /* @__PURE__ */ jsx(
277
+ Button,
278
+ {
279
+ onClick: closeModal,
280
+ size: "large",
281
+ variant: "outlined",
282
+ color: "primary",
283
+ sx: { mr: 2 },
284
+ children: "Close"
285
+ }
286
+ ),
287
+ /* @__PURE__ */ jsx(
288
+ Button,
289
+ {
290
+ onClick: onSubmit,
291
+ size: "large",
292
+ variant: "contained",
293
+ color: "primary",
294
+ disabled: loading || fileLoading,
295
+ children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit"
296
+ }
297
+ )
298
+ ]
299
+ }
300
+ ) })
301
+ ]
302
+ }
303
+ ),
304
+ /* @__PURE__ */ jsx(
305
+ Snackbar,
306
+ {
307
+ open: snackbar.open,
308
+ autoHideDuration: 3e3,
309
+ onClose: handleCloseSnackbar,
310
+ anchorOrigin: { vertical: "top", horizontal: "right" },
311
+ children: /* @__PURE__ */ jsx(
312
+ Alert,
313
+ {
314
+ onClose: handleCloseSnackbar,
315
+ severity: snackbar.severity,
316
+ sx: {
317
+ width: "100%",
318
+ color: snackbar.severity === "error" ? "#fff" : "inherit",
319
+ bgcolor: snackbar.severity === "error" ? "#d32f2f" : void 0
320
+ },
321
+ children: snackbar.message
250
322
  }
251
- ) })
252
- ]
253
- }
254
- );
323
+ )
324
+ }
325
+ )
326
+ ] });
255
327
  }
256
328
  var SendBackDialog_default = SendBackDialog;
257
- function ApproveDialog({ openModal, closeModal, header, workflowLogId, statusId }) {
329
+ function ApproveDialog({
330
+ openModal,
331
+ closeModal,
332
+ header,
333
+ workflowLogId,
334
+ statusId
335
+ }) {
258
336
  const { userInfo, api } = useWorkflowContext();
259
337
  const theme = useTheme();
260
338
  useMediaQuery(theme.breakpoints.down("lg"));
261
339
  const [comment, setComment] = useState("");
262
340
  const [error, setError] = useState({});
263
341
  const [loading, setLoading] = useState(false);
342
+ const [snackbar, setSnackbar] = useState({
343
+ open: false,
344
+ message: "",
345
+ severity: "success"
346
+ });
347
+ const handleCloseSnackbar = () => setSnackbar((prev) => ({ ...prev, open: false }));
264
348
  const validateFields = () => {
265
349
  let isValid = true;
266
350
  const newError = {};
@@ -272,60 +356,185 @@ function ApproveDialog({ openModal, closeModal, header, workflowLogId, statusId
272
356
  return isValid;
273
357
  };
274
358
  const onSubmit = async () => {
275
- var _a;
359
+ var _a, _b, _c;
276
360
  if (!validateFields()) return;
277
361
  setLoading(true);
278
362
  try {
279
- await api.post(`/workflow/update-status/${workflowLogId}/${statusId}`, {
280
- comment,
281
- created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
363
+ await api.post({
364
+ url: `/workflow/update-status/${workflowLogId}/${statusId}`,
365
+ data: {
366
+ comment,
367
+ created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
368
+ },
369
+ serviceURL: "api"
370
+ });
371
+ setSnackbar({
372
+ open: true,
373
+ message: "Approved successfully!",
374
+ severity: "success"
375
+ });
376
+ } catch (e) {
377
+ setSnackbar({
378
+ open: true,
379
+ message: ((_c = (_b = e == null ? void 0 : e.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || "Something unexpected occurred!",
380
+ severity: "error"
282
381
  });
283
- toast.success("approved successfully!!!");
284
- closeModal && closeModal();
285
- } catch {
286
- toast.error("something unexpected occured!!!");
287
382
  } finally {
383
+ setComment("");
288
384
  setLoading(false);
385
+ closeModal && closeModal();
289
386
  }
290
387
  };
291
- return /* @__PURE__ */ jsxs(Dialog, { open: openModal, onClose: closeModal, "aria-labelledby": "responsive-dialog-title", sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } }, children: [
292
- /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
293
- /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
294
- /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
295
- ] }),
296
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(TextField, { fullWidth: true, label: "Comment", value: comment, placeholder: "Comment Here", onChange: (e) => setComment(e.target.value), required: true, error: !!error.comment, helperText: error.comment }) }) }) }) }),
297
- /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: [
298
- /* @__PURE__ */ jsx(Button, { onClick: closeModal, size: "large", variant: "outlined", color: "primary", sx: { mr: 2 }, children: "Close" }),
299
- /* @__PURE__ */ jsx(Button, { onClick: onSubmit, size: "large", variant: "contained", color: "primary", disabled: loading, children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit" })
300
- ] }) })
388
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
389
+ /* @__PURE__ */ jsxs(
390
+ Dialog,
391
+ {
392
+ open: openModal,
393
+ onClose: closeModal,
394
+ "aria-labelledby": "responsive-dialog-title",
395
+ sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } },
396
+ children: [
397
+ /* @__PURE__ */ jsxs(
398
+ Box$1,
399
+ {
400
+ sx: {
401
+ display: "flex",
402
+ justifyContent: "space-between",
403
+ alignItems: "center"
404
+ },
405
+ children: [
406
+ /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
407
+ /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
408
+ ]
409
+ }
410
+ ),
411
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
412
+ TextField,
413
+ {
414
+ fullWidth: true,
415
+ label: "Comment",
416
+ value: comment,
417
+ placeholder: "Comment Here",
418
+ onChange: (e) => setComment(e.target.value),
419
+ required: true,
420
+ error: !!error.comment,
421
+ helperText: error.comment
422
+ }
423
+ ) }) }) }) }),
424
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(
425
+ Box$1,
426
+ {
427
+ sx: {
428
+ display: "flex",
429
+ justifyContent: "flex-end",
430
+ alignItems: "center"
431
+ },
432
+ children: [
433
+ /* @__PURE__ */ jsx(
434
+ Button,
435
+ {
436
+ onClick: closeModal,
437
+ size: "large",
438
+ variant: "outlined",
439
+ color: "primary",
440
+ sx: { mr: 2 },
441
+ children: "Close"
442
+ }
443
+ ),
444
+ /* @__PURE__ */ jsx(
445
+ Button,
446
+ {
447
+ onClick: onSubmit,
448
+ size: "large",
449
+ variant: "contained",
450
+ color: "primary",
451
+ disabled: loading,
452
+ children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit"
453
+ }
454
+ )
455
+ ]
456
+ }
457
+ ) })
458
+ ]
459
+ }
460
+ ),
461
+ /* @__PURE__ */ jsx(
462
+ Snackbar,
463
+ {
464
+ open: snackbar.open,
465
+ autoHideDuration: 3e3,
466
+ onClose: handleCloseSnackbar,
467
+ anchorOrigin: { vertical: "top", horizontal: "right" },
468
+ children: /* @__PURE__ */ jsx(
469
+ Alert,
470
+ {
471
+ onClose: handleCloseSnackbar,
472
+ severity: snackbar.severity,
473
+ sx: {
474
+ width: "100%",
475
+ color: snackbar.severity === "error" ? "#fff" : "inherit",
476
+ bgcolor: snackbar.severity === "error" ? "#d32f2f" : void 0
477
+ },
478
+ children: snackbar.message
479
+ }
480
+ )
481
+ }
482
+ )
301
483
  ] });
302
484
  }
303
485
  var ApproveDialog_default = ApproveDialog;
304
- function RejectDialog({ openModal, closeModal, header, workflowLogId, statusId, rejection_reason_master }) {
486
+ function RejectDialog({
487
+ openModal,
488
+ closeModal,
489
+ header,
490
+ workflowLogId,
491
+ statusId,
492
+ rejection_reason_master
493
+ }) {
305
494
  const { userInfo, api } = useWorkflowContext();
306
495
  const theme = useTheme();
307
496
  useMediaQuery(theme.breakpoints.down("lg"));
308
497
  const DownArrow = () => {
309
498
  var _a;
310
- return /* @__PURE__ */ jsx("span", { style: { color: ((_a = theme.palette.customColors) == null ? void 0 : _a.mainText) || "#333" }, className: "icon-arrow-down-1" });
499
+ return /* @__PURE__ */ jsx(
500
+ "span",
501
+ {
502
+ style: { color: ((_a = theme.palette.customColors) == null ? void 0 : _a.mainText) || "#333" },
503
+ className: "icon-arrow-down-1"
504
+ }
505
+ );
311
506
  };
312
507
  const [rejectReasons, setRejectReasons] = useState("");
313
508
  const [comment, setComment] = useState("");
314
509
  const [error, setError] = useState({ reason: "", comment: "" });
315
510
  const [statusApplicableList, setStatusApplicableList] = useState([]);
316
511
  const [loading, setLoading] = useState(false);
512
+ const [snackbar, setSnackbar] = useState({
513
+ open: false,
514
+ message: "",
515
+ severity: "success"
516
+ });
517
+ const handleCloseSnackbar = () => setSnackbar((prev) => ({ ...prev, open: false }));
317
518
  useEffect(() => {
318
519
  (async () => {
319
520
  var _a;
320
521
  try {
321
522
  if (!statusApplicableList.length) {
322
- const res = await api.get(`/workflow/applicableStatuses?type=${rejection_reason_master}`);
523
+ const res = await api.get({
524
+ url: `/workflow/applicableStatuses?type=${rejection_reason_master}`,
525
+ serviceURL: "api"
526
+ });
323
527
  setStatusApplicableList(((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.data) || []);
324
528
  }
325
529
  } catch (e) {
530
+ setSnackbar({
531
+ open: true,
532
+ message: "Failed to load reject reasons.",
533
+ severity: "error"
534
+ });
326
535
  }
327
536
  })();
328
- }, []);
537
+ }, [rejection_reason_master]);
329
538
  const validateFields = () => {
330
539
  let isValid = true;
331
540
  const errors = { reason: "", comment: "" };
@@ -341,48 +550,174 @@ function RejectDialog({ openModal, closeModal, header, workflowLogId, statusId,
341
550
  return isValid;
342
551
  };
343
552
  const onSubmit = async () => {
344
- var _a;
553
+ var _a, _b, _c;
345
554
  if (!validateFields()) return;
346
555
  setLoading(true);
347
556
  try {
348
- await api.post(`/workflow/update-status/${workflowLogId}/${statusId}`, {
349
- reason: rejectReasons,
350
- comment,
351
- created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
557
+ await api.post({
558
+ url: `/workflow/update-status/${workflowLogId}/${statusId}`,
559
+ data: {
560
+ reason: rejectReasons,
561
+ comment,
562
+ created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
563
+ },
564
+ serviceURL: "api"
565
+ });
566
+ setSnackbar({
567
+ open: true,
568
+ message: "Rejected successfully!",
569
+ severity: "success"
352
570
  });
353
- closeModal && closeModal();
354
571
  } catch (e) {
572
+ const message = ((_c = (_b = e == null ? void 0 : e.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || "Something went wrong!";
573
+ console.error("\u274C Reject Error:", message);
574
+ setSnackbar({
575
+ open: true,
576
+ message,
577
+ severity: "error"
578
+ });
355
579
  } finally {
580
+ setComment("");
581
+ setRejectReasons("");
356
582
  setLoading(false);
583
+ closeModal && closeModal();
357
584
  }
358
585
  };
359
- return /* @__PURE__ */ jsxs(Dialog, { open: openModal, onClose: closeModal, "aria-labelledby": "responsive-dialog-title", sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } }, children: [
360
- /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
361
- /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
362
- /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
363
- ] }),
364
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 5, children: [
365
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, required: true, error: !!error.reason, children: [
366
- /* @__PURE__ */ jsx(InputLabel, { required: true, id: "reject-reason-label", children: "Reject Reasons" }),
367
- /* @__PURE__ */ jsx(Select, { IconComponent: DownArrow, label: "Reject Reasons", value: rejectReasons, id: "reject-reason", labelId: "reject-reason-label", onChange: (e) => setRejectReasons(e.target.value), children: statusApplicableList == null ? void 0 : statusApplicableList.map((reason_) => /* @__PURE__ */ jsx(MenuItem, { value: reason_ == null ? void 0 : reason_.id, children: reason_ == null ? void 0 : reason_.name }, reason_ == null ? void 0 : reason_.id)) }),
368
- error.reason && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", children: error.reason })
369
- ] }) }),
370
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(TextField, { fullWidth: true, label: "Comment", value: comment, placeholder: "Comment Here", onChange: (e) => setComment(e.target.value), required: true, error: !!error.comment, helperText: error.comment }) })
371
- ] }) }) }),
372
- /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: [
373
- /* @__PURE__ */ jsx(Button, { onClick: closeModal, size: "large", variant: "outlined", color: "primary", sx: { mr: 2 }, children: "Close" }),
374
- /* @__PURE__ */ jsx(Button, { onClick: onSubmit, size: "large", variant: "contained", color: "primary", disabled: loading, children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit" })
375
- ] }) })
586
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
587
+ /* @__PURE__ */ jsxs(
588
+ Dialog,
589
+ {
590
+ open: openModal,
591
+ onClose: closeModal,
592
+ "aria-labelledby": "responsive-dialog-title",
593
+ sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } },
594
+ children: [
595
+ /* @__PURE__ */ jsxs(
596
+ Box$1,
597
+ {
598
+ sx: {
599
+ display: "flex",
600
+ justifyContent: "space-between",
601
+ alignItems: "center"
602
+ },
603
+ children: [
604
+ /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
605
+ /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
606
+ ]
607
+ }
608
+ ),
609
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 5, children: [
610
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, required: true, error: !!error.reason, children: [
611
+ /* @__PURE__ */ jsx(InputLabel, { required: true, id: "reject-reason-label", children: "Reject Reasons" }),
612
+ /* @__PURE__ */ jsx(
613
+ Select,
614
+ {
615
+ IconComponent: DownArrow,
616
+ label: "Reject Reasons",
617
+ value: rejectReasons,
618
+ id: "reject-reason",
619
+ labelId: "reject-reason-label",
620
+ onChange: (e) => setRejectReasons(e.target.value),
621
+ children: statusApplicableList == null ? void 0 : statusApplicableList.map((reason_) => /* @__PURE__ */ jsx(MenuItem, { value: reason_ == null ? void 0 : reason_.id, children: reason_ == null ? void 0 : reason_.name }, reason_ == null ? void 0 : reason_.id))
622
+ }
623
+ ),
624
+ error.reason && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", children: error.reason })
625
+ ] }) }),
626
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
627
+ TextField,
628
+ {
629
+ fullWidth: true,
630
+ label: "Comment",
631
+ value: comment,
632
+ placeholder: "Comment Here",
633
+ onChange: (e) => setComment(e.target.value),
634
+ required: true,
635
+ error: !!error.comment,
636
+ helperText: error.comment
637
+ }
638
+ ) })
639
+ ] }) }) }),
640
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(
641
+ Box$1,
642
+ {
643
+ sx: {
644
+ display: "flex",
645
+ justifyContent: "flex-end",
646
+ alignItems: "center"
647
+ },
648
+ children: [
649
+ /* @__PURE__ */ jsx(
650
+ Button,
651
+ {
652
+ onClick: closeModal,
653
+ size: "large",
654
+ variant: "outlined",
655
+ color: "primary",
656
+ sx: { mr: 2 },
657
+ children: "Close"
658
+ }
659
+ ),
660
+ /* @__PURE__ */ jsx(
661
+ Button,
662
+ {
663
+ onClick: onSubmit,
664
+ size: "large",
665
+ variant: "contained",
666
+ color: "primary",
667
+ disabled: loading,
668
+ children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit"
669
+ }
670
+ )
671
+ ]
672
+ }
673
+ ) })
674
+ ]
675
+ }
676
+ ),
677
+ /* @__PURE__ */ jsx(
678
+ Snackbar,
679
+ {
680
+ open: snackbar.open,
681
+ autoHideDuration: 3e3,
682
+ onClose: handleCloseSnackbar,
683
+ anchorOrigin: { vertical: "top", horizontal: "right" },
684
+ children: /* @__PURE__ */ jsx(
685
+ Alert,
686
+ {
687
+ onClose: handleCloseSnackbar,
688
+ severity: snackbar.severity,
689
+ sx: {
690
+ width: "100%",
691
+ color: snackbar.severity === "error" ? "#fff" : "inherit",
692
+ bgcolor: snackbar.severity === "error" ? "#d32f2f" : void 0
693
+ },
694
+ children: snackbar.message
695
+ }
696
+ )
697
+ }
698
+ )
376
699
  ] });
377
700
  }
378
701
  var RejectDialog_default = RejectDialog;
379
- function OnHoldDialog({ openModal, closeModal, header, workflowLogId, statusId }) {
702
+ function OnHoldDialog({
703
+ openModal,
704
+ closeModal,
705
+ header,
706
+ workflowLogId,
707
+ statusId
708
+ }) {
380
709
  const { userInfo, api } = useWorkflowContext();
381
710
  const theme = useTheme();
382
711
  useMediaQuery(theme.breakpoints.down("lg"));
383
712
  const [comment, setComment] = useState("");
384
713
  const [error, setError] = useState({ comment: "" });
385
714
  const [loading, setLoading] = useState(false);
715
+ const [snackbar, setSnackbar] = useState({
716
+ open: false,
717
+ message: "",
718
+ severity: "success"
719
+ });
720
+ const handleCloseSnackbar = () => setSnackbar((prev) => ({ ...prev, open: false }));
386
721
  const validateFields = () => {
387
722
  let isValid = true;
388
723
  const errors = { comment: "" };
@@ -394,271 +729,331 @@ function OnHoldDialog({ openModal, closeModal, header, workflowLogId, statusId }
394
729
  return isValid;
395
730
  };
396
731
  const onSubmit = async () => {
397
- var _a;
732
+ var _a, _b, _c;
398
733
  if (!validateFields()) return;
399
734
  setLoading(true);
400
735
  try {
401
- await api.post(`/workflow/update-status/${workflowLogId}/${statusId}`, {
402
- comment,
403
- created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
736
+ await api.post({
737
+ url: `/workflow/update-status/${workflowLogId}/${statusId}`,
738
+ data: {
739
+ comment,
740
+ created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
741
+ },
742
+ serviceURL: "api"
743
+ });
744
+ setSnackbar({
745
+ open: true,
746
+ message: "Moved to On-Hold successfully!",
747
+ severity: "success"
748
+ });
749
+ } catch (e) {
750
+ setSnackbar({
751
+ open: true,
752
+ message: ((_c = (_b = e == null ? void 0 : e.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || "Failed to submit the form",
753
+ severity: "error"
404
754
  });
405
- closeModal && closeModal();
406
- } catch {
407
- toast.error("Failed to submit the form");
408
755
  } finally {
756
+ setComment("");
757
+ closeModal && closeModal();
409
758
  setLoading(false);
410
759
  }
411
760
  };
412
- return /* @__PURE__ */ jsxs(Dialog, { open: openModal, onClose: closeModal, "aria-labelledby": "responsive-dialog-title", sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } }, children: [
413
- /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
414
- /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
415
- /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
416
- ] }),
417
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(TextField, { fullWidth: true, label: "Comment", value: comment, placeholder: "Comment Here", onChange: (e) => setComment(e.target.value), required: true, error: !!error.comment, helperText: error.comment }) }) }) }) }),
418
- /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: [
419
- /* @__PURE__ */ jsx(Button, { onClick: closeModal, size: "large", variant: "outlined", color: "primary", sx: { mr: 2 }, children: "Close" }),
420
- /* @__PURE__ */ jsx(Button, { onClick: onSubmit, size: "large", variant: "contained", color: "primary", disabled: loading, children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit" })
421
- ] }) })
422
- ] });
423
- }
424
- var OnHoldDialog_default = OnHoldDialog;
425
- var getStatus = (status, theme) => {
426
- const s = status == null ? void 0 : status.toLowerCase();
427
- const colors = {
428
- approved: {
429
- bg: theme.palette.success.light,
430
- text: theme.palette.success.main
431
- },
432
- rejected: { bg: theme.palette.error.light, text: theme.palette.error.main },
433
- onhold: {
434
- bg: theme.palette.warning.light,
435
- text: theme.palette.warning.main
436
- },
437
- inprogress: { bg: theme.palette.info.light, text: theme.palette.info.main },
438
- pending: { bg: theme.palette.grey[200], text: theme.palette.text.primary }
439
- };
440
- return colors[s] || colors.pending;
441
- };
442
- function ConnectedTimeline({ events }) {
443
- const { api } = useWorkflowContext();
444
- const theme = useTheme$1();
445
- const [isMobile, setIsMobile] = useState(false);
446
- useEffect(() => {
447
- const checkScreen = () => setIsMobile(window.innerWidth < 768);
448
- checkScreen();
449
- window.addEventListener("resize", checkScreen);
450
- return () => window.removeEventListener("resize", checkScreen);
451
- }, []);
452
- const handleAttachmentClick = (attachment) => {
453
- api.get({
454
- url: `/workflow/uploaded-document-url/${attachment.split("/").reverse()[0]}`,
455
- serviceURL: "api"
456
- }).then((res) => window.open(res.data, "_blank"));
457
- };
458
- const columns = 4;
459
- const rows = [];
460
- for (let i = 0; i < (events == null ? void 0 : events.length); i += columns)
461
- rows.push(events.slice(i, i + columns));
462
- return /* @__PURE__ */ jsx(Box$1, { sx: { py: 4, position: "relative" }, children: rows.map((row, rowIndex) => {
463
- const reversed = rowIndex % 2 === 1;
464
- return /* @__PURE__ */ jsx(
465
- Box$1,
761
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
762
+ /* @__PURE__ */ jsxs(
763
+ Dialog,
466
764
  {
467
- sx: {
468
- display: "flex",
469
- flexDirection: reversed ? "row-reverse" : "row",
470
- justifyContent: "left",
471
- alignItems: "center",
472
- gap: 6,
473
- position: "relative",
474
- mb: 8,
475
- flexWrap: isMobile ? "wrap" : "nowrap"
476
- },
477
- children: row.map((event, index) => {
478
- var _a;
479
- const globalIndex = rowIndex * columns + index;
480
- const status = getStatus((_a = event.status) == null ? void 0 : _a.title, theme);
481
- const isDisabled = event.cardType === "disableCard";
482
- return /* @__PURE__ */ jsxs(
765
+ open: openModal,
766
+ onClose: closeModal,
767
+ "aria-labelledby": "responsive-dialog-title",
768
+ sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } },
769
+ children: [
770
+ /* @__PURE__ */ jsxs(
483
771
  Box$1,
484
772
  {
485
773
  sx: {
486
- position: "relative",
487
774
  display: "flex",
488
- justifyContent: "center",
775
+ justifyContent: "space-between",
489
776
  alignItems: "center"
490
777
  },
491
778
  children: [
492
- !isMobile && index < row.length - 1 && /* @__PURE__ */ jsx(
493
- Box$1,
494
- {
495
- sx: {
496
- position: "absolute",
497
- top: "50%",
498
- [reversed ? "right" : "left"]: "100%",
499
- width: "60px",
500
- height: "2px",
501
- background: theme.palette.primary.main,
502
- zIndex: 0
503
- }
504
- }
505
- ),
506
- !isMobile && globalIndex === (rowIndex + 1) * columns - 1 && globalIndex < events.length - 1 && /* @__PURE__ */ jsx(
507
- Box$1,
779
+ /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
780
+ /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
781
+ ]
782
+ }
783
+ ),
784
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsx(Grid, { container: true, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
785
+ TextField,
786
+ {
787
+ fullWidth: true,
788
+ label: "Comment",
789
+ value: comment,
790
+ placeholder: "Comment Here",
791
+ onChange: (e) => setComment(e.target.value),
792
+ required: true,
793
+ error: !!error.comment,
794
+ helperText: error.comment
795
+ }
796
+ ) }) }) }) }),
797
+ /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(
798
+ Box$1,
799
+ {
800
+ sx: {
801
+ display: "flex",
802
+ justifyContent: "flex-end",
803
+ alignItems: "center"
804
+ },
805
+ children: [
806
+ /* @__PURE__ */ jsx(
807
+ Button,
508
808
  {
509
- sx: {
510
- position: "absolute",
511
- bottom: "-48px",
512
- left: reversed ? "0%" : "100%",
513
- width: "2px",
514
- height: "48px",
515
- background: theme.palette.primary.main,
516
- zIndex: 0
517
- }
809
+ onClick: closeModal,
810
+ size: "large",
811
+ variant: "outlined",
812
+ color: "primary",
813
+ sx: { mr: 2 },
814
+ children: "Close"
518
815
  }
519
816
  ),
520
817
  /* @__PURE__ */ jsx(
521
- Card,
818
+ Button,
522
819
  {
523
- sx: {
524
- width: "230px",
525
- minHeight: "180px",
526
- borderRadius: "16px",
527
- border: `1px solid ${isDisabled ? theme.palette.success.light : theme.palette.divider}`,
528
- backgroundColor: isDisabled ? theme.palette.action.hover : theme.palette.background.paper,
529
- textAlign: "center",
530
- boxShadow: "0px 4px 10px rgba(0,0,0,0.05)",
531
- transition: "all 0.25s ease-in-out",
532
- "&:hover": {
533
- boxShadow: "0px 6px 14px rgba(0,0,0,0.1)",
534
- transform: "translateY(-2px)"
535
- }
536
- },
537
- children: /* @__PURE__ */ jsxs(CardContent, { children: [
538
- /* @__PURE__ */ jsxs(
539
- Box$1,
540
- {
541
- sx: {
542
- display: "flex",
543
- justifyContent: "space-between",
544
- alignItems: "center",
545
- mb: 1
546
- },
547
- children: [
548
- /* @__PURE__ */ jsx(
549
- Typography,
550
- {
551
- variant: "body2",
552
- color: theme.palette.text.secondary,
553
- children: event.date
554
- }
555
- ),
556
- event.status && /* @__PURE__ */ jsx(
557
- Chip,
558
- {
559
- label: event.status.title,
560
- sx: {
561
- backgroundColor: status.bg,
562
- color: status.text,
563
- fontSize: 12,
564
- height: 24,
565
- fontWeight: 600,
566
- borderRadius: "16px"
567
- }
568
- }
569
- )
570
- ]
571
- }
572
- ),
573
- /* @__PURE__ */ jsx(
574
- Box$1,
575
- {
576
- sx: {
577
- width: 36,
578
- height: 36,
579
- borderRadius: "50%",
580
- border: `2px solid ${theme.palette.primary.main}`,
581
- display: "flex",
582
- justifyContent: "center",
583
- alignItems: "center",
584
- color: theme.palette.primary.main,
585
- fontWeight: 600,
586
- fontSize: 14,
587
- mx: "auto",
588
- mb: 1.5
589
- },
590
- children: event.count
591
- }
592
- ),
593
- /* @__PURE__ */ jsx(Tooltip, { title: event.title, children: /* @__PURE__ */ jsx(
594
- Typography,
595
- {
596
- variant: "subtitle1",
597
- fontWeight: 600,
598
- color: isDisabled ? theme.palette.text.secondary : theme.palette.text.primary,
599
- sx: {
600
- overflow: "hidden",
601
- textOverflow: "ellipsis",
602
- whiteSpace: "nowrap",
603
- mb: 0.5
604
- },
605
- children: event.title
606
- }
607
- ) }),
608
- /* @__PURE__ */ jsx(
609
- Typography,
610
- {
611
- variant: "body2",
612
- color: theme.palette.text.secondary,
613
- sx: {
614
- minHeight: "20px",
615
- mb: 0.8,
616
- textOverflow: "ellipsis",
617
- whiteSpace: "nowrap",
618
- overflow: "hidden"
619
- },
620
- children: event.subTitle || "No Comments"
621
- }
622
- ),
623
- event.attachment && /* @__PURE__ */ jsx(Tooltip, { title: "View attachment", children: /* @__PURE__ */ jsx(
624
- Typography,
820
+ onClick: onSubmit,
821
+ size: "large",
822
+ variant: "contained",
823
+ color: "primary",
824
+ disabled: loading,
825
+ children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit"
826
+ }
827
+ )
828
+ ]
829
+ }
830
+ ) })
831
+ ]
832
+ }
833
+ ),
834
+ /* @__PURE__ */ jsx(
835
+ Snackbar,
836
+ {
837
+ open: snackbar.open,
838
+ autoHideDuration: 3e3,
839
+ onClose: handleCloseSnackbar,
840
+ anchorOrigin: { vertical: "top", horizontal: "right" },
841
+ children: /* @__PURE__ */ jsx(
842
+ Alert,
843
+ {
844
+ onClose: handleCloseSnackbar,
845
+ severity: snackbar.severity,
846
+ sx: {
847
+ width: "100%",
848
+ color: snackbar.severity === "error" ? "#fff" : "inherit",
849
+ bgcolor: snackbar.severity === "error" ? "#d32f2f" : void 0
850
+ },
851
+ children: snackbar.message
852
+ }
853
+ )
854
+ }
855
+ )
856
+ ] });
857
+ }
858
+ var OnHoldDialog_default = OnHoldDialog;
859
+ var CONNECTOR_STYLE = {
860
+ horizontal: {
861
+ thickness: 3,
862
+ lengthExtra: 20,
863
+ color: "#2C35FF",
864
+ offsetY: 90,
865
+ offsetReverseExtra: 30
866
+ // extra offset for reversed rows to avoid overlap
867
+ },
868
+ vertical: {
869
+ thickness: 3,
870
+ height: 60,
871
+ color: "#2C35FF"}
872
+ };
873
+ var CARD_WIDTH = 200;
874
+ var CARD_HEIGHT = 220;
875
+ var GAP = 65;
876
+ var ROW_GAP = 60;
877
+ var CustomCard = styled(Card)(
878
+ ({ theme, cardType }) => ({
879
+ width: CARD_WIDTH,
880
+ height: CARD_HEIGHT,
881
+ borderRadius: 16,
882
+ backgroundColor: cardType === "subCard" ? "#FFF2D8" : cardType === "disableCard" ? "#ECECEC" : "#F1F1FF",
883
+ border: cardType === "disableCard" ? "none" : `1px solid ${theme.palette.primary.dark}`,
884
+ position: "relative"
885
+ })
886
+ );
887
+ var Bull = ({ count, cardType }) => {
888
+ const theme = useTheme();
889
+ return /* @__PURE__ */ jsx(
890
+ Box$1,
891
+ {
892
+ sx: {
893
+ width: 40,
894
+ height: 40,
895
+ display: "flex",
896
+ justifyContent: "center",
897
+ alignItems: "center",
898
+ borderRadius: "50%",
899
+ background: "#fff",
900
+ border: cardType === "disableCard" ? `2px solid ${theme.palette.grey[400]}` : `2px solid ${theme.palette.primary.dark}`,
901
+ color: cardType === "disableCard" ? theme.palette.grey[700] : theme.palette.primary.dark,
902
+ fontWeight: 600,
903
+ fontSize: 16
904
+ },
905
+ children: count
906
+ }
907
+ );
908
+ };
909
+ function SnakeTimeline({ events }) {
910
+ const { api } = useWorkflowContext();
911
+ useTheme();
912
+ const rows = [];
913
+ for (let i = 0; i < events.length; i += 4) rows.push(events.slice(i, i + 4));
914
+ const computeColumn = (index) => {
915
+ const row = Math.floor(index / 4);
916
+ const pos = index % 4;
917
+ return row % 2 === 0 ? pos : 3 - pos;
918
+ };
919
+ const getHorizontalOffsetY = (rowIndex) => rowIndex % 2 === 0 ? CONNECTOR_STYLE.horizontal.offsetY : CONNECTOR_STYLE.horizontal.offsetY + CONNECTOR_STYLE.horizontal.offsetReverseExtra;
920
+ const hasNextCard = (currentIndex) => currentIndex + 1 < events.length;
921
+ const handleAttachmentClick = (att) => {
922
+ if (!att) return;
923
+ api.get({
924
+ url: `/workflow/uploaded-document-url/${att.split("/").pop()}`,
925
+ serviceURL: "api"
926
+ }).then((res) => window.open(res.data, "_blank"));
927
+ };
928
+ return /* @__PURE__ */ jsx(Box$1, { sx: { width: "100%", overflowX: "auto", p: 2 }, children: /* @__PURE__ */ jsx(
929
+ Box$1,
930
+ {
931
+ sx: {
932
+ position: "relative",
933
+ display: "grid",
934
+ gridTemplateColumns: `repeat(4, ${CARD_WIDTH}px)`,
935
+ columnGap: `${GAP}px`,
936
+ rowGap: `${ROW_GAP}px`,
937
+ width: "max-content"
938
+ },
939
+ children: events.map((event, index) => {
940
+ console.log("\u{1F680} ~ SnakeTimeline ~ event:", event);
941
+ const row = Math.floor(index / 4);
942
+ const col = computeColumn(index);
943
+ const isLastInRow = index % 4 === 3;
944
+ const isVerticalConnectorNeeded = (index + 1) % 4 === 0 && hasNextCard(index);
945
+ return /* @__PURE__ */ jsxs(
946
+ Box$1,
947
+ {
948
+ sx: {
949
+ gridColumn: col + 1,
950
+ gridRow: row + 1,
951
+ position: "relative"
952
+ },
953
+ children: [
954
+ !isLastInRow && hasNextCard(index) && /* @__PURE__ */ jsx(
955
+ Box$1,
956
+ {
957
+ sx: {
958
+ position: "absolute",
959
+ top: getHorizontalOffsetY(row),
960
+ left: row % 2 === 0 ? CARD_WIDTH : "auto",
961
+ right: row % 2 !== 0 ? CARD_WIDTH : "auto",
962
+ width: GAP + CONNECTOR_STYLE.horizontal.lengthExtra,
963
+ borderTop: `${CONNECTOR_STYLE.horizontal.thickness}px dashed ${CONNECTOR_STYLE.horizontal.color}`,
964
+ zIndex: 10
965
+ }
966
+ }
967
+ ),
968
+ isVerticalConnectorNeeded && /* @__PURE__ */ jsx(
969
+ Box$1,
970
+ {
971
+ sx: {
972
+ position: "absolute",
973
+ top: CARD_HEIGHT,
974
+ left: CARD_WIDTH / 2 - CONNECTOR_STYLE.vertical.thickness / 2,
975
+ width: CONNECTOR_STYLE.vertical.thickness,
976
+ height: CONNECTOR_STYLE.vertical.height,
977
+ borderLeft: `${CONNECTOR_STYLE.vertical.thickness}px dashed ${CONNECTOR_STYLE.vertical.color}`,
978
+ zIndex: 10
979
+ }
980
+ }
981
+ ),
982
+ /* @__PURE__ */ jsx(CustomCard, { cardType: event.cardType, children: /* @__PURE__ */ jsxs(CardContent, { sx: { px: 2, pt: 2, pb: 1 }, children: [
983
+ /* @__PURE__ */ jsxs(
984
+ Box$1,
985
+ {
986
+ sx: {
987
+ mb: 1,
988
+ display: "flex",
989
+ justifyContent: "space-between",
990
+ alignItems: "center",
991
+ height: 28
992
+ },
993
+ children: [
994
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: event.date }),
995
+ event.status && /* @__PURE__ */ jsx(
996
+ Chip,
625
997
  {
626
- variant: "body2",
998
+ label: event.status.title,
627
999
  sx: {
628
- color: theme.palette.primary.main,
629
- cursor: "pointer",
630
- textDecoration: "underline",
631
- fontWeight: 500,
632
- "&:hover": {
633
- color: theme.palette.primary.dark
634
- }
635
- },
636
- onClick: () => handleAttachmentClick(event.attachment),
637
- children: "Attachment"
638
- }
639
- ) }),
640
- /* @__PURE__ */ jsx(
641
- Typography,
642
- {
643
- variant: "caption",
644
- display: "block",
645
- color: theme.palette.text.disabled,
646
- sx: { mt: 1 },
647
- children: event.time
1000
+ backgroundColor: event.status.color,
1001
+ color: event.status.labelColor,
1002
+ borderRadius: "50px",
1003
+ height: 28,
1004
+ fontWeight: 600
1005
+ }
648
1006
  }
649
1007
  )
650
- ] })
1008
+ ]
1009
+ }
1010
+ ),
1011
+ /* @__PURE__ */ jsx(Bull, { count: event.count, cardType: event.cardType }),
1012
+ /* @__PURE__ */ jsx(
1013
+ Typography,
1014
+ {
1015
+ variant: "subtitle2",
1016
+ sx: { mt: 2, fontWeight: 600 },
1017
+ children: event.title
1018
+ }
1019
+ ),
1020
+ /* @__PURE__ */ jsx(Typography, { sx: { mb: 1 }, variant: "body2", children: event.subTitle }),
1021
+ event.attachment && /* @__PURE__ */ jsxs(
1022
+ Typography,
1023
+ {
1024
+ sx: {
1025
+ cursor: "pointer",
1026
+ color: "#0B56CA",
1027
+ fontWeight: 600
1028
+ },
1029
+ onClick: () => handleAttachmentClick(event.attachment),
1030
+ children: [
1031
+ /* @__PURE__ */ jsx("span", { className: "icon-link" }),
1032
+ " Attachment"
1033
+ ]
1034
+ }
1035
+ ),
1036
+ /* @__PURE__ */ jsx(
1037
+ Typography,
1038
+ {
1039
+ variant: "body2",
1040
+ sx: {
1041
+ position: "absolute",
1042
+ bottom: 12,
1043
+ left: 14,
1044
+ color: "#777"
1045
+ },
1046
+ children: event.time
651
1047
  }
652
1048
  )
653
- ]
654
- },
655
- index
656
- );
657
- })
658
- },
659
- rowIndex
660
- );
661
- }) });
1049
+ ] }) })
1050
+ ]
1051
+ },
1052
+ index
1053
+ );
1054
+ })
1055
+ }
1056
+ ) });
662
1057
  }
663
1058
  var useDebounce = (value, delay) => {
664
1059
  const [debouncedValue, setDebouncedValue] = useState(value);
@@ -703,7 +1098,7 @@ var SearchBox = ({
703
1098
  ) });
704
1099
  };
705
1100
  var SearchBox_default = SearchBox;
706
- var StyledChipProps = styled(Chip)(({ theme }) => {
1101
+ var StyledChipProps = styled$1(Chip)(({ theme }) => {
707
1102
  var _a, _b, _c;
708
1103
  return {
709
1104
  "&.MuiChip-colorPrimary": {
@@ -743,6 +1138,7 @@ function ApprovalWorkflow({
743
1138
  selectedWorkflowsList.length ? "selected" : "Action Required"
744
1139
  );
745
1140
  const [expandedId, setExpandedId] = useState(null);
1141
+ console.log("\u{1F680} ~ ApprovalWorkflow ~ expandedId:", expandedId);
746
1142
  const [sendDialog, setSendDialog] = React7.useState(null);
747
1143
  const [approveTarget, setApproveTarget] = React7.useState(null);
748
1144
  const [rejectTarget, setRejectTarget] = React7.useState(null);
@@ -842,10 +1238,11 @@ function ApprovalWorkflow({
842
1238
  if (option === "selected") fetchSelectedActivites();
843
1239
  };
844
1240
  const handleExpandClick = (id) => {
1241
+ console.log("\u{1F680} ~ handleExpandClick ~ id:", id);
845
1242
  setExpandedId((prevId) => prevId === id ? null : id);
846
1243
  fetchExpandedActivityLogs(id);
847
1244
  };
848
- const getStatus2 = (status) => {
1245
+ const getStatus = (status) => {
849
1246
  switch (status.toLowerCase()) {
850
1247
  case "approved":
851
1248
  return {
@@ -992,6 +1389,32 @@ function ApprovalWorkflow({
992
1389
  }
993
1390
  return "#";
994
1391
  };
1392
+ const StatusObj = {
1393
+ approved: {
1394
+ title: "Approved",
1395
+ color: theme.palette.success.light,
1396
+ labelColor: theme.palette.success.dark
1397
+ },
1398
+ rejected: {
1399
+ title: "Rejected",
1400
+ color: theme.palette.error.light,
1401
+ labelColor: theme.palette.error.dark
1402
+ },
1403
+ onhold: {
1404
+ title: "On Hold",
1405
+ color: theme.palette.warning.light,
1406
+ labelColor: theme.palette.warning.dark
1407
+ },
1408
+ sendback: {
1409
+ title: "Send Back",
1410
+ color: theme.palette.info.light,
1411
+ labelColor: theme.palette.info.dark
1412
+ },
1413
+ pending: {
1414
+ color: theme.palette.grey[300],
1415
+ labelColor: theme.palette.text.primary
1416
+ }
1417
+ };
995
1418
  if (isLoading && loadingComponent) return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
996
1419
  return /* @__PURE__ */ jsxs(Fragment, { children: [
997
1420
  /* @__PURE__ */ jsx(
@@ -1063,7 +1486,7 @@ function ApprovalWorkflow({
1063
1486
  pb: 3
1064
1487
  },
1065
1488
  children: visibleSelectedRequests == null ? void 0 : visibleSelectedRequests.map((info, index) => {
1066
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l, _m, _n, _o;
1489
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l, _m, _n;
1067
1490
  const currentLevel = info == null ? void 0 : info.levels.find(
1068
1491
  (level_) => level_.id === (info == null ? void 0 : info.current_level)
1069
1492
  );
@@ -1075,13 +1498,17 @@ function ApprovalWorkflow({
1075
1498
  },
1076
1499
  {}
1077
1500
  );
1501
+ const filterRejectForLevelZero = (statusList2, info2) => {
1502
+ if (!(info2 == null ? void 0 : info2.isLevelZero)) return statusList2;
1503
+ return statusList2.filter((item) => item.status !== 3);
1504
+ };
1078
1505
  const redir = buildRedirectionUrl(info);
1079
1506
  const currentStatus = ((_c2 = (_b2 = (_a2 = info == null ? void 0 : info.levels) == null ? void 0 : _a2.find(
1080
1507
  (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1081
1508
  )) == null ? void 0 : _b2.selected_status) == null ? void 0 : _c2.status_id) === 1 ? "approved" : ((_f2 = (_e2 = (_d2 = info == null ? void 0 : info.levels) == null ? void 0 : _d2.find(
1082
1509
  (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1083
1510
  )) == null ? void 0 : _e2.selected_status) == null ? void 0 : _f2.status_id) === 3 ? "rejected" : "pending";
1084
- const statusData = getStatus2(currentStatus);
1511
+ const statusData = getStatus(currentStatus);
1085
1512
  return /* @__PURE__ */ jsxs(
1086
1513
  Card,
1087
1514
  {
@@ -1244,17 +1671,19 @@ function ApprovalWorkflow({
1244
1671
  `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
1245
1672
  );
1246
1673
  },
1247
- statusList: (info == null ? void 0 : info.isLevelZero) && (info == null ? void 0 : info.created_by) === ((_o = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _o.id) ? statusList == null ? void 0 : statusList.filter(
1248
- (app) => app.status == 1
1249
- ) : statusList
1674
+ level: info == null ? void 0 : info.isLevelZero,
1675
+ statusList: filterRejectForLevelZero(
1676
+ statusList,
1677
+ info
1678
+ )
1250
1679
  }
1251
1680
  ) : /* @__PURE__ */ jsx(
1252
1681
  Chip,
1253
1682
  {
1254
1683
  variant: "filled",
1255
1684
  sx: {
1256
- backgroundColor: getStatus2(currentStatus).color,
1257
- color: getStatus2(currentStatus).labelColor,
1685
+ backgroundColor: getStatus(currentStatus).color,
1686
+ color: getStatus(currentStatus).labelColor,
1258
1687
  height: "40px",
1259
1688
  px: 2,
1260
1689
  borderRadius: "100px !important",
@@ -1312,7 +1741,7 @@ function ApprovalWorkflow({
1312
1741
  children: /* @__PURE__ */ jsx(CircularProgress, { size: 36, color: "primary" })
1313
1742
  }
1314
1743
  ) : /* @__PURE__ */ jsx(
1315
- ConnectedTimeline,
1744
+ SnakeTimeline,
1316
1745
  {
1317
1746
  events: expandedDetails == null ? void 0 : expandedDetails.map((item) => {
1318
1747
  var _a3, _b3, _c3, _d3;
@@ -1325,7 +1754,8 @@ function ApprovalWorkflow({
1325
1754
  subTitle: ((_c3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _c3.comment) || "No Comments",
1326
1755
  attachment: ((_d3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _d3.file) || null,
1327
1756
  count: (item == null ? void 0 : item.current_level) == "L0" ? "L0" : item == null ? void 0 : item.current_level_count,
1328
- cardType: "card"
1757
+ cardType: "card",
1758
+ status: (item == null ? void 0 : item.type) === "approve" ? StatusObj.approved : (item == null ? void 0 : item.type) === "reject" ? StatusObj.rejected : (item == null ? void 0 : item.type) === "send_back" ? StatusObj.sendback : (item == null ? void 0 : item.type) === "onhold" ? StatusObj.onhold : null
1329
1759
  };
1330
1760
  })
1331
1761
  }
@@ -1348,7 +1778,7 @@ function ApprovalWorkflow({
1348
1778
  pb: 3
1349
1779
  },
1350
1780
  children: visibleAllRequests == null ? void 0 : visibleAllRequests.map((info, index) => {
1351
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l, _m, _n, _o;
1781
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l, _m, _n;
1352
1782
  const currentLevel = info == null ? void 0 : info.levels.find(
1353
1783
  (level_) => level_.id === (info == null ? void 0 : info.current_level)
1354
1784
  );
@@ -1360,13 +1790,17 @@ function ApprovalWorkflow({
1360
1790
  },
1361
1791
  {}
1362
1792
  );
1793
+ const filterRejectForLevelZero = (statusList2, info2) => {
1794
+ if (!(info2 == null ? void 0 : info2.isLevelZero)) return statusList2;
1795
+ return statusList2.filter((item) => item.status !== 3);
1796
+ };
1363
1797
  const redir = buildRedirectionUrl(info);
1364
1798
  const currentStatus = ((_c2 = (_b2 = (_a2 = info == null ? void 0 : info.levels) == null ? void 0 : _a2.find(
1365
1799
  (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1366
1800
  )) == null ? void 0 : _b2.selected_status) == null ? void 0 : _c2.status_id) === 1 ? "approved" : ((_f2 = (_e2 = (_d2 = info == null ? void 0 : info.levels) == null ? void 0 : _d2.find(
1367
1801
  (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1368
1802
  )) == null ? void 0 : _e2.selected_status) == null ? void 0 : _f2.status_id) === 3 ? "rejected" : "pending";
1369
- const statusData = getStatus2(currentStatus);
1803
+ const statusData = getStatus(currentStatus);
1370
1804
  return /* @__PURE__ */ jsxs(
1371
1805
  Card,
1372
1806
  {
@@ -1536,17 +1970,19 @@ function ApprovalWorkflow({
1536
1970
  `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
1537
1971
  );
1538
1972
  },
1539
- statusList: (info == null ? void 0 : info.isLevelZero) && (info == null ? void 0 : info.created_by) === ((_o = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _o.id) ? statusList == null ? void 0 : statusList.filter(
1540
- (app) => app.status == 1
1541
- ) : statusList
1973
+ level: info == null ? void 0 : info.isLevelZero,
1974
+ statusList: filterRejectForLevelZero(
1975
+ statusList,
1976
+ info
1977
+ )
1542
1978
  }
1543
1979
  ) : /* @__PURE__ */ jsx(
1544
1980
  Chip,
1545
1981
  {
1546
1982
  variant: "filled",
1547
1983
  sx: {
1548
- backgroundColor: getStatus2(currentStatus).color,
1549
- color: getStatus2(currentStatus).labelColor,
1984
+ backgroundColor: getStatus(currentStatus).color,
1985
+ color: getStatus(currentStatus).labelColor,
1550
1986
  height: "40px",
1551
1987
  px: 2,
1552
1988
  borderRadius: "100px !important",
@@ -1604,7 +2040,7 @@ function ApprovalWorkflow({
1604
2040
  children: /* @__PURE__ */ jsx(CircularProgress, { size: 36, color: "primary" })
1605
2041
  }
1606
2042
  ) : /* @__PURE__ */ jsx(
1607
- ConnectedTimeline,
2043
+ SnakeTimeline,
1608
2044
  {
1609
2045
  events: expandedDetails == null ? void 0 : expandedDetails.map((item) => {
1610
2046
  var _a3, _b3, _c3, _d3;
@@ -1617,7 +2053,8 @@ function ApprovalWorkflow({
1617
2053
  subTitle: ((_c3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _c3.comment) || "No Comments",
1618
2054
  attachment: ((_d3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _d3.file) || null,
1619
2055
  count: (item == null ? void 0 : item.current_level) == "L0" ? "L0" : item == null ? void 0 : item.current_level_count,
1620
- cardType: "card"
2056
+ cardType: "card",
2057
+ status: (item == null ? void 0 : item.type) === "approve" ? StatusObj.approved : (item == null ? void 0 : item.type) === "reject" ? StatusObj.rejected : (item == null ? void 0 : item.type) === "send_back" ? StatusObj.sendback : (item == null ? void 0 : item.type) === "onhold" ? StatusObj.onhold : null
1621
2058
  };
1622
2059
  })
1623
2060
  }
@@ -1641,18 +2078,24 @@ function ApprovalWorkflow({
1641
2078
  },
1642
2079
  children: visiblePendingRequests == null ? void 0 : visiblePendingRequests.map((info, index) => {
1643
2080
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k;
2081
+ console.log("\u{1F680} ~ ApprovalWorkflow ~ info:", info);
1644
2082
  const currentLevel = (_a2 = info == null ? void 0 : info.levels) == null ? void 0 : _a2.find(
1645
2083
  (level_) => level_.id === (info == null ? void 0 : info.current_level)
1646
2084
  );
1647
2085
  const statusList = currentLevel ? currentLevel.status_list : [];
2086
+ const filterRejectForLevelZero = (statusList2, info2) => {
2087
+ if (!(info2 == null ? void 0 : info2.isLevelZero)) return statusList2;
2088
+ return statusList2.filter((item) => item.status !== 3);
2089
+ };
2090
+ console.log("statusList", statusList);
1648
2091
  const redir = buildRedirectionUrl(info);
1649
2092
  const currentStatus = ((_d2 = (_c2 = (_b2 = info == null ? void 0 : info.levels) == null ? void 0 : _b2.find(
1650
2093
  (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1651
2094
  )) == null ? void 0 : _c2.selected_status) == null ? void 0 : _d2.status_id) === 1 ? "approved" : ((_g2 = (_f2 = (_e2 = info == null ? void 0 : info.levels) == null ? void 0 : _e2.find(
1652
2095
  (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1653
2096
  )) == null ? void 0 : _f2.selected_status) == null ? void 0 : _g2.status_id) === 3 ? "rejected" : "pending";
1654
- const statusData = getStatus2(currentStatus);
1655
- return /* @__PURE__ */ jsx(
2097
+ const statusData = getStatus(currentStatus);
2098
+ return /* @__PURE__ */ jsxs(
1656
2099
  Card,
1657
2100
  {
1658
2101
  ref: index === visiblePendingRequests.length - 1 ? lastCardRef : null,
@@ -1663,192 +2106,229 @@ function ApprovalWorkflow({
1663
2106
  px: 3,
1664
2107
  py: 2
1665
2108
  },
1666
- children: /* @__PURE__ */ jsxs(
1667
- CardContent,
1668
- {
1669
- sx: {
1670
- display: "flex",
1671
- justifyContent: "space-between",
1672
- alignItems: "center",
1673
- flexWrap: { xs: "wrap", md: "nowrap" },
1674
- gap: 2
1675
- },
1676
- children: [
1677
- /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "20%", minWidth: 220 }, children: [
1678
- /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(Typography, { variant: "h6", fontWeight: 600, noWrap: true, children: info.activity_name }) }),
1679
- /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
1680
- Typography,
1681
- {
1682
- variant: "body2",
1683
- color: "text.secondary",
1684
- noWrap: true,
1685
- sx: { mt: 0.5 },
1686
- children: info.description_data
1687
- }
1688
- ) })
1689
- ] }),
1690
- /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "18%", minWidth: 180 }, children: [
1691
- /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Links" }),
1692
- /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx(
1693
- "a",
1694
- {
1695
- href: redir,
1696
- target: "_blank",
1697
- rel: "noreferrer",
1698
- style: {
1699
- cursor: "pointer",
1700
- textDecoration: "none"
1701
- },
1702
- children: /* @__PURE__ */ jsx(
1703
- Typography,
1704
- {
1705
- variant: "subtitle2",
1706
- color: "primary.dark",
1707
- sx: {
1708
- mt: 0.8,
1709
- lineHeight: "15.4px",
1710
- overflow: "hidden",
1711
- textOverflow: "ellipsis",
1712
- whiteSpace: "nowrap"
1713
- },
1714
- children: redir
1715
- }
1716
- )
1717
- }
1718
- ) })
1719
- ] }),
1720
- /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "12%", minWidth: 120 }, children: [
1721
- /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Attachments" }),
1722
- /* @__PURE__ */ jsx(
1723
- Typography,
2109
+ children: [
2110
+ /* @__PURE__ */ jsxs(
2111
+ CardContent,
2112
+ {
2113
+ sx: {
2114
+ display: "flex",
2115
+ justifyContent: "space-between",
2116
+ alignItems: "center",
2117
+ flexWrap: { xs: "wrap", md: "nowrap" },
2118
+ gap: 2
2119
+ },
2120
+ children: [
2121
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "20%", minWidth: 220 }, children: [
2122
+ /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(Typography, { variant: "h6", fontWeight: 600, noWrap: true, children: info.activity_name }) }),
2123
+ /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
2124
+ Typography,
2125
+ {
2126
+ variant: "body2",
2127
+ color: "text.secondary",
2128
+ noWrap: true,
2129
+ sx: { mt: 0.5 },
2130
+ children: info.description_data
2131
+ }
2132
+ ) })
2133
+ ] }),
2134
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "18%", minWidth: 180 }, children: [
2135
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Links" }),
2136
+ /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx(
2137
+ "a",
2138
+ {
2139
+ href: redir,
2140
+ target: "_blank",
2141
+ rel: "noreferrer",
2142
+ style: {
2143
+ cursor: "pointer",
2144
+ textDecoration: "none"
2145
+ },
2146
+ children: /* @__PURE__ */ jsx(
2147
+ Typography,
2148
+ {
2149
+ variant: "subtitle2",
2150
+ color: "primary.dark",
2151
+ sx: {
2152
+ mt: 0.8,
2153
+ lineHeight: "15.4px",
2154
+ overflow: "hidden",
2155
+ textOverflow: "ellipsis",
2156
+ whiteSpace: "nowrap"
2157
+ },
2158
+ children: redir
2159
+ }
2160
+ )
2161
+ }
2162
+ ) })
2163
+ ] }),
2164
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "12%", minWidth: 120 }, children: [
2165
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Attachments" }),
2166
+ /* @__PURE__ */ jsx(
2167
+ Typography,
2168
+ {
2169
+ variant: "body2",
2170
+ noWrap: true,
2171
+ sx: {
2172
+ mt: 0.8,
2173
+ color: ((_h = info == null ? void 0 : info.attachment_links) == null ? void 0 : _h.length) ? "primary.dark" : "text.disabled"
2174
+ },
2175
+ children: ((_i = info == null ? void 0 : info.attachment_links) == null ? void 0 : _i.length) ? `${info.attachment_links.length} file(s)` : "N/A"
2176
+ }
2177
+ )
2178
+ ] }),
2179
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "14%", minWidth: 130 }, children: [
2180
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "TAT" }),
2181
+ /* @__PURE__ */ jsx(
2182
+ Typography,
2183
+ {
2184
+ variant: "body2",
2185
+ sx: {
2186
+ mt: 0.8,
2187
+ fontWeight: 500,
2188
+ color: "text.primary"
2189
+ },
2190
+ children: (currentLevel == null ? void 0 : currentLevel.tat_expiry) ? moment(currentLevel.tat_expiry).utcOffset("UTC+05:30").format("DD/MM/YYYY hh:mm A") : "N/A"
2191
+ }
2192
+ )
2193
+ ] }),
2194
+ /* @__PURE__ */ jsxs(
2195
+ Box,
1724
2196
  {
1725
- variant: "body2",
1726
- noWrap: true,
1727
2197
  sx: {
1728
- mt: 0.8,
1729
- color: ((_h = info == null ? void 0 : info.attachment_links) == null ? void 0 : _h.length) ? "primary.dark" : "text.disabled"
2198
+ flexBasis: "8%",
2199
+ minWidth: 80,
2200
+ textAlign: "center"
1730
2201
  },
1731
- children: ((_i = info == null ? void 0 : info.attachment_links) == null ? void 0 : _i.length) ? `${info.attachment_links.length} file(s)` : "N/A"
2202
+ children: [
2203
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Current Level" }),
2204
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { mt: 0.8 }, children: (info == null ? void 0 : info.isLevelZero) ? "L0" : "L" + (((_k = (_j = info == null ? void 0 : info.levels) == null ? void 0 : _j.findIndex(
2205
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
2206
+ )) != null ? _k : -1) + 1 || "") })
2207
+ ]
1732
2208
  }
1733
- )
1734
- ] }),
1735
- /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "14%", minWidth: 130 }, children: [
1736
- /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "TAT" }),
1737
- /* @__PURE__ */ jsx(
1738
- Typography,
2209
+ ),
2210
+ /* @__PURE__ */ jsxs(
2211
+ Box,
1739
2212
  {
1740
- variant: "body2",
1741
2213
  sx: {
1742
- mt: 0.8,
1743
- fontWeight: 500,
1744
- color: "text.primary"
2214
+ flexBasis: "18%",
2215
+ minWidth: 200,
2216
+ display: "flex",
2217
+ alignItems: "center",
2218
+ justifyContent: "flex-end",
2219
+ gap: 1.5
1745
2220
  },
1746
- children: (currentLevel == null ? void 0 : currentLevel.tat_expiry) ? moment(currentLevel.tat_expiry).utcOffset("UTC+05:30").format("DD/MM/YYYY hh:mm A") : "N/A"
1747
- }
1748
- )
1749
- ] }),
1750
- /* @__PURE__ */ jsxs(
1751
- Box,
1752
- {
1753
- sx: {
1754
- flexBasis: "8%",
1755
- minWidth: 80,
1756
- textAlign: "center"
1757
- },
1758
- children: [
1759
- /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Current Level" }),
1760
- /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { mt: 0.8 }, children: (info == null ? void 0 : info.isLevelZero) ? "L0" : "L" + (((_k = (_j = info == null ? void 0 : info.levels) == null ? void 0 : _j.findIndex(
1761
- (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1762
- )) != null ? _k : -1) + 1 || "") })
1763
- ]
1764
- }
1765
- ),
1766
- /* @__PURE__ */ jsxs(
1767
- Box,
1768
- {
1769
- sx: {
1770
- flexBasis: "18%",
1771
- minWidth: 200,
1772
- display: "flex",
1773
- alignItems: "center",
1774
- justifyContent: "flex-end",
1775
- gap: 1.5
1776
- },
1777
- children: [
1778
- (info == null ? void 0 : info.current_status) !== "completed" ? /* @__PURE__ */ jsx(
1779
- Statusselector_default,
1780
- {
1781
- onSendBack: () => handleSendBack(info == null ? void 0 : info._id),
1782
- onApprove: () => {
1783
- var _a3;
1784
- return handleApprove(
1785
- `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a3.id}`
1786
- );
1787
- },
1788
- onReject: () => {
1789
- var _a3;
1790
- return handleReject(
1791
- `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 3)) == null ? void 0 : _a3.id}|${info == null ? void 0 : info.reasons}`
1792
- );
1793
- },
1794
- onHold: () => {
1795
- var _a3;
1796
- return handleOnHold(
1797
- `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
1798
- );
1799
- },
1800
- statusList
1801
- }
1802
- ) : /* @__PURE__ */ jsx(
1803
- Chip,
1804
- {
1805
- variant: "filled",
1806
- sx: {
1807
- backgroundColor: statusData.color,
1808
- color: statusData.labelColor,
1809
- height: "40px",
1810
- px: 2,
1811
- borderRadius: "100px !important",
1812
- "& .MuiChip-label": {
1813
- fontSize: "14px",
1814
- lineHeight: "15.4px",
1815
- fontWeight: "500",
1816
- textTransform: "capitalize"
2221
+ children: [
2222
+ (info == null ? void 0 : info.current_status) !== "completed" ? /* @__PURE__ */ jsx(
2223
+ Statusselector_default,
2224
+ {
2225
+ onSendBack: () => handleSendBack(info == null ? void 0 : info._id),
2226
+ onApprove: () => {
2227
+ var _a3;
2228
+ return handleApprove(
2229
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a3.id}`
2230
+ );
2231
+ },
2232
+ onReject: () => {
2233
+ var _a3;
2234
+ return handleReject(
2235
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 3)) == null ? void 0 : _a3.id}|${info == null ? void 0 : info.reasons}`
2236
+ );
2237
+ },
2238
+ onHold: () => {
2239
+ var _a3;
2240
+ return handleOnHold(
2241
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
2242
+ );
2243
+ },
2244
+ level: info == null ? void 0 : info.isLevelZero,
2245
+ statusList: filterRejectForLevelZero(
2246
+ statusList,
2247
+ info
2248
+ )
2249
+ }
2250
+ ) : /* @__PURE__ */ jsx(
2251
+ Chip,
2252
+ {
2253
+ variant: "filled",
2254
+ sx: {
2255
+ backgroundColor: statusData.color,
2256
+ color: statusData.labelColor,
2257
+ height: "40px",
2258
+ px: 2,
2259
+ borderRadius: "100px !important",
2260
+ "& .MuiChip-label": {
2261
+ fontSize: "14px",
2262
+ lineHeight: "15.4px",
2263
+ fontWeight: "500",
2264
+ textTransform: "capitalize"
2265
+ }
2266
+ },
2267
+ label: statusData.title
2268
+ }
2269
+ ),
2270
+ /* @__PURE__ */ jsx(
2271
+ Divider,
2272
+ {
2273
+ orientation: "vertical",
2274
+ flexItem: true,
2275
+ sx: {
2276
+ borderColor: "#E0E0E0",
2277
+ height: "40px"
1817
2278
  }
1818
- },
1819
- label: statusData.title
1820
- }
1821
- ),
1822
- /* @__PURE__ */ jsx(
1823
- Divider,
1824
- {
1825
- orientation: "vertical",
1826
- flexItem: true,
1827
- sx: {
1828
- borderColor: "#E0E0E0",
1829
- height: "40px"
1830
2279
  }
1831
- }
1832
- ),
1833
- /* @__PURE__ */ jsx(
1834
- IconButton,
1835
- {
1836
- color: "primary",
1837
- sx: {
1838
- background: "rgba(25,118,210,0.08)",
1839
- boxShadow: "2px 2px 10px 0px #4C4E6426",
1840
- "& span": { color: "primary.dark" }
1841
- },
1842
- onClick: () => handleExpandClick(info._id),
1843
- children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
1844
- }
1845
- )
1846
- ]
1847
- }
1848
- )
1849
- ]
1850
- }
1851
- )
2280
+ ),
2281
+ /* @__PURE__ */ jsx(
2282
+ IconButton,
2283
+ {
2284
+ color: "primary",
2285
+ sx: {
2286
+ background: "rgba(25,118,210,0.08)",
2287
+ boxShadow: "2px 2px 10px 0px #4C4E6426",
2288
+ "& span": { color: "primary.dark" }
2289
+ },
2290
+ onClick: () => handleExpandClick(info._id),
2291
+ children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
2292
+ }
2293
+ )
2294
+ ]
2295
+ }
2296
+ )
2297
+ ]
2298
+ }
2299
+ ),
2300
+ expandedId === info._id && /* @__PURE__ */ jsx(Box, { sx: { mt: 2, ml: 2 }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(
2301
+ Box,
2302
+ {
2303
+ sx: {
2304
+ height: 150,
2305
+ display: "flex",
2306
+ justifyContent: "center",
2307
+ alignItems: "center"
2308
+ },
2309
+ children: /* @__PURE__ */ jsx(CircularProgress, { size: 36, color: "primary" })
2310
+ }
2311
+ ) : /* @__PURE__ */ jsx(
2312
+ SnakeTimeline,
2313
+ {
2314
+ events: expandedDetails == null ? void 0 : expandedDetails.map((item) => {
2315
+ var _a3, _b3, _c3, _d3;
2316
+ return {
2317
+ date: moment(item == null ? void 0 : item.created_at).format(
2318
+ "DD-MM-YYYY"
2319
+ ),
2320
+ time: moment(item == null ? void 0 : item.created_at).format("HH:mm"),
2321
+ title: (item == null ? void 0 : item.type) === "create" ? `Raised by - ${(_a3 = item == null ? void 0 : item.created_by_user) == null ? void 0 : _a3.full_name}` : ((_b3 = item == null ? void 0 : item.created_by_user) == null ? void 0 : _b3.full_name) || "N/A",
2322
+ subTitle: ((_c3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _c3.comment) || "No Comments",
2323
+ attachment: ((_d3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _d3.file) || null,
2324
+ count: (item == null ? void 0 : item.current_level) == "L0" ? "L0" : item == null ? void 0 : item.current_level_count,
2325
+ cardType: "card",
2326
+ status: (item == null ? void 0 : item.type) === "approve" ? StatusObj.approved : (item == null ? void 0 : item.type) === "reject" ? StatusObj.rejected : (item == null ? void 0 : item.type) === "send_back" ? StatusObj.sendback : (item == null ? void 0 : item.type) === "onhold" ? StatusObj.onhold : null
2327
+ };
2328
+ })
2329
+ }
2330
+ ) })
2331
+ ]
1852
2332
  },
1853
2333
  index
1854
2334
  );