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