amp-workflow-ui 0.1.1 → 0.1.3

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
@@ -1,4 +1,4 @@
1
- import React7, { createContext, useState, useEffect, useContext, useRef } from 'react';
1
+ import React7, { createContext, useState, useEffect, useCallback, useContext, useRef } from 'react';
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';
@@ -6,7 +6,7 @@ import { 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, Typography, IconButton, useTheme as useTheme$1, Tooltip, Card, CardContent, Divider, Grid, CircularProgress, Button, Menu, MenuItem, Box as Box$1, DialogTitle, TextField, InputAdornment, DialogActions, FormControl, InputLabel, Select } from '@mui/material';
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';
10
10
  import HighlightOffIcon from '@mui/icons-material/HighlightOff';
11
11
  import { Box } from '@mui/system';
12
12
  import moment from 'moment';
@@ -70,7 +70,12 @@ var ActionMenu = ({
70
70
  ] });
71
71
  };
72
72
  var Statusselector_default = ActionMenu;
73
- function SendBackDialog({ openModal, closeModal, header, workflowLogId }) {
73
+ function SendBackDialog({
74
+ openModal,
75
+ closeModal,
76
+ header,
77
+ workflowLogId
78
+ }) {
74
79
  const { userInfo, api } = useWorkflowContext();
75
80
  const [comment, setComment] = useState("");
76
81
  const [selectedFile, setSelectedFile] = useState(null);
@@ -88,7 +93,9 @@ function SendBackDialog({ openModal, closeModal, header, workflowLogId }) {
88
93
  const formData = new FormData();
89
94
  formData.append("file", file);
90
95
  try {
91
- const response = await api.post("/workflow/upload-document", formData, {
96
+ const response = await api.post({
97
+ url: "/workflow/upload-document",
98
+ data: formData,
92
99
  headers: { "Content-Type": "multipart/form-data" }
93
100
  });
94
101
  setFileName(response.data.file);
@@ -124,10 +131,14 @@ function SendBackDialog({ openModal, closeModal, header, workflowLogId }) {
124
131
  if (!validateFields()) return;
125
132
  setLoading(true);
126
133
  try {
127
- const res = await api.post(`/workflow/send-back/${workflowLogId}`, {
128
- comment,
129
- file: selectedFile,
130
- created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
134
+ const res = await api.post({
135
+ url: `/workflow/send-back/${workflowLogId}`,
136
+ data: {
137
+ comment,
138
+ file: selectedFile,
139
+ created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
140
+ },
141
+ serviceURL: "api"
131
142
  });
132
143
  if ((res == null ? void 0 : res.status) === 200) toast.success("Successfully sent back!");
133
144
  if ((_b = res == null ? void 0 : res.error) == null ? void 0 : _b.message) {
@@ -140,50 +151,107 @@ function SendBackDialog({ openModal, closeModal, header, workflowLogId }) {
140
151
  setLoading(false);
141
152
  }
142
153
  };
143
- return /* @__PURE__ */ jsxs(Dialog, { open: openModal, onClose: closeModal, "aria-labelledby": "responsive-dialog-title", sx: { "& .MuiPaper-root.MuiDialog-paper": { width: "550px" } }, children: [
144
- /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
145
- /* @__PURE__ */ jsx(DialogTitle, { id: "responsive-dialog-title", children: header }),
146
- /* @__PURE__ */ jsx(IconButton, { disableFocusRipple: true, disableRipple: true, onClick: closeModal, children: /* @__PURE__ */ jsx(HighlightOffIcon, { style: { color: "#666666" } }) })
147
- ] }),
148
- /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(Box$1, { sx: { mb: 5 }, children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 5, children: [
149
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
150
- TextField,
151
- {
152
- fullWidth: true,
153
- label: "Comment",
154
- value: comment,
155
- placeholder: "Comment Here",
156
- onChange: (e) => setComment(e.target.value),
157
- required: true,
158
- error: !!error.comment,
159
- helperText: error.comment
160
- }
161
- ) }),
162
- /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
163
- /* @__PURE__ */ jsx(
164
- TextField,
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,
165
164
  {
166
- type: "text",
167
- fullWidth: true,
168
- label: "Attachment",
169
- placeholder: "Attachment",
170
- InputProps: {
171
- endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx("span", { className: "icon-export-1" }) })
165
+ sx: {
166
+ display: "flex",
167
+ justifyContent: "space-between",
168
+ alignItems: "center"
172
169
  },
173
- onClick: handleAttachment,
174
- value: fileName,
175
- error: !!error.file,
176
- helperText: error.file
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
+ ]
177
174
  }
178
175
  ),
179
- /* @__PURE__ */ jsx("input", { type: "file", ref: fileInputRef, style: { display: "none" }, onChange: handleFileChange })
180
- ] })
181
- ] }) }) }),
182
- /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center" }, children: [
183
- /* @__PURE__ */ jsx(Button, { onClick: closeModal, size: "large", variant: "outlined", color: "primary", sx: { mr: 2 }, children: "Close" }),
184
- /* @__PURE__ */ jsx(Button, { onClick: onSubmit, size: "large", variant: "contained", color: "primary", disabled: loading || fileLoading, children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 24, color: "inherit" }) : "Submit" })
185
- ] }) })
186
- ] });
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,
179
+ {
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
188
+ }
189
+ ) }),
190
+ /* @__PURE__ */ jsxs(Grid, { item: true, xs: 12, children: [
191
+ /* @__PURE__ */ jsx(
192
+ TextField,
193
+ {
194
+ type: "text",
195
+ 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
205
+ }
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: [
227
+ /* @__PURE__ */ jsx(
228
+ Button,
229
+ {
230
+ onClick: closeModal,
231
+ size: "large",
232
+ variant: "outlined",
233
+ color: "primary",
234
+ sx: { mr: 2 },
235
+ children: "Close"
236
+ }
237
+ ),
238
+ /* @__PURE__ */ jsx(
239
+ Button,
240
+ {
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"
247
+ }
248
+ )
249
+ ]
250
+ }
251
+ ) })
252
+ ]
253
+ }
254
+ );
187
255
  }
188
256
  var SendBackDialog_default = SendBackDialog;
189
257
  function ApproveDialog({ openModal, closeModal, header, workflowLogId, statusId }) {
@@ -354,16 +422,297 @@ function OnHoldDialog({ openModal, closeModal, header, workflowLogId, statusId }
354
422
  ] });
355
423
  }
356
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,
466
+ {
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(
483
+ Box$1,
484
+ {
485
+ sx: {
486
+ position: "relative",
487
+ display: "flex",
488
+ justifyContent: "center",
489
+ alignItems: "center"
490
+ },
491
+ 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,
508
+ {
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
+ }
518
+ }
519
+ ),
520
+ /* @__PURE__ */ jsx(
521
+ Card,
522
+ {
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,
625
+ {
626
+ variant: "body2",
627
+ 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
648
+ }
649
+ )
650
+ ] })
651
+ }
652
+ )
653
+ ]
654
+ },
655
+ index
656
+ );
657
+ })
658
+ },
659
+ rowIndex
660
+ );
661
+ }) });
662
+ }
663
+ var useDebounce = (value, delay) => {
664
+ const [debouncedValue, setDebouncedValue] = useState(value);
665
+ useEffect(() => {
666
+ const timeoutId = setTimeout(() => {
667
+ setDebouncedValue(value);
668
+ }, delay);
669
+ return () => clearTimeout(timeoutId);
670
+ }, [value, delay]);
671
+ return debouncedValue;
672
+ };
673
+ var useDebounce_default = useDebounce;
674
+ var SearchBox = ({
675
+ placeHolderTitle,
676
+ searchText,
677
+ handleClearSearch,
678
+ handleInputChange
679
+ }) => {
680
+ return /* @__PURE__ */ jsx(Box$1, { sx: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx(
681
+ TextField,
682
+ {
683
+ variant: "outlined",
684
+ value: searchText,
685
+ onChange: handleInputChange,
686
+ placeholder: placeHolderTitle,
687
+ autoComplete: "off",
688
+ className: "custom-search",
689
+ InputProps: {
690
+ startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx("span", { className: "icon-search-normal-1" }) }),
691
+ endAdornment: searchText ? /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
692
+ IconButton,
693
+ {
694
+ disableFocusRipple: true,
695
+ disableRipple: true,
696
+ disableTouchRipple: true,
697
+ onClick: handleClearSearch,
698
+ children: /* @__PURE__ */ jsx("span", { className: "icon-close-circle" })
699
+ }
700
+ ) }) : null
701
+ }
702
+ }
703
+ ) });
704
+ };
705
+ var SearchBox_default = SearchBox;
357
706
  var StyledChipProps = styled(Chip)(({ theme }) => {
358
- var _a, _b, _c, _d, _e, _f, _g;
707
+ var _a, _b, _c;
359
708
  return {
360
709
  "&.MuiChip-colorPrimary": {
361
710
  border: `1px solid ${theme.palette.primary.dark}`,
362
711
  borderRadius: "8px",
363
712
  height: "36px",
364
713
  padding: "6px 4px",
365
- background: `${(_b = (_a = theme.palette.customColors) == null ? void 0 : _a.customChipBackgroundColor) != null ? _b : "rgba(25,118,210,0.1)"}`,
366
- color: `${(_d = (_c = theme.palette.customColors) == null ? void 0 : _c.customChipColor) != null ? _d : theme.palette.primary.dark}`,
714
+ background: `${"rgba(25,118,210,0.1)"}`,
715
+ color: `${theme.palette.primary.dark}`,
367
716
  width: "170px",
368
717
  overflow: "hidden",
369
718
  whiteSpace: "nowrap",
@@ -375,7 +724,7 @@ var StyledChipProps = styled(Chip)(({ theme }) => {
375
724
  height: "36px",
376
725
  padding: "6px 4px",
377
726
  background: "none !important",
378
- color: `${(_g = (_f = (_e = theme.palette) == null ? void 0 : _e.customColors) == null ? void 0 : _f.mainText) != null ? _g : theme.palette.text.primary} `,
727
+ color: `${(_c = (_b = (_a = theme.palette) == null ? void 0 : _a.customColors) == null ? void 0 : _b.mainText) != null ? _c : theme.palette.text.primary} `,
379
728
  width: "170px",
380
729
  overflow: "hidden",
381
730
  whiteSpace: "nowrap",
@@ -383,19 +732,11 @@ var StyledChipProps = styled(Chip)(({ theme }) => {
383
732
  }
384
733
  };
385
734
  });
386
- var TruncatedTypography = styled(Typography)(({ theme }) => ({
387
- overflow: "hidden",
388
- textOverflow: "ellipsis",
389
- whiteSpace: "nowrap",
390
- width: "200px",
391
- [theme.breakpoints.down("sm")]: {
392
- width: "80px"
393
- }
394
- }));
395
735
  function ApprovalWorkflow({
396
736
  selectedWorkflowsList = [],
397
737
  userInfo
398
738
  }) {
739
+ var _a, _b, _c, _d, _e, _f, _g;
399
740
  const theme = useTheme$1();
400
741
  const { api, urlBuilder, loadingComponent } = useWorkflowContext();
401
742
  const [selectedApprovalOtions, setSelectedApprovalOtions] = useState(
@@ -407,12 +748,90 @@ function ApprovalWorkflow({
407
748
  const [rejectTarget, setRejectTarget] = React7.useState(null);
408
749
  const [onHoldTarget, setOnHoldTarget] = React7.useState(null);
409
750
  const [expandedDetails, setExpandedDetails] = useState([]);
410
- const [statusCount, setStatusCount] = useState({});
411
751
  const [urlConfig, setUrlConfig] = useState({});
412
752
  const [allRequestArray, setAllRequestArray] = useState([]);
413
753
  const [pendingRequestArray, setPendingRequestArray] = useState([]);
414
754
  const [selectedRequestArray, setSelectedRequestArray] = useState([]);
415
755
  const [isLoading, setIsLoading] = useState(false);
756
+ const [visibleAll, setVisibleAll] = useState(10);
757
+ const [visiblePending, setVisiblePending] = useState(10);
758
+ const [visibleSelected, setVisibleSelected] = useState(10);
759
+ const [searchText, setSearchText] = useState("");
760
+ const handleClearSearch = useCallback(() => {
761
+ setSearchText("");
762
+ }, []);
763
+ const handleSearchChange = useCallback((value) => {
764
+ setSearchText(value);
765
+ }, []);
766
+ const debouncedSearchTerm = useDebounce_default(searchText, 500);
767
+ const filteredSelectedRequestArray = React7.useMemo(() => {
768
+ if (!debouncedSearchTerm) return selectedRequestArray;
769
+ const q = debouncedSearchTerm.toLowerCase();
770
+ return selectedRequestArray.filter((item) => {
771
+ const name = ((item == null ? void 0 : item.activity_name) || "").toString().toLowerCase();
772
+ const desc = ((item == null ? void 0 : item.description_data) || "").toString().toLowerCase();
773
+ return name.includes(q) || desc.includes(q);
774
+ });
775
+ }, [selectedRequestArray, debouncedSearchTerm]);
776
+ const filteredAllRequestArray = React7.useMemo(() => {
777
+ if (!debouncedSearchTerm) return allRequestArray;
778
+ const q = debouncedSearchTerm.toLowerCase();
779
+ return allRequestArray.filter((item) => {
780
+ const name = ((item == null ? void 0 : item.activity_name) || "").toString().toLowerCase();
781
+ const desc = ((item == null ? void 0 : item.description_data) || "").toString().toLowerCase();
782
+ return name.includes(q) || desc.includes(q);
783
+ });
784
+ }, [allRequestArray, debouncedSearchTerm]);
785
+ const filteredPendingRequestArray = React7.useMemo(() => {
786
+ if (!debouncedSearchTerm) return pendingRequestArray;
787
+ const q = debouncedSearchTerm.toLowerCase();
788
+ return pendingRequestArray.filter((item) => {
789
+ const name = ((item == null ? void 0 : item.activity_name) || "").toString().toLowerCase();
790
+ const desc = ((item == null ? void 0 : item.description_data) || "").toString().toLowerCase();
791
+ return name.includes(q) || desc.includes(q);
792
+ });
793
+ }, [pendingRequestArray, debouncedSearchTerm]);
794
+ const observer = React7.useRef(null);
795
+ const lastCardRef = useCallback(
796
+ (node) => {
797
+ if (isLoading) return;
798
+ if (observer.current) observer.current.disconnect();
799
+ observer.current = new IntersectionObserver((entries) => {
800
+ if (entries[0].isIntersecting) {
801
+ if (selectedApprovalOtions === "All Requests") {
802
+ setVisibleAll((prev) => prev + 10);
803
+ } else if (selectedApprovalOtions === "Action Required") {
804
+ setVisiblePending((prev) => prev + 10);
805
+ } else if (selectedApprovalOtions === "selected") {
806
+ setVisibleSelected((prev) => prev + 10);
807
+ }
808
+ }
809
+ });
810
+ if (node) observer.current.observe(node);
811
+ },
812
+ [isLoading, selectedApprovalOtions]
813
+ );
814
+ const visibleAllRequests = filteredAllRequestArray.slice(0, visibleAll);
815
+ const visiblePendingRequests = filteredPendingRequestArray.slice(
816
+ 0,
817
+ visiblePending
818
+ );
819
+ const visibleSelectedRequests = filteredSelectedRequestArray.slice(
820
+ 0,
821
+ visibleSelected
822
+ );
823
+ const handleSendBack = (workflowLogId) => {
824
+ setSendDialog(workflowLogId);
825
+ };
826
+ const handleApprove = (workflowLogId) => {
827
+ setApproveTarget(workflowLogId);
828
+ };
829
+ const handleReject = (workflowLogId) => {
830
+ setRejectTarget(workflowLogId);
831
+ };
832
+ const handleOnHold = (workflowLogId) => {
833
+ setOnHoldTarget(workflowLogId);
834
+ };
416
835
  const handleProfileToggle = (option) => {
417
836
  setSelectedApprovalOtions(option);
418
837
  if (option === "Action Required") fetchPendingActivities();
@@ -423,75 +842,105 @@ function ApprovalWorkflow({
423
842
  setExpandedId((prevId) => prevId === id ? null : id);
424
843
  fetchExpandedActivityLogs(id);
425
844
  };
426
- const getStatus = (status) => {
427
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
428
- switch (status) {
845
+ const getStatus2 = (status) => {
846
+ switch (status.toLowerCase()) {
429
847
  case "approved":
430
848
  return {
431
849
  title: "Approved",
432
850
  color: theme.palette.success.light,
433
- labelColor: theme.palette.success.main
851
+ // e.g. light green background
852
+ labelColor: theme.palette.grey[100]
853
+ // e.g. light grey text
434
854
  };
435
855
  case "rejected":
436
856
  return {
437
857
  title: "Rejected",
438
- color: (_c = (_b = (_a = theme.palette) == null ? void 0 : _a.customColors) == null ? void 0 : _b.chipWarningContainer) != null ? _c : theme.palette.error.light,
439
- labelColor: theme.palette.error.main
858
+ color: theme.palette.error.light,
859
+ // light red background
860
+ labelColor: theme.palette.text.primary
861
+ // normal text color
440
862
  };
441
863
  case "onhold":
864
+ case "on_hold":
442
865
  return {
443
866
  title: "On Hold",
444
- color: (_f = (_e = (_d = theme.palette) == null ? void 0 : _d.customColors) == null ? void 0 : _e.chipPendingContainer) != null ? _f : theme.palette.warning.light,
445
- labelColor: (_i = (_h = (_g = theme.palette) == null ? void 0 : _g.customColors) == null ? void 0 : _h.chipPendingText) != null ? _i : theme.palette.warning.main
867
+ color: theme.palette.warning.light,
868
+ // soft amber background
869
+ labelColor: theme.palette.warning.main
870
+ // strong amber text
871
+ };
872
+ case "inprogress":
873
+ case "in_progress":
874
+ return {
875
+ title: "In Progress",
876
+ color: theme.palette.info.light,
877
+ // light blue background
878
+ labelColor: theme.palette.info.main
879
+ // blue text
446
880
  };
447
881
  case "pending":
448
882
  default:
449
883
  return {
450
884
  title: "Pending",
451
- color: (_l = (_k = (_j = theme.palette) == null ? void 0 : _j.customColors) == null ? void 0 : _k.approvalPrimaryChipBG) != null ? _l : theme.palette.info.light,
452
- labelColor: (_o = (_n = (_m = theme.palette) == null ? void 0 : _m.customColors) == null ? void 0 : _n.approvalPrimaryChipText) != null ? _o : theme.palette.info.main
885
+ color: theme.palette.grey[200],
886
+ // light grey background
887
+ labelColor: theme.palette.text.primary
888
+ // normal text color
453
889
  };
454
890
  }
455
891
  };
456
892
  const approvalChipLabel = [
457
- { label: "Action Required", icon: /* @__PURE__ */ jsx("span", { className: "icon-document-forward" }), count: (statusCount == null ? void 0 : statusCount.pending_activities_count) || "" },
458
- { label: "All Requests", icon: /* @__PURE__ */ jsx("span", { className: "icon-document-copy" }), count: (statusCount == null ? void 0 : statusCount.total_activities_count) || "" }
893
+ {
894
+ label: "Action Required",
895
+ icon: /* @__PURE__ */ jsx("span", { className: "icon-document-forward" }),
896
+ count: pendingRequestArray.length || ""
897
+ },
898
+ {
899
+ label: "All Requests",
900
+ icon: /* @__PURE__ */ jsx("span", { className: "icon-document-copy" }),
901
+ count: allRequestArray.length || ""
902
+ }
459
903
  ];
460
904
  const fetchExpandedActivityLogs = (workflowLogId) => {
461
905
  setExpandedDetails([]);
462
- api.get({ url: `/workflow/workflow-activity-logs/${workflowLogId}`, serviceURL: "api" }).then((res) => setExpandedDetails(res == null ? void 0 : res.data));
906
+ api.get({
907
+ url: `/workflow/workflow-activity-logs/${workflowLogId}`,
908
+ serviceURL: "api"
909
+ }).then((res) => setExpandedDetails(res == null ? void 0 : res.data));
463
910
  };
464
911
  const fetchPendingActivities = () => {
465
- var _a;
912
+ var _a2;
466
913
  setIsLoading(true);
467
- api.get({ url: `/workflow/activity-workflow/${(_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id}?paginate=false&type=pending`, serviceURL: "api" }).then((res) => {
468
- var _a2;
469
- return setPendingRequestArray((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.activities);
914
+ api.get({
915
+ url: `/workflow/activity-workflow/${(_a2 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a2.id}?paginate=false&type=pending`,
916
+ serviceURL: "api"
917
+ }).then((res) => {
918
+ var _a3;
919
+ return setPendingRequestArray((_a3 = res == null ? void 0 : res.data) == null ? void 0 : _a3.activities);
470
920
  }).finally(() => setIsLoading(false));
471
921
  };
472
922
  const fetchAllActivites = () => {
473
- var _a;
923
+ var _a2;
474
924
  setIsLoading(true);
475
- api.get({ url: `/workflow/activity-workflow/${(_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id}?paginate=false`, serviceURL: "api" }).then((res) => {
476
- var _a2;
477
- return setAllRequestArray((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.activities);
925
+ api.get({
926
+ url: `/workflow/activity-workflow/${(_a2 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a2.id}?paginate=false`,
927
+ serviceURL: "api"
928
+ }).then((res) => {
929
+ var _a3;
930
+ return setAllRequestArray((_a3 = res == null ? void 0 : res.data) == null ? void 0 : _a3.activities);
478
931
  }).finally(() => setIsLoading(false));
479
932
  };
480
933
  const fetchSelectedActivites = () => {
481
934
  setIsLoading(true);
482
- api.post({ url: `/workflow/bulk-details`, serviceURL: "api", data: { workflowIds: selectedWorkflowsList } }).then((res) => setSelectedRequestArray(res == null ? void 0 : res.data)).finally(() => setIsLoading(false));
483
- };
484
- const fetchStatusCount = () => {
485
- var _a;
486
- api.get({ url: `/workflow/status-count/${(_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id}`, serviceURL: "api" }).then((res) => {
487
- var _a2;
488
- setStatusCount((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2[0]);
489
- });
935
+ api.post({
936
+ url: `/workflow/bulk-details`,
937
+ serviceURL: "api",
938
+ data: { workflowIds: selectedWorkflowsList }
939
+ }).then((res) => setSelectedRequestArray(res == null ? void 0 : res.data)).finally(() => setIsLoading(false));
490
940
  };
491
941
  useEffect(() => {
492
942
  if (!sendDialog && !approveTarget && !onHoldTarget && !rejectTarget) {
493
943
  fetchAllActivites();
494
- fetchStatusCount();
495
944
  fetchPendingActivities();
496
945
  setExpandedDetails([]);
497
946
  setExpandedId(null);
@@ -514,11 +963,18 @@ function ApprovalWorkflow({
514
963
  }, [selectedWorkflowsList]);
515
964
  const buildRedirectionUrl = (info) => {
516
965
  if (info == null ? void 0 : info.redirection_link) return info.redirection_link;
517
- if (urlBuilder) return urlBuilder(info == null ? void 0 : info.module_name, info == null ? void 0 : info.module_id, urlConfig, info == null ? void 0 : info.reference_id);
966
+ if (urlBuilder)
967
+ return urlBuilder(
968
+ info == null ? void 0 : info.module_name,
969
+ info == null ? void 0 : info.module_id,
970
+ urlConfig,
971
+ info == null ? void 0 : info.reference_id
972
+ );
518
973
  const ref = urlConfig == null ? void 0 : urlConfig[info == null ? void 0 : info.module_name];
519
974
  if ((ref == null ? void 0 : ref.base_url) && (ref == null ? void 0 : ref.sub_url)) {
520
975
  const qs = new URLSearchParams();
521
- if (info == null ? void 0 : info.reference_id) qs.set("reference_id", String(info == null ? void 0 : info.reference_id));
976
+ if (info == null ? void 0 : info.reference_id)
977
+ qs.set("reference_id", String(info == null ? void 0 : info.reference_id));
522
978
  if (info == null ? void 0 : info.module_name) qs.set("module_name", String(info == null ? void 0 : info.module_name));
523
979
  return `${ref.base_url}${ref.sub_url}${qs.toString() ? `?${qs.toString()}` : ""}`;
524
980
  }
@@ -526,516 +982,902 @@ function ApprovalWorkflow({
526
982
  };
527
983
  if (isLoading && loadingComponent) return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
528
984
  return /* @__PURE__ */ jsxs(Fragment, { children: [
529
- /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", flexWrap: "nowrap" }, children: /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", height: "100%" }, children: [
530
- /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: /* @__PURE__ */ jsxs(Box, { sx: { mt: 2, mb: 2 }, children: [
531
- (selectedWorkflowsList == null ? void 0 : selectedWorkflowsList.length) ? /* @__PURE__ */ jsx(Tooltip, { title: "Selected Workflows", children: /* @__PURE__ */ jsx(
532
- StyledChipProps,
533
- {
534
- label: "Selected",
535
- icon: /* @__PURE__ */ jsx("span", { className: "icon-eye" }),
536
- color: (selectedApprovalOtions == null ? void 0 : selectedApprovalOtions.includes("selected")) ? "primary" : "default",
537
- variant: "filled",
538
- sx: { mr: 4, mb: 4, "& .MuiChip-icon": { fontSize: "18px !important" } },
539
- onClick: () => handleProfileToggle("selected")
540
- }
541
- ) }) : "",
542
- approvalChipLabel.map(({ label, icon, count }, index) => /* @__PURE__ */ jsx(Tooltip, { title: `${count} ${label}`, children: /* @__PURE__ */ jsx(
543
- StyledChipProps,
544
- {
545
- label: `${count} ${label}`,
546
- icon,
547
- color: (selectedApprovalOtions == null ? void 0 : selectedApprovalOtions.includes(label)) ? "primary" : "default",
548
- variant: "filled",
549
- sx: { mr: 4, mb: 4, "& .MuiChip-icon": { fontSize: "18px !important" } },
550
- onClick: () => handleProfileToggle(label)
551
- }
552
- ) }, index))
553
- ] }) }),
554
- selectedApprovalOtions === "selected" && /* @__PURE__ */ jsx(Box, { className: "fixedModal", sx: { overflowY: "auto", height: "calc(100vh - 180px)" }, children: selectedRequestArray && selectedRequestArray.map((info, index) => {
555
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
556
- const currentLevel = info == null ? void 0 : info.levels.find((level_) => level_.id === (info == null ? void 0 : info.current_level));
557
- const statusList = currentLevel ? currentLevel.status_list : [];
558
- const statusByNum = (statusList || []).reduce((acc, s) => {
559
- if ((s == null ? void 0 : s.status) != null) acc[s.status] = s;
560
- return acc;
561
- }, {});
562
- const redir = buildRedirectionUrl(info);
563
- return /* @__PURE__ */ jsxs(React7.Fragment, { children: [
564
- /* @__PURE__ */ jsx(
565
- Card,
985
+ /* @__PURE__ */ jsx(
986
+ Box,
987
+ {
988
+ sx: { display: "flex", justifyContent: "center", flexWrap: "nowrap" },
989
+ children: /* @__PURE__ */ jsxs(Box, { sx: { width: "100%", height: "100%" }, children: [
990
+ /* @__PURE__ */ jsxs(
991
+ Box,
566
992
  {
567
993
  sx: {
568
- mb: 8,
569
- "&.MuiCard-root.MuiPaper-elevation": {
570
- boxShadow: "2px 2px 10px 0px #4C4E6426",
571
- padding: "20px",
572
- borderRadius: "10px"
573
- }
994
+ display: "flex",
995
+ justifyContent: "space-between",
996
+ alignItems: "center"
574
997
  },
575
- children: /* @__PURE__ */ jsxs(CardContent, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
576
- /* @__PURE__ */ jsxs(Box, { children: [
577
- /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(TruncatedTypography, { variant: "h6", color: "text.primary", sx: { textTransform: "capitalize", lineHeight: "22px" }, children: info.activity_name }) }),
578
- /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
579
- TruncatedTypography,
580
- {
581
- variant: "body2",
582
- color: "customColors.mainText",
583
- sx: { mt: "13px", textTransform: "capitalize", lineHeight: "15.4px" },
584
- children: info.description_data
585
- }
586
- ) })
587
- ] }),
588
- /* @__PURE__ */ jsxs(Box, { children: [
589
- /* @__PURE__ */ jsx(Tooltip, { title: "Links", children: /* @__PURE__ */ jsx(
590
- TruncatedTypography,
591
- {
592
- variant: "caption",
593
- color: "customColors.text3",
594
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
595
- children: "Links"
596
- }
597
- ) }),
598
- /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx("a", { href: redir, style: { cursor: "pointer", textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx(
599
- TruncatedTypography,
600
- {
601
- variant: "subtitle2",
602
- color: "primary.dark",
603
- sx: { mt: "13px", lineHeight: "15.4px" },
604
- children: redir
605
- }
606
- ) }) })
607
- ] }),
608
- /* @__PURE__ */ jsxs(Box, { children: [
609
- /* @__PURE__ */ jsx(Tooltip, { title: "Attachments", children: /* @__PURE__ */ jsx(
610
- TruncatedTypography,
611
- {
612
- variant: "caption",
613
- color: "customColors.text3",
614
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
615
- children: "Attachments"
616
- }
617
- ) }),
618
- ((_a = info == null ? void 0 : info.attachment_links) == null ? void 0 : _a.length) ? info == null ? void 0 : info.attachment_links.map((link, idx) => /* @__PURE__ */ jsx(Tooltip, { title: `Attachment ${idx + 1}`, children: /* @__PURE__ */ jsx("a", { href: link, style: { cursor: "pointer", textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx(
619
- TruncatedTypography,
620
- {
621
- variant: "subtitle2",
622
- color: "primary.dark",
623
- sx: { mt: "13px", textTransform: "capitalize", lineHeight: "15.4px" },
624
- children: link || "N/A"
625
- }
626
- ) }) }, idx)) : /* @__PURE__ */ jsx(Box, { sx: { display: "flex", mt: 2, justifyContent: "center", alignItems: "center", lineHeight: "15.4px" }, children: "N/A" })
627
- ] }),
628
- /* @__PURE__ */ jsxs(Box, { children: [
629
- /* @__PURE__ */ jsx(Tooltip, { title: "Date and Time", children: /* @__PURE__ */ jsx(
630
- TruncatedTypography,
631
- {
632
- variant: "caption",
633
- color: "customColors.text3",
634
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
635
- children: "TAT"
636
- }
637
- ) }),
638
- /* @__PURE__ */ jsx(Tooltip, { title: info.dateTime, children: /* @__PURE__ */ jsx(
639
- TruncatedTypography,
640
- {
641
- variant: "subtitle2",
642
- color: "customColors.mainText",
643
- sx: { mt: "13px", textTransform: "capitalize", lineHeight: "15.4px" },
644
- children: ((_c = (_b = info == null ? void 0 : info.levels) == null ? void 0 : _b.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _c.tat_expiry) ? moment((_e = (_d = info == null ? void 0 : info.levels) == null ? void 0 : _d.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _e.tat_expiry).utcOffset("UTC+05:30").format("DD/MM/YYYY HH:MM A") : "N/A"
645
- }
646
- ) })
647
- ] }),
648
- /* @__PURE__ */ jsxs(Box, { children: [
649
- /* @__PURE__ */ jsx(Tooltip, { title: "Current active level of Workflow", children: /* @__PURE__ */ jsx(
650
- TruncatedTypography,
651
- {
652
- variant: "caption",
653
- color: "customColors.text3",
654
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
655
- children: "Current Level"
656
- }
657
- ) }),
658
- /* @__PURE__ */ jsx(Box, { sx: { display: "flex", mt: 2, justifyContent: "center", alignItems: "center" }, children: (info == null ? void 0 : info.isLevelZero) ? "L0" : "L" + (((_g = (_f = info == null ? void 0 : info.levels) == null ? void 0 : _f.findIndex((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) != null ? _g : -1) + 1 || "") })
659
- ] }),
660
- /* @__PURE__ */ jsxs(Box, { sx: { mt: 2, display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
661
- /* @__PURE__ */ jsx(
662
- Chip,
998
+ children: [
999
+ /* @__PURE__ */ jsxs(Box, { sx: { mt: 2, mb: 2 }, children: [
1000
+ (selectedWorkflowsList == null ? void 0 : selectedWorkflowsList.length) ? /* @__PURE__ */ jsx(Tooltip, { title: "Selected Workflows", children: /* @__PURE__ */ jsx(
1001
+ StyledChipProps,
663
1002
  {
1003
+ label: "Selected",
1004
+ icon: /* @__PURE__ */ jsx("span", { className: "icon-eye" }),
1005
+ color: (selectedApprovalOtions == null ? void 0 : selectedApprovalOtions.includes("selected")) ? "primary" : "default",
664
1006
  variant: "filled",
665
1007
  sx: {
666
- backgroundColor: `${(_n = getStatus(
667
- ((_j = (_i = (_h = info == null ? void 0 : info.levels) == null ? void 0 : _h.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _i.selected_status) == null ? void 0 : _j.status_id) === 1 ? "approved" : ((_m = (_l = (_k = info == null ? void 0 : info.levels) == null ? void 0 : _k.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _l.selected_status) == null ? void 0 : _m.status_id) === 3 ? "rejected" : "pending"
668
- )) == null ? void 0 : _n.color} !important`,
669
- color: `${(_u = getStatus(
670
- ((_q = (_p = (_o = info == null ? void 0 : info.levels) == null ? void 0 : _o.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _p.selected_status) == null ? void 0 : _q.status_id) === 1 ? "approved" : ((_t = (_s = (_r = info == null ? void 0 : info.levels) == null ? void 0 : _r.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _s.selected_status) == null ? void 0 : _t.status_id) === 3 ? "rejected" : "pending"
671
- )) == null ? void 0 : _u.labelColor} !important`,
672
- height: "40px",
673
- padding: "8px",
674
- borderRadius: "100px !important",
675
- border: "0px !important",
676
- "& .MuiChip-label": {
677
- fontSize: "14px",
678
- lineHeight: "15.4px",
679
- fontWeight: "500",
680
- textTransform: "capitalize"
681
- }
1008
+ mr: 4,
1009
+ mb: 4,
1010
+ "& .MuiChip-icon": { fontSize: "18px !important" }
682
1011
  },
683
- label: `${((_x = (_w = (_v = info == null ? void 0 : info.levels) == null ? void 0 : _v.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _w.selected_status) == null ? void 0 : _x.status_id) === 2 || (info == null ? void 0 : info.isLevelZero) || !((_z = (_y = info == null ? void 0 : info.levels) == null ? void 0 : _y.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _z.selected_status) ? "pending" : (_C = (_B = (_A = info == null ? void 0 : info.levels) == null ? void 0 : _A.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _B.selected_status) == null ? void 0 : _C.name}`
1012
+ onClick: () => handleProfileToggle("selected")
684
1013
  }
685
- ),
686
- /* @__PURE__ */ jsx(Divider, { orientation: "vertical", sx: { ml: 5, borderColor: (_E = (_D = theme.palette) == null ? void 0 : _D.customColors) == null ? void 0 : _E.text4, height: "50px" } }),
687
- /* @__PURE__ */ jsx(
688
- IconButton,
1014
+ ) }) : "",
1015
+ approvalChipLabel.map(({ label, icon, count }, index) => /* @__PURE__ */ jsx(Tooltip, { title: `${count} ${label}`, children: /* @__PURE__ */ jsx(
1016
+ StyledChipProps,
689
1017
  {
690
- disableFocusRipple: true,
691
- disableRipple: true,
692
- color: "primary",
1018
+ label: `${count} ${label}`,
1019
+ icon,
1020
+ color: (selectedApprovalOtions == null ? void 0 : selectedApprovalOtions.includes(label)) ? "primary" : "default",
1021
+ variant: "filled",
693
1022
  sx: {
694
- ml: 5,
695
- background: (_H = (_G = (_F = theme.palette) == null ? void 0 : _F.customColors) == null ? void 0 : _G.primaryLightest) != null ? _H : "rgba(25,118,210,0.08)",
696
- boxShadow: "2px 2px 10px 0px #4C4E6426",
697
- "& span": { color: theme.palette.primary.dark }
1023
+ mr: 4,
1024
+ mb: 4,
1025
+ "& .MuiChip-icon": { fontSize: "18px !important" }
698
1026
  },
699
- onClick: () => handleExpandClick(info._id),
700
- children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
1027
+ onClick: () => handleProfileToggle(label)
701
1028
  }
702
- ),
703
- /* @__PURE__ */ jsx(Box, { sx: { ml: 5 }, children: /* @__PURE__ */ jsx(
704
- Statusselector_default,
705
- {
706
- onSendBack: () => setSendDialog(info._id),
707
- onApprove: () => {
708
- var _a2, _b2;
709
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[1]) == null ? void 0 : _a2.id) != null ? _b2 : "");
710
- setApproveTarget({ id: info._id, statusId: sid });
711
- },
712
- onReject: () => {
713
- var _a2, _b2;
714
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[3]) == null ? void 0 : _a2.id) != null ? _b2 : "");
715
- setRejectTarget({ id: info._id, statusId: sid });
716
- },
717
- onHold: () => {
718
- var _a2, _b2;
719
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[2]) == null ? void 0 : _a2.id) != null ? _b2 : "");
720
- setOnHoldTarget({ id: info._id, statusId: sid });
721
- },
722
- statusList
723
- }
724
- ) })
725
- ] })
726
- ] })
1029
+ ) }, index))
1030
+ ] }),
1031
+ /* @__PURE__ */ jsx(Box, { sx: { flexGrow: 1, maxWidth: 250, ml: "auto" }, children: /* @__PURE__ */ jsx(
1032
+ SearchBox_default,
1033
+ {
1034
+ placeHolderTitle: "Search",
1035
+ searchText,
1036
+ handleClearSearch,
1037
+ handleInputChange: (e) => handleSearchChange(e.target.value)
1038
+ }
1039
+ ) })
1040
+ ]
727
1041
  }
728
1042
  ),
729
- expandedId === info._id && /* @__PURE__ */ jsx(Grid, { container: true, xs: 12, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, sx: { transform: "translateX(3.9%)" }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(Box, { sx: { height: "200px", display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 40, sx: { color: theme.palette.primary.dark } }) }) : /* @__PURE__ */ jsx(Box, { sx: { pl: 2 }, children: expandedDetails == null ? void 0 : expandedDetails.map((item, idx) => {
730
- var _a2;
731
- return /* @__PURE__ */ jsxs(Box, { sx: { mb: 2 }, children: [
732
- /* @__PURE__ */ jsx(Typography, { variant: "caption", sx: { mr: 2 }, children: moment(item == null ? void 0 : item.created_at).format("DD-MM-YYYY HH:mm") }),
733
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", component: "span", children: [
734
- item == null ? void 0 : item.type,
735
- " - ",
736
- ((_a2 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _a2.comment) || "No Comments"
737
- ] })
738
- ] }, idx);
739
- }) }) }) })
740
- ] }, index);
741
- }) }),
742
- selectedApprovalOtions === "All Requests" && /* @__PURE__ */ jsx(Box, { className: "fixedModal", sx: { overflowY: "auto", height: "calc(100vh - 180px)" }, children: allRequestArray && allRequestArray.map((info, index) => {
743
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
744
- const currentLevel = info == null ? void 0 : info.levels.find((level_) => level_.id === (info == null ? void 0 : info.current_level));
745
- const statusList = currentLevel ? currentLevel.status_list : [];
746
- const statusByNum = (statusList || []).reduce((acc, s) => {
747
- if ((s == null ? void 0 : s.status) != null) acc[s.status] = s;
748
- return acc;
749
- }, {});
750
- const redir = buildRedirectionUrl(info);
751
- return /* @__PURE__ */ jsxs(React7.Fragment, { children: [
752
- /* @__PURE__ */ jsx(
753
- Card,
1043
+ selectedApprovalOtions === "selected" && /* @__PURE__ */ jsx(
1044
+ Box,
754
1045
  {
1046
+ className: "fixedModal",
755
1047
  sx: {
756
- mb: 8,
757
- "&.MuiCard-root.MuiPaper-elevation": {
758
- boxShadow: "2px 2px 10px 0px #4C4E6426",
759
- padding: "20px",
760
- borderRadius: "10px"
761
- }
1048
+ overflowY: "auto",
1049
+ height: "calc(100vh - 180px)",
1050
+ px: 2,
1051
+ pb: 3
762
1052
  },
763
- children: /* @__PURE__ */ jsxs(CardContent, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
764
- /* @__PURE__ */ jsxs(Box, { children: [
765
- /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(TruncatedTypography, { variant: "h6", color: "text.primary", sx: { textTransform: "capitalize", lineHeight: "22px" }, children: info.activity_name }) }),
766
- /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
767
- TruncatedTypography,
768
- {
769
- variant: "body2",
770
- color: "customColors.mainText",
771
- sx: { mt: "13px", textTransform: "capitalize", lineHeight: "15.4px" },
772
- children: info.description_data
773
- }
774
- ) })
775
- ] }),
776
- /* @__PURE__ */ jsxs(Box, { children: [
777
- /* @__PURE__ */ jsx(Tooltip, { title: "Links", children: /* @__PURE__ */ jsx(
778
- TruncatedTypography,
779
- {
780
- variant: "caption",
781
- color: "customColors.text3",
782
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
783
- children: "Links"
784
- }
785
- ) }),
786
- /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx("a", { href: redir, style: { cursor: "pointer", textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx(
787
- TruncatedTypography,
788
- {
789
- variant: "subtitle2",
790
- color: "primary.dark",
791
- sx: { mt: "13px", lineHeight: "15.4px" },
792
- children: redir
793
- }
794
- ) }) })
795
- ] }),
796
- /* @__PURE__ */ jsxs(Box, { children: [
797
- /* @__PURE__ */ jsx(Tooltip, { title: "Attachments", children: /* @__PURE__ */ jsx(
798
- TruncatedTypography,
799
- {
800
- variant: "caption",
801
- color: "customColors.text3",
802
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
803
- children: "Attachments"
804
- }
805
- ) }),
806
- ((_a = info == null ? void 0 : info.attachment_links) == null ? void 0 : _a.length) ? info == null ? void 0 : info.attachment_links.map((link, idx) => /* @__PURE__ */ jsx(Tooltip, { title: `Attachment ${idx + 1}`, children: /* @__PURE__ */ jsx("a", { href: link, style: { cursor: "pointer", textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx(
807
- TruncatedTypography,
808
- {
809
- variant: "subtitle2",
810
- color: "primary.dark",
811
- sx: { mt: "13px", textTransform: "capitalize", lineHeight: "15.4px" },
812
- children: link || "N/A"
813
- }
814
- ) }) }, idx)) : /* @__PURE__ */ jsx(Box, { sx: { display: "flex", mt: 2, justifyContent: "center", alignItems: "center", lineHeight: "15.4px" }, children: "N/A" })
815
- ] }),
816
- /* @__PURE__ */ jsxs(Box, { sx: { mt: 2, display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
817
- /* @__PURE__ */ jsx(
818
- Chip,
819
- {
820
- variant: "filled",
821
- sx: {
822
- backgroundColor: `${(_h = getStatus(
823
- ((_d = (_c = (_b = info == null ? void 0 : info.levels) == null ? void 0 : _b.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _c.selected_status) == null ? void 0 : _d.status_id) === 1 ? "approved" : ((_g = (_f = (_e = info == null ? void 0 : info.levels) == null ? void 0 : _e.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _f.selected_status) == null ? void 0 : _g.status_id) === 3 ? "rejected" : "pending"
824
- )) == null ? void 0 : _h.color} !important`,
825
- color: `${(_o = getStatus(
826
- ((_k = (_j = (_i = info == null ? void 0 : info.levels) == null ? void 0 : _i.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _j.selected_status) == null ? void 0 : _k.status_id) === 1 ? "approved" : ((_n = (_m = (_l = info == null ? void 0 : info.levels) == null ? void 0 : _l.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _m.selected_status) == null ? void 0 : _n.status_id) === 3 ? "rejected" : "pending"
827
- )) == null ? void 0 : _o.labelColor} !important`,
828
- height: "40px",
829
- padding: "8px",
830
- borderRadius: "100px !important",
831
- border: "0px !important",
832
- "& .MuiChip-label": {
833
- fontSize: "14px",
834
- lineHeight: "15.4px",
835
- fontWeight: "500",
836
- textTransform: "capitalize"
1053
+ children: visibleSelectedRequests == null ? void 0 : visibleSelectedRequests.map((info, index) => {
1054
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l, _m, _n, _o;
1055
+ const currentLevel = info == null ? void 0 : info.levels.find(
1056
+ (level_) => level_.id === (info == null ? void 0 : info.current_level)
1057
+ );
1058
+ const statusList = currentLevel ? currentLevel.status_list : [];
1059
+ (statusList || []).reduce(
1060
+ (acc, s) => {
1061
+ if ((s == null ? void 0 : s.status) != null) acc[s.status] = s;
1062
+ return acc;
1063
+ },
1064
+ {}
1065
+ );
1066
+ const redir = buildRedirectionUrl(info);
1067
+ const currentStatus = ((_c2 = (_b2 = (_a2 = info == null ? void 0 : info.levels) == null ? void 0 : _a2.find(
1068
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1069
+ )) == 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(
1070
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1071
+ )) == null ? void 0 : _e2.selected_status) == null ? void 0 : _f2.status_id) === 3 ? "rejected" : "pending";
1072
+ const statusData = getStatus2(currentStatus);
1073
+ return /* @__PURE__ */ jsxs(
1074
+ Card,
1075
+ {
1076
+ ref: index === visibleSelectedRequests.length - 1 ? lastCardRef : null,
1077
+ sx: {
1078
+ mb: 3,
1079
+ borderRadius: "14px",
1080
+ boxShadow: "0px 2px 10px rgba(76, 78, 100, 0.1)",
1081
+ px: 3,
1082
+ py: 2
1083
+ },
1084
+ children: [
1085
+ /* @__PURE__ */ jsxs(
1086
+ CardContent,
1087
+ {
1088
+ sx: {
1089
+ display: "flex",
1090
+ justifyContent: "space-between",
1091
+ alignItems: "center",
1092
+ flexWrap: { xs: "wrap", md: "nowrap" },
1093
+ gap: 2
1094
+ },
1095
+ children: [
1096
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "22%", minWidth: 220 }, children: [
1097
+ /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(
1098
+ Typography,
1099
+ {
1100
+ variant: "h6",
1101
+ fontWeight: 600,
1102
+ noWrap: true,
1103
+ color: "text.primary",
1104
+ children: info.activity_name
1105
+ }
1106
+ ) }),
1107
+ /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
1108
+ Typography,
1109
+ {
1110
+ variant: "body2",
1111
+ color: "text.secondary",
1112
+ noWrap: true,
1113
+ sx: { mt: 0.5 },
1114
+ children: info.description_data
1115
+ }
1116
+ ) })
1117
+ ] }),
1118
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "20%", minWidth: 180 }, children: [
1119
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Links" }),
1120
+ /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx(
1121
+ Typography,
1122
+ {
1123
+ component: "a",
1124
+ href: redir,
1125
+ target: "_blank",
1126
+ rel: "noreferrer",
1127
+ sx: {
1128
+ display: "block",
1129
+ color: "primary.dark",
1130
+ fontWeight: 500,
1131
+ textDecoration: "none",
1132
+ overflow: "hidden",
1133
+ textOverflow: "ellipsis",
1134
+ whiteSpace: "nowrap",
1135
+ mt: 0.8
1136
+ },
1137
+ children: redir
1138
+ }
1139
+ ) })
1140
+ ] }),
1141
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "12%", minWidth: 120 }, children: [
1142
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Attachments" }),
1143
+ /* @__PURE__ */ jsx(
1144
+ Typography,
1145
+ {
1146
+ variant: "body2",
1147
+ noWrap: true,
1148
+ sx: {
1149
+ mt: 0.8,
1150
+ color: ((_g2 = info == null ? void 0 : info.attachment_links) == null ? void 0 : _g2.length) ? "primary.dark" : "text.disabled"
1151
+ },
1152
+ children: ((_h = info == null ? void 0 : info.attachment_links) == null ? void 0 : _h.length) ? `${info.attachment_links.length} file(s)` : "N/A"
1153
+ }
1154
+ )
1155
+ ] }),
1156
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "14%", minWidth: 130 }, children: [
1157
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "TAT" }),
1158
+ /* @__PURE__ */ jsx(
1159
+ Typography,
1160
+ {
1161
+ variant: "body2",
1162
+ sx: {
1163
+ mt: 0.8,
1164
+ fontWeight: 500,
1165
+ color: "text.primary"
1166
+ },
1167
+ 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"
1168
+ }
1169
+ )
1170
+ ] }),
1171
+ /* @__PURE__ */ jsxs(
1172
+ Box,
1173
+ {
1174
+ sx: {
1175
+ flexBasis: "8%",
1176
+ minWidth: 80,
1177
+ textAlign: "center"
1178
+ },
1179
+ children: [
1180
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Current Level" }),
1181
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { mt: 0.8 }, children: (info == null ? void 0 : info.isLevelZero) ? "L0" : "L" + (((_j = (_i = info == null ? void 0 : info.levels) == null ? void 0 : _i.findIndex(
1182
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1183
+ )) != null ? _j : -1) + 1 || "") })
1184
+ ]
1185
+ }
1186
+ ),
1187
+ /* @__PURE__ */ jsxs(
1188
+ Box,
1189
+ {
1190
+ sx: {
1191
+ flexBasis: "18%",
1192
+ minWidth: 200,
1193
+ display: "flex",
1194
+ alignItems: "center",
1195
+ justifyContent: "flex-end",
1196
+ gap: 1.5
1197
+ },
1198
+ children: [
1199
+ (info == null ? void 0 : info.current_status) !== "completed" && ((_l = (_k = info == null ? void 0 : info.levels) == null ? void 0 : _k.find(
1200
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1201
+ )) == null ? void 0 : _l.order) <= ((_n = (_m = info == null ? void 0 : info.levels) == null ? void 0 : _m.find(
1202
+ (lvl) => {
1203
+ var _a3;
1204
+ return Number(lvl.assign_to[0]) === ((_a3 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a3.id);
1205
+ }
1206
+ )) == null ? void 0 : _n.order) ? /* @__PURE__ */ jsx(
1207
+ Statusselector_default,
1208
+ {
1209
+ onSendBack: () => handleSendBack(info == null ? void 0 : info._id),
1210
+ onApprove: () => {
1211
+ var _a3;
1212
+ return handleApprove(
1213
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a3.id}`
1214
+ );
1215
+ },
1216
+ onReject: () => {
1217
+ var _a3;
1218
+ return handleReject(
1219
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 3)) == null ? void 0 : _a3.id}|${info == null ? void 0 : info.reasons}`
1220
+ );
1221
+ },
1222
+ onHold: () => {
1223
+ var _a3;
1224
+ return handleOnHold(
1225
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
1226
+ );
1227
+ },
1228
+ 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(
1229
+ (app) => app.status == 1
1230
+ ) : statusList
1231
+ }
1232
+ ) : /* @__PURE__ */ jsx(
1233
+ Chip,
1234
+ {
1235
+ variant: "filled",
1236
+ sx: {
1237
+ backgroundColor: getStatus2(currentStatus).color,
1238
+ color: getStatus2(currentStatus).labelColor,
1239
+ height: "40px",
1240
+ px: 2,
1241
+ borderRadius: "100px !important",
1242
+ "& .MuiChip-label": {
1243
+ fontSize: "14px",
1244
+ lineHeight: "15.4px",
1245
+ fontWeight: "500",
1246
+ textTransform: "capitalize"
1247
+ }
1248
+ },
1249
+ label: statusData.title
1250
+ }
1251
+ ),
1252
+ /* @__PURE__ */ jsx(
1253
+ Divider,
1254
+ {
1255
+ orientation: "vertical",
1256
+ flexItem: true,
1257
+ sx: {
1258
+ borderColor: "#E0E0E0",
1259
+ height: "40px"
1260
+ }
1261
+ }
1262
+ ),
1263
+ /* @__PURE__ */ jsx(
1264
+ IconButton,
1265
+ {
1266
+ disableFocusRipple: true,
1267
+ disableRipple: true,
1268
+ color: "primary",
1269
+ sx: {
1270
+ background: "rgba(25,118,210,0.08)",
1271
+ boxShadow: "2px 2px 10px 0px #4C4E6426",
1272
+ "& span": { color: "primary.dark" }
1273
+ },
1274
+ onClick: () => handleExpandClick(info._id),
1275
+ children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
1276
+ }
1277
+ )
1278
+ ]
1279
+ }
1280
+ )
1281
+ ]
837
1282
  }
838
- },
839
- label: `${((_r = (_q = (_p = info == null ? void 0 : info.levels) == null ? void 0 : _p.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _q.selected_status) == null ? void 0 : _r.status_id) === 2 || (info == null ? void 0 : info.isLevelZero) || !((_t = (_s = info == null ? void 0 : info.levels) == null ? void 0 : _s.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _t.selected_status) ? "pending" : (_w = (_v = (_u = info == null ? void 0 : info.levels) == null ? void 0 : _u.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _v.selected_status) == null ? void 0 : _w.name}`
840
- }
841
- ),
842
- /* @__PURE__ */ jsx(Divider, { orientation: "vertical", sx: { ml: 5, borderColor: (_y = (_x = theme.palette) == null ? void 0 : _x.customColors) == null ? void 0 : _y.text4, height: "50px" } }),
843
- /* @__PURE__ */ jsx(
844
- IconButton,
845
- {
846
- disableFocusRipple: true,
847
- disableRipple: true,
848
- color: "primary",
849
- sx: {
850
- ml: 5,
851
- background: (_B = (_A = (_z = theme.palette) == null ? void 0 : _z.customColors) == null ? void 0 : _A.primaryLightest) != null ? _B : "rgba(25,118,210,0.08)",
852
- boxShadow: "2px 2px 10px 0px #4C4E6426",
853
- "& span": { color: theme.palette.primary.dark }
854
- },
855
- onClick: () => handleExpandClick(info._id),
856
- children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
857
- }
858
- ),
859
- /* @__PURE__ */ jsx(Box, { sx: { ml: 5 }, children: /* @__PURE__ */ jsx(
860
- Statusselector_default,
861
- {
862
- onSendBack: () => setSendDialog(info._id),
863
- onApprove: () => {
864
- var _a2, _b2;
865
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[1]) == null ? void 0 : _a2.id) != null ? _b2 : "");
866
- setApproveTarget({ id: info._id, statusId: sid });
867
- },
868
- onReject: () => {
869
- var _a2, _b2;
870
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[3]) == null ? void 0 : _a2.id) != null ? _b2 : "");
871
- setRejectTarget({ id: info._id, statusId: sid });
872
- },
873
- onHold: () => {
874
- var _a2, _b2;
875
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[2]) == null ? void 0 : _a2.id) != null ? _b2 : "");
876
- setOnHoldTarget({ id: info._id, statusId: sid });
877
- },
878
- statusList
879
- }
880
- ) })
881
- ] })
882
- ] })
1283
+ ),
1284
+ expandedId === info._id && /* @__PURE__ */ jsx(Box, { sx: { mt: 2, ml: 2 }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(
1285
+ Box,
1286
+ {
1287
+ sx: {
1288
+ height: 150,
1289
+ display: "flex",
1290
+ justifyContent: "center",
1291
+ alignItems: "center"
1292
+ },
1293
+ children: /* @__PURE__ */ jsx(CircularProgress, { size: 36, color: "primary" })
1294
+ }
1295
+ ) : /* @__PURE__ */ jsx(
1296
+ ConnectedTimeline,
1297
+ {
1298
+ events: expandedDetails == null ? void 0 : expandedDetails.map((item) => {
1299
+ var _a3, _b3, _c3, _d3;
1300
+ return {
1301
+ date: moment(item == null ? void 0 : item.created_at).format(
1302
+ "DD-MM-YYYY"
1303
+ ),
1304
+ time: moment(item == null ? void 0 : item.created_at).format("HH:mm"),
1305
+ 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",
1306
+ subTitle: ((_c3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _c3.comment) || "No Comments",
1307
+ attachment: ((_d3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _d3.file) || null,
1308
+ count: (item == null ? void 0 : item.current_level) == "L0" ? "L0" : item == null ? void 0 : item.current_level_count,
1309
+ cardType: "card"
1310
+ };
1311
+ })
1312
+ }
1313
+ ) })
1314
+ ]
1315
+ },
1316
+ index
1317
+ );
1318
+ })
883
1319
  }
884
1320
  ),
885
- expandedId === info._id && /* @__PURE__ */ jsx(Grid, { container: true, xs: 12, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, sx: { transform: "translateX(3.9%)" }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(Box, { sx: { height: "200px", display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 40, sx: { color: theme.palette.primary.dark } }) }) : /* @__PURE__ */ jsx(Box, { sx: { pl: 2 }, children: expandedDetails == null ? void 0 : expandedDetails.map((item, idx) => {
886
- var _a2;
887
- return /* @__PURE__ */ jsxs(Box, { sx: { mb: 2 }, children: [
888
- /* @__PURE__ */ jsx(Typography, { variant: "caption", sx: { mr: 2 }, children: moment(item == null ? void 0 : item.created_at).format("DD-MM-YYYY HH:mm") }),
889
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", component: "span", children: [
890
- item == null ? void 0 : item.type,
891
- " - ",
892
- ((_a2 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _a2.comment) || "No Comments"
893
- ] })
894
- ] }, idx);
895
- }) }) }) })
896
- ] }, index);
897
- }) }),
898
- selectedApprovalOtions === "Action Required" && /* @__PURE__ */ jsx(Box, { className: "fixedModal", sx: { overflowY: "auto", height: "calc(100vh - 180px)" }, children: pendingRequestArray && pendingRequestArray.map((info, index) => {
899
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
900
- const currentLevel = (_a = info == null ? void 0 : info.levels) == null ? void 0 : _a.find((level_) => level_.id === (info == null ? void 0 : info.current_level));
901
- const statusList = currentLevel ? currentLevel.status_list : [];
902
- const statusByNum = (statusList || []).reduce((acc, s) => {
903
- if ((s == null ? void 0 : s.status) != null) acc[s.status] = s;
904
- return acc;
905
- }, {});
906
- const redir = buildRedirectionUrl(info);
907
- return /* @__PURE__ */ jsxs(React7.Fragment, { children: [
908
- /* @__PURE__ */ jsx(
909
- Card,
1321
+ selectedApprovalOtions === "All Requests" && /* @__PURE__ */ jsx(
1322
+ Box,
910
1323
  {
1324
+ className: "fixedModal",
911
1325
  sx: {
912
- mb: 8,
913
- "&.MuiCard-root.MuiPaper-elevation": {
914
- boxShadow: "2px 2px 10px 0px #4C4E6426",
915
- padding: "20px",
916
- borderRadius: "10px"
917
- }
1326
+ overflowY: "auto",
1327
+ height: "calc(100vh - 180px)",
1328
+ px: 2,
1329
+ pb: 3
918
1330
  },
919
- children: /* @__PURE__ */ jsxs(CardContent, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
920
- /* @__PURE__ */ jsxs(Box, { children: [
921
- /* @__PURE__ */ jsx(Tooltip, { title: info.title, children: /* @__PURE__ */ jsx(TruncatedTypography, { variant: "h6", color: "text.primary", sx: { textTransform: "capitalize", lineHeight: "22px" }, children: info.activity_name }) }),
922
- /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
923
- TruncatedTypography,
924
- {
925
- variant: "body2",
926
- color: "customColors.mainText",
927
- sx: { mt: "13px", textTransform: "capitalize", lineHeight: "15.4px" },
928
- children: info.description_data
929
- }
930
- ) })
931
- ] }),
932
- /* @__PURE__ */ jsxs(Box, { children: [
933
- /* @__PURE__ */ jsx(Tooltip, { title: "Links", children: /* @__PURE__ */ jsx(
934
- TruncatedTypography,
935
- {
936
- variant: "caption",
937
- color: "customColors.text3",
938
- sx: { textTransform: "capitalize", lineHeight: "13.2px" },
939
- children: "Links"
940
- }
941
- ) }),
942
- /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx("a", { href: redir, style: { cursor: "pointer", textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ jsx(
943
- TruncatedTypography,
944
- {
945
- variant: "subtitle2",
946
- color: "primary.dark",
947
- sx: { mt: "13px", lineHeight: "15.4px" },
948
- children: redir
949
- }
950
- ) }) })
951
- ] }),
952
- /* @__PURE__ */ jsxs(Box, { sx: { mt: 2, display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
953
- /* @__PURE__ */ jsx(
954
- Chip,
955
- {
956
- variant: "filled",
957
- sx: {
958
- backgroundColor: `${(_h = getStatus(
959
- ((_d = (_c = (_b = info == null ? void 0 : info.levels) == null ? void 0 : _b.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _c.selected_status) == null ? void 0 : _d.status_id) === 1 ? "approved" : ((_g = (_f = (_e = info == null ? void 0 : info.levels) == null ? void 0 : _e.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _f.selected_status) == null ? void 0 : _g.status_id) === 3 ? "rejected" : "pending"
960
- )) == null ? void 0 : _h.color} !important`,
961
- color: `${(_o = getStatus(
962
- ((_k = (_j = (_i = info == null ? void 0 : info.levels) == null ? void 0 : _i.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _j.selected_status) == null ? void 0 : _k.status_id) === 1 ? "approved" : ((_n = (_m = (_l = info == null ? void 0 : info.levels) == null ? void 0 : _l.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _m.selected_status) == null ? void 0 : _n.status_id) === 3 ? "rejected" : "pending"
963
- )) == null ? void 0 : _o.labelColor} !important`,
964
- height: "40px",
965
- padding: "8px",
966
- borderRadius: "100px !important",
967
- border: "0px !important",
968
- "& .MuiChip-label": {
969
- fontSize: "14px",
970
- lineHeight: "15.4px",
971
- fontWeight: "500",
972
- textTransform: "capitalize"
1331
+ children: visibleAllRequests == null ? void 0 : visibleAllRequests.map((info, index) => {
1332
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l, _m, _n, _o;
1333
+ const currentLevel = info == null ? void 0 : info.levels.find(
1334
+ (level_) => level_.id === (info == null ? void 0 : info.current_level)
1335
+ );
1336
+ const statusList = currentLevel ? currentLevel.status_list : [];
1337
+ (statusList || []).reduce(
1338
+ (acc, s) => {
1339
+ if ((s == null ? void 0 : s.status) != null) acc[s.status] = s;
1340
+ return acc;
1341
+ },
1342
+ {}
1343
+ );
1344
+ const redir = buildRedirectionUrl(info);
1345
+ const currentStatus = ((_c2 = (_b2 = (_a2 = info == null ? void 0 : info.levels) == null ? void 0 : _a2.find(
1346
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1347
+ )) == 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(
1348
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1349
+ )) == null ? void 0 : _e2.selected_status) == null ? void 0 : _f2.status_id) === 3 ? "rejected" : "pending";
1350
+ const statusData = getStatus2(currentStatus);
1351
+ return /* @__PURE__ */ jsxs(
1352
+ Card,
1353
+ {
1354
+ ref: index === visibleAllRequests.length - 1 ? lastCardRef : null,
1355
+ sx: {
1356
+ mb: 3,
1357
+ borderRadius: "14px",
1358
+ boxShadow: "0px 2px 10px rgba(76, 78, 100, 0.1)",
1359
+ px: 3,
1360
+ py: 2
1361
+ },
1362
+ children: [
1363
+ /* @__PURE__ */ jsxs(
1364
+ CardContent,
1365
+ {
1366
+ sx: {
1367
+ display: "flex",
1368
+ justifyContent: "space-between",
1369
+ alignItems: "center",
1370
+ flexWrap: { xs: "wrap", md: "nowrap" },
1371
+ gap: 2
1372
+ },
1373
+ children: [
1374
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "20%", minWidth: 220 }, children: [
1375
+ /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(
1376
+ Typography,
1377
+ {
1378
+ variant: "h6",
1379
+ fontWeight: 600,
1380
+ noWrap: true,
1381
+ color: "text.primary",
1382
+ children: info.activity_name
1383
+ }
1384
+ ) }),
1385
+ /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
1386
+ Typography,
1387
+ {
1388
+ variant: "body2",
1389
+ noWrap: true,
1390
+ sx: { mt: 0.5, color: "text.secondary" },
1391
+ children: info.description_data
1392
+ }
1393
+ ) })
1394
+ ] }),
1395
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "18%", minWidth: 180 }, children: [
1396
+ /* @__PURE__ */ jsx(
1397
+ Typography,
1398
+ {
1399
+ variant: "caption",
1400
+ color: "text.secondary",
1401
+ sx: { display: "block" },
1402
+ children: "Links"
1403
+ }
1404
+ ),
1405
+ /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx(
1406
+ Typography,
1407
+ {
1408
+ component: "a",
1409
+ href: redir,
1410
+ target: "_blank",
1411
+ rel: "noreferrer",
1412
+ sx: {
1413
+ display: "block",
1414
+ color: "primary.dark",
1415
+ fontWeight: 500,
1416
+ textDecoration: "none",
1417
+ overflow: "hidden",
1418
+ textOverflow: "ellipsis",
1419
+ whiteSpace: "nowrap",
1420
+ mt: 0.8
1421
+ },
1422
+ children: redir
1423
+ }
1424
+ ) })
1425
+ ] }),
1426
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "12%", minWidth: 120 }, children: [
1427
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Attachments" }),
1428
+ /* @__PURE__ */ jsx(
1429
+ Typography,
1430
+ {
1431
+ variant: "body2",
1432
+ noWrap: true,
1433
+ sx: {
1434
+ mt: 0.8,
1435
+ color: ((_g2 = info == null ? void 0 : info.attachment_links) == null ? void 0 : _g2.length) ? "primary.dark" : "text.disabled"
1436
+ },
1437
+ children: ((_h = info == null ? void 0 : info.attachment_links) == null ? void 0 : _h.length) ? `${info.attachment_links.length} file(s)` : "N/A"
1438
+ }
1439
+ )
1440
+ ] }),
1441
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "14%", minWidth: 130 }, children: [
1442
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "TAT" }),
1443
+ /* @__PURE__ */ jsx(
1444
+ Typography,
1445
+ {
1446
+ variant: "body2",
1447
+ sx: {
1448
+ mt: 0.8,
1449
+ fontWeight: 500,
1450
+ color: "text.primary"
1451
+ },
1452
+ 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"
1453
+ }
1454
+ )
1455
+ ] }),
1456
+ /* @__PURE__ */ jsxs(
1457
+ Box,
1458
+ {
1459
+ sx: {
1460
+ flexBasis: "8%",
1461
+ minWidth: 80,
1462
+ textAlign: "center"
1463
+ },
1464
+ children: [
1465
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Current Level" }),
1466
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { mt: 0.8 }, children: (info == null ? void 0 : info.isLevelZero) ? "L0" : "L" + (((_j = (_i = info == null ? void 0 : info.levels) == null ? void 0 : _i.findIndex(
1467
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1468
+ )) != null ? _j : -1) + 1 || "") })
1469
+ ]
1470
+ }
1471
+ ),
1472
+ /* @__PURE__ */ jsxs(
1473
+ Box,
1474
+ {
1475
+ sx: {
1476
+ flexBasis: "18%",
1477
+ minWidth: 200,
1478
+ display: "flex",
1479
+ alignItems: "center",
1480
+ justifyContent: "flex-end",
1481
+ gap: 1.5
1482
+ },
1483
+ children: [
1484
+ (info == null ? void 0 : info.current_status) !== "completed" && ((_l = (_k = info == null ? void 0 : info.levels) == null ? void 0 : _k.find(
1485
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1486
+ )) == null ? void 0 : _l.order) <= ((_n = (_m = info == null ? void 0 : info.levels) == null ? void 0 : _m.find(
1487
+ (lvl) => {
1488
+ var _a3;
1489
+ return Number(lvl.assign_to[0]) === ((_a3 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a3.id);
1490
+ }
1491
+ )) == null ? void 0 : _n.order) ? /* @__PURE__ */ jsx(
1492
+ Statusselector_default,
1493
+ {
1494
+ onSendBack: () => handleSendBack(info == null ? void 0 : info._id),
1495
+ onApprove: () => {
1496
+ var _a3;
1497
+ return handleApprove(
1498
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a3.id}`
1499
+ );
1500
+ },
1501
+ onReject: () => {
1502
+ var _a3;
1503
+ return handleReject(
1504
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 3)) == null ? void 0 : _a3.id}|${info == null ? void 0 : info.reasons}`
1505
+ );
1506
+ },
1507
+ onHold: () => {
1508
+ var _a3;
1509
+ return handleOnHold(
1510
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
1511
+ );
1512
+ },
1513
+ 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(
1514
+ (app) => app.status == 1
1515
+ ) : statusList
1516
+ }
1517
+ ) : /* @__PURE__ */ jsx(
1518
+ Chip,
1519
+ {
1520
+ variant: "filled",
1521
+ sx: {
1522
+ backgroundColor: getStatus2(currentStatus).color,
1523
+ color: getStatus2(currentStatus).labelColor,
1524
+ height: "40px",
1525
+ px: 2,
1526
+ borderRadius: "100px !important",
1527
+ "& .MuiChip-label": {
1528
+ fontSize: "14px",
1529
+ lineHeight: "15.4px",
1530
+ fontWeight: "500",
1531
+ textTransform: "capitalize"
1532
+ }
1533
+ },
1534
+ label: statusData.title
1535
+ }
1536
+ ),
1537
+ /* @__PURE__ */ jsx(
1538
+ Divider,
1539
+ {
1540
+ orientation: "vertical",
1541
+ flexItem: true,
1542
+ sx: {
1543
+ borderColor: "#E0E0E0",
1544
+ height: "40px"
1545
+ }
1546
+ }
1547
+ ),
1548
+ /* @__PURE__ */ jsx(
1549
+ IconButton,
1550
+ {
1551
+ disableFocusRipple: true,
1552
+ disableRipple: true,
1553
+ color: "primary",
1554
+ sx: {
1555
+ background: "rgba(25,118,210,0.08)",
1556
+ boxShadow: "2px 2px 10px 0px #4C4E6426",
1557
+ "& span": { color: "primary.dark" }
1558
+ },
1559
+ onClick: () => handleExpandClick(info._id),
1560
+ children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
1561
+ }
1562
+ )
1563
+ ]
1564
+ }
1565
+ )
1566
+ ]
973
1567
  }
974
- },
975
- label: `${((_r = (_q = (_p = info == null ? void 0 : info.levels) == null ? void 0 : _p.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _q.selected_status) == null ? void 0 : _r.status_id) === 2 || (info == null ? void 0 : info.isLevelZero) || !((_t = (_s = info == null ? void 0 : info.levels) == null ? void 0 : _s.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _t.selected_status) ? "pending" : (_w = (_v = (_u = info == null ? void 0 : info.levels) == null ? void 0 : _u.find((lvl) => lvl.id === (info == null ? void 0 : info.current_level))) == null ? void 0 : _v.selected_status) == null ? void 0 : _w.name}`
976
- }
977
- ),
978
- /* @__PURE__ */ jsx(Divider, { orientation: "vertical", sx: { ml: 5, borderColor: (_y = (_x = theme.palette) == null ? void 0 : _x.customColors) == null ? void 0 : _y.text4, height: "50px" } }),
979
- /* @__PURE__ */ jsx(
980
- IconButton,
981
- {
982
- disableFocusRipple: true,
983
- disableRipple: true,
984
- color: "primary",
985
- sx: {
986
- ml: 5,
987
- background: (_B = (_A = (_z = theme.palette) == null ? void 0 : _z.customColors) == null ? void 0 : _A.primaryLightest) != null ? _B : "rgba(25,118,210,0.08)",
988
- boxShadow: "2px 2px 10px 0px #4C4E6426",
989
- "& span": { color: theme.palette.primary.dark }
990
- },
991
- onClick: () => handleExpandClick(info._id),
992
- children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
993
- }
994
- ),
995
- /* @__PURE__ */ jsx(Box, { sx: { ml: 5 }, children: /* @__PURE__ */ jsx(
996
- Statusselector_default,
997
- {
998
- onSendBack: () => setSendDialog(info._id),
999
- onApprove: () => {
1000
- var _a2, _b2;
1001
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[1]) == null ? void 0 : _a2.id) != null ? _b2 : "");
1002
- setApproveTarget({ id: info._id, statusId: sid });
1003
- },
1004
- onReject: () => {
1005
- var _a2, _b2;
1006
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[3]) == null ? void 0 : _a2.id) != null ? _b2 : "");
1007
- setRejectTarget({ id: info._id, statusId: sid });
1008
- },
1009
- onHold: () => {
1010
- var _a2, _b2;
1011
- const sid = String((_b2 = (_a2 = statusByNum == null ? void 0 : statusByNum[2]) == null ? void 0 : _a2.id) != null ? _b2 : "");
1012
- setOnHoldTarget({ id: info._id, statusId: sid });
1013
- },
1014
- statusList
1015
- }
1016
- ) })
1017
- ] })
1018
- ] })
1568
+ ),
1569
+ expandedId === info._id && /* @__PURE__ */ jsx(Box, { sx: { mt: 2, ml: 2 }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(
1570
+ Box,
1571
+ {
1572
+ sx: {
1573
+ height: 150,
1574
+ display: "flex",
1575
+ justifyContent: "center",
1576
+ alignItems: "center"
1577
+ },
1578
+ children: /* @__PURE__ */ jsx(CircularProgress, { size: 36, color: "primary" })
1579
+ }
1580
+ ) : /* @__PURE__ */ jsx(
1581
+ ConnectedTimeline,
1582
+ {
1583
+ events: expandedDetails == null ? void 0 : expandedDetails.map((item) => {
1584
+ var _a3, _b3, _c3, _d3;
1585
+ return {
1586
+ date: moment(item == null ? void 0 : item.created_at).format(
1587
+ "DD-MM-YYYY"
1588
+ ),
1589
+ time: moment(item == null ? void 0 : item.created_at).format("HH:mm"),
1590
+ 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",
1591
+ subTitle: ((_c3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _c3.comment) || "No Comments",
1592
+ attachment: ((_d3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _d3.file) || null,
1593
+ count: (item == null ? void 0 : item.current_level) == "L0" ? "L0" : item == null ? void 0 : item.current_level_count,
1594
+ cardType: "card"
1595
+ };
1596
+ })
1597
+ }
1598
+ ) })
1599
+ ]
1600
+ },
1601
+ index
1602
+ );
1603
+ })
1019
1604
  }
1020
1605
  ),
1021
- expandedId === info._id && /* @__PURE__ */ jsx(Grid, { container: true, xs: 12, spacing: 5, children: /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, sx: { transform: "translateX(3.9%)" }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(Box, { sx: { height: "200px", display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx(CircularProgress, { size: 40, sx: { color: theme.palette.primary.dark } }) }) : /* @__PURE__ */ jsx(Box, { sx: { pl: 2 }, children: expandedDetails == null ? void 0 : expandedDetails.map((item, idx) => {
1022
- var _a2;
1023
- return /* @__PURE__ */ jsxs(Box, { sx: { mb: 2 }, children: [
1024
- /* @__PURE__ */ jsx(Typography, { variant: "caption", sx: { mr: 2 }, children: moment(item == null ? void 0 : item.created_at).format("DD-MM-YYYY HH:mm") }),
1025
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", component: "span", children: [
1026
- item == null ? void 0 : item.type,
1027
- " - ",
1028
- ((_a2 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _a2.comment) || "No Comments"
1029
- ] })
1030
- ] }, idx);
1031
- }) }) }) })
1032
- ] }, index);
1033
- }) })
1034
- ] }) }),
1035
- /* @__PURE__ */ jsx(SendBackDialog_default, { openModal: !!sendDialog, closeModal: () => setSendDialog(null), header: "Send Back", workflowLogId: sendDialog || "" }),
1036
- /* @__PURE__ */ jsx(ApproveDialog_default, { openModal: !!approveTarget, closeModal: () => setApproveTarget(null), header: "Approve", workflowLogId: (approveTarget == null ? void 0 : approveTarget.id) || "", statusId: (approveTarget == null ? void 0 : approveTarget.statusId) || "" }),
1037
- /* @__PURE__ */ jsx(RejectDialog_default, { openModal: !!rejectTarget, closeModal: () => setRejectTarget(null), header: "Reject", workflowLogId: (rejectTarget == null ? void 0 : rejectTarget.id) || "", statusId: (rejectTarget == null ? void 0 : rejectTarget.statusId) || "", rejection_reason_master: "workflow_reject_reason" }),
1038
- /* @__PURE__ */ jsx(OnHoldDialog_default, { openModal: !!onHoldTarget, closeModal: () => setOnHoldTarget(null), header: "On Hold", workflowLogId: (onHoldTarget == null ? void 0 : onHoldTarget.id) || "", statusId: (onHoldTarget == null ? void 0 : onHoldTarget.statusId) || "" })
1606
+ selectedApprovalOtions === "Action Required" && /* @__PURE__ */ jsx(
1607
+ Box,
1608
+ {
1609
+ className: "fixedModal",
1610
+ sx: {
1611
+ overflowY: "auto",
1612
+ height: "calc(100vh - 180px)",
1613
+ px: 2,
1614
+ pb: 3
1615
+ },
1616
+ children: visiblePendingRequests == null ? void 0 : visiblePendingRequests.map((info, index) => {
1617
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k, _l;
1618
+ const currentLevel = (_a2 = info == null ? void 0 : info.levels) == null ? void 0 : _a2.find(
1619
+ (level_) => level_.id === (info == null ? void 0 : info.current_level)
1620
+ );
1621
+ const statusList = currentLevel ? currentLevel.status_list : [];
1622
+ (statusList || []).reduce(
1623
+ (acc, s) => {
1624
+ if ((s == null ? void 0 : s.status) != null) acc[s.status] = s;
1625
+ return acc;
1626
+ },
1627
+ {}
1628
+ );
1629
+ const redir = buildRedirectionUrl(info);
1630
+ const currentStatus = ((_d2 = (_c2 = (_b2 = info == null ? void 0 : info.levels) == null ? void 0 : _b2.find(
1631
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1632
+ )) == 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(
1633
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1634
+ )) == null ? void 0 : _f2.selected_status) == null ? void 0 : _g2.status_id) === 3 ? "rejected" : "pending";
1635
+ const statusData = getStatus2(currentStatus);
1636
+ return /* @__PURE__ */ jsxs(
1637
+ Card,
1638
+ {
1639
+ ref: index === visiblePendingRequests.length - 1 ? lastCardRef : null,
1640
+ sx: {
1641
+ mb: 3,
1642
+ borderRadius: "14px",
1643
+ boxShadow: "0px 2px 10px rgba(76, 78, 100, 0.1)",
1644
+ px: 3,
1645
+ py: 2
1646
+ },
1647
+ children: [
1648
+ /* @__PURE__ */ jsxs(
1649
+ CardContent,
1650
+ {
1651
+ sx: {
1652
+ display: "flex",
1653
+ justifyContent: "space-between",
1654
+ alignItems: "center",
1655
+ flexWrap: { xs: "wrap", md: "nowrap" },
1656
+ gap: 2
1657
+ },
1658
+ children: [
1659
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "22%", minWidth: 220 }, children: [
1660
+ /* @__PURE__ */ jsx(Tooltip, { title: info.activityInstruction, children: /* @__PURE__ */ jsx(
1661
+ Typography,
1662
+ {
1663
+ variant: "h6",
1664
+ fontWeight: 600,
1665
+ noWrap: true,
1666
+ color: "text.primary",
1667
+ children: info.activity_name
1668
+ }
1669
+ ) }),
1670
+ /* @__PURE__ */ jsx(Tooltip, { title: info.description_data, children: /* @__PURE__ */ jsx(
1671
+ Typography,
1672
+ {
1673
+ variant: "body2",
1674
+ color: "text.secondary",
1675
+ noWrap: true,
1676
+ sx: { mt: 0.5 },
1677
+ children: info.description_data
1678
+ }
1679
+ ) })
1680
+ ] }),
1681
+ /* @__PURE__ */ jsxs(Box, { sx: { flexBasis: "20%", minWidth: 180 }, children: [
1682
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Links" }),
1683
+ /* @__PURE__ */ jsx(Tooltip, { title: redir, children: /* @__PURE__ */ jsx(
1684
+ Typography,
1685
+ {
1686
+ component: "a",
1687
+ href: redir,
1688
+ target: "_blank",
1689
+ rel: "noreferrer",
1690
+ sx: {
1691
+ display: "block",
1692
+ color: "primary.dark",
1693
+ fontWeight: 500,
1694
+ textDecoration: "none",
1695
+ overflow: "hidden",
1696
+ textOverflow: "ellipsis",
1697
+ whiteSpace: "nowrap",
1698
+ mt: 0.8
1699
+ },
1700
+ children: redir
1701
+ }
1702
+ ) })
1703
+ ] }),
1704
+ /* @__PURE__ */ jsxs(
1705
+ Box,
1706
+ {
1707
+ sx: {
1708
+ flexBasis: "18%",
1709
+ minWidth: 200,
1710
+ display: "flex",
1711
+ alignItems: "center",
1712
+ justifyContent: "flex-end",
1713
+ gap: 1.5
1714
+ },
1715
+ children: [
1716
+ (info == null ? void 0 : info.current_status) !== "completed" && ((_i = (_h = info == null ? void 0 : info.levels) == null ? void 0 : _h.find(
1717
+ (lvl) => lvl.id === (info == null ? void 0 : info.current_level)
1718
+ )) == null ? void 0 : _i.order) <= ((_k = (_j = info == null ? void 0 : info.levels) == null ? void 0 : _j.find(
1719
+ (lvl) => {
1720
+ var _a3;
1721
+ return Number(lvl.assign_to[0]) === ((_a3 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a3.id);
1722
+ }
1723
+ )) == null ? void 0 : _k.order) ? /* @__PURE__ */ jsx(
1724
+ Statusselector_default,
1725
+ {
1726
+ onSendBack: () => handleSendBack(info == null ? void 0 : info._id),
1727
+ onApprove: () => {
1728
+ var _a3;
1729
+ return handleApprove(
1730
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a3.id}`
1731
+ );
1732
+ },
1733
+ onReject: () => {
1734
+ var _a3;
1735
+ return handleReject(
1736
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 3)) == null ? void 0 : _a3.id}|${info == null ? void 0 : info.reasons}`
1737
+ );
1738
+ },
1739
+ onHold: () => {
1740
+ var _a3;
1741
+ return handleOnHold(
1742
+ `${info == null ? void 0 : info._id}|${(_a3 = statusList.find((i) => i.status == 2)) == null ? void 0 : _a3.id}`
1743
+ );
1744
+ },
1745
+ statusList: (info == null ? void 0 : info.isLevelZero) && (info == null ? void 0 : info.created_by) === ((_l = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _l.id) ? statusList == null ? void 0 : statusList.filter(
1746
+ (app) => app.status == 1
1747
+ ) : statusList
1748
+ }
1749
+ ) : /* @__PURE__ */ jsx(
1750
+ Chip,
1751
+ {
1752
+ variant: "filled",
1753
+ sx: {
1754
+ backgroundColor: getStatus2(currentStatus).color,
1755
+ color: getStatus2(currentStatus).labelColor,
1756
+ height: "40px",
1757
+ px: 2,
1758
+ borderRadius: "100px !important",
1759
+ "& .MuiChip-label": {
1760
+ fontSize: "14px",
1761
+ lineHeight: "15.4px",
1762
+ fontWeight: "500",
1763
+ textTransform: "capitalize"
1764
+ }
1765
+ },
1766
+ label: statusData.title
1767
+ }
1768
+ ),
1769
+ /* @__PURE__ */ jsx(
1770
+ Divider,
1771
+ {
1772
+ orientation: "vertical",
1773
+ flexItem: true,
1774
+ sx: {
1775
+ borderColor: "#E0E0E0",
1776
+ height: "40px"
1777
+ }
1778
+ }
1779
+ ),
1780
+ /* @__PURE__ */ jsx(
1781
+ IconButton,
1782
+ {
1783
+ disableFocusRipple: true,
1784
+ disableRipple: true,
1785
+ color: "primary",
1786
+ sx: {
1787
+ background: "rgba(25,118,210,0.08)",
1788
+ boxShadow: "2px 2px 10px 0px #4C4E6426",
1789
+ "& span": { color: "primary.dark" }
1790
+ },
1791
+ onClick: () => handleExpandClick(info._id),
1792
+ children: expandedId === info._id ? /* @__PURE__ */ jsx("span", { className: "icon-arrow-down-1" }) : /* @__PURE__ */ jsx("span", { className: "icon-arrow-right-3" })
1793
+ }
1794
+ )
1795
+ ]
1796
+ }
1797
+ )
1798
+ ]
1799
+ }
1800
+ ),
1801
+ expandedId === info._id && /* @__PURE__ */ jsx(Box, { sx: { mt: 2, ml: 2 }, children: !(expandedDetails == null ? void 0 : expandedDetails.length) ? /* @__PURE__ */ jsx(
1802
+ Box,
1803
+ {
1804
+ sx: {
1805
+ height: 150,
1806
+ display: "flex",
1807
+ justifyContent: "center",
1808
+ alignItems: "center"
1809
+ },
1810
+ children: /* @__PURE__ */ jsx(CircularProgress, { size: 36, color: "primary" })
1811
+ }
1812
+ ) : /* @__PURE__ */ jsx(
1813
+ ConnectedTimeline,
1814
+ {
1815
+ events: expandedDetails == null ? void 0 : expandedDetails.map((item) => {
1816
+ var _a3, _b3, _c3, _d3;
1817
+ return {
1818
+ date: moment(item == null ? void 0 : item.created_at).format(
1819
+ "DD-MM-YYYY"
1820
+ ),
1821
+ time: moment(item == null ? void 0 : item.created_at).format("HH:mm"),
1822
+ 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",
1823
+ subTitle: ((_c3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _c3.comment) || "No Comments",
1824
+ attachment: ((_d3 = item == null ? void 0 : item.comment_reasons) == null ? void 0 : _d3.file) || null,
1825
+ count: (item == null ? void 0 : item.current_level) == "L0" ? "L0" : item == null ? void 0 : item.current_level_count,
1826
+ cardType: "card"
1827
+ };
1828
+ })
1829
+ }
1830
+ ) })
1831
+ ]
1832
+ },
1833
+ index
1834
+ );
1835
+ })
1836
+ }
1837
+ )
1838
+ ] })
1839
+ }
1840
+ ),
1841
+ /* @__PURE__ */ jsx(
1842
+ SendBackDialog_default,
1843
+ {
1844
+ openModal: !!sendDialog,
1845
+ closeModal: () => setSendDialog(null),
1846
+ header: "Send Back",
1847
+ workflowLogId: sendDialog || ""
1848
+ }
1849
+ ),
1850
+ /* @__PURE__ */ jsx(
1851
+ ApproveDialog_default,
1852
+ {
1853
+ openModal: !!approveTarget,
1854
+ closeModal: () => setApproveTarget(null),
1855
+ header: "Approve",
1856
+ workflowLogId: (_a = approveTarget == null ? void 0 : approveTarget.split("|")) == null ? void 0 : _a[0],
1857
+ statusId: (_b = approveTarget == null ? void 0 : approveTarget.split("|")) == null ? void 0 : _b[1]
1858
+ }
1859
+ ),
1860
+ /* @__PURE__ */ jsx(
1861
+ RejectDialog_default,
1862
+ {
1863
+ openModal: !!rejectTarget,
1864
+ closeModal: () => setRejectTarget(null),
1865
+ header: "Reject",
1866
+ workflowLogId: (_c = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _c[0],
1867
+ statusId: (_d = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _d[1],
1868
+ rejection_reason_master: (_e = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _e[2]
1869
+ }
1870
+ ),
1871
+ /* @__PURE__ */ jsx(
1872
+ OnHoldDialog_default,
1873
+ {
1874
+ openModal: !!onHoldTarget,
1875
+ closeModal: () => setOnHoldTarget(null),
1876
+ header: "On Hold",
1877
+ workflowLogId: (_f = onHoldTarget == null ? void 0 : onHoldTarget.split("|")) == null ? void 0 : _f[0],
1878
+ statusId: (_g = onHoldTarget == null ? void 0 : onHoldTarget.split("|")) == null ? void 0 : _g[1]
1879
+ }
1880
+ )
1039
1881
  ] });
1040
1882
  }
1041
1883
  function DialogOpener({