amp-workflow-ui 0.1.18 → 0.1.20

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
@@ -282,6 +282,7 @@ function WorkflowRequestCard({
282
282
  helpers
283
283
  }) {
284
284
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
285
+ console.log("\u{1F680} ~ WorkflowRequestCard ~ requestDetails:", requestDetails);
285
286
  const { timeLeftDHm, getStatus, buildRedirectionUrl } = helpers;
286
287
  const allCurrentAssignees = (_a = requestDetails == null ? void 0 : requestDetails.levels) == null ? void 0 : _a.map(
287
288
  (level) => {
@@ -298,7 +299,6 @@ function WorkflowRequestCard({
298
299
  const allAssignees = [
299
300
  .../* @__PURE__ */ new Set([...allCurrentAssignees, ...allCurrentEscalatedAssignees])
300
301
  ].filter((item) => item);
301
- console.log("\u{1F680} ~ WorkflowRequestCard ~ allAssignees:", allAssignees);
302
302
  const currentLevel = (_c = requestDetails == null ? void 0 : requestDetails.levels) == null ? void 0 : _c.find(
303
303
  (level_) => level_.id === (requestDetails == null ? void 0 : requestDetails.current_level)
304
304
  );
@@ -306,10 +306,6 @@ function WorkflowRequestCard({
306
306
  const currentlyEscaltedUserArray = (currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name) || [];
307
307
  const currentlyAssignedUser = (currentLevel == null ? void 0 : currentLevel.assign_to_name) ? currentLevel == null ? void 0 : currentLevel.assign_to_name[0] : "NA";
308
308
  const currentlyEscalatedUser = (currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name) ? currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name[0] : "NA";
309
- console.log(
310
- "\u{1F680} ~ WorkflowRequestCard ~ currentlyEscalatedUser:",
311
- currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name
312
- );
313
309
  const extraCurrentlyAssignedUserCount = currentlyAssignedUserArray.length - 1;
314
310
  const extraCurrentlyEscalatedUserCount = currentlyEscaltedUserArray.length - 1;
315
311
  const statusList = currentLevel ? currentLevel.status_list : [];
@@ -333,6 +329,7 @@ function WorkflowRequestCard({
333
329
  (lvl) => lvl.id === (requestDetails == null ? void 0 : requestDetails.current_level)
334
330
  )) != null ? _l : -1) + 1 || "");
335
331
  const tatExpired = timeLeftDHm(currentLevel == null ? void 0 : currentLevel.tat_expiry) === "0d: 0h: 0m";
332
+ const userDetails = userInfo == null ? void 0 : userInfo.userInfo;
336
333
  return /* @__PURE__ */ jsxs(
337
334
  Box,
338
335
  {
@@ -523,7 +520,7 @@ function WorkflowRequestCard({
523
520
  tatExpired ? currentlyEscalatedUser : currentlyAssignedUser
524
521
  ] })
525
522
  ] }),
526
- (requestDetails == null ? void 0 : requestDetails.current_status) !== "completed" ? /* @__PURE__ */ jsxs(Box, { className: "action-buttons", children: [
523
+ (requestDetails == null ? void 0 : requestDetails.current_status) !== "completed" && (userDetails == null ? void 0 : userDetails.id) !== (requestDetails == null ? void 0 : requestDetails.created_by) && !(requestDetails == null ? void 0 : requestDetails.isLevelZero) ? /* @__PURE__ */ jsxs(Box, { className: "action-buttons", children: [
527
524
  filterRejectForLevelZero(statusList, requestDetails).find(
528
525
  (list) => list.status == 3
529
526
  ) && /* @__PURE__ */ jsx(
@@ -565,7 +562,20 @@ function WorkflowRequestCard({
565
562
  children: "Approve"
566
563
  }
567
564
  )
568
- ] }) : /* @__PURE__ */ jsx(
565
+ ] }) : (requestDetails == null ? void 0 : requestDetails.isLevelZero) ? /* @__PURE__ */ jsx(
566
+ Button,
567
+ {
568
+ variant: "contained",
569
+ className: "btn-approve",
570
+ onClick: () => {
571
+ var _a2;
572
+ return handleApprove(
573
+ `${requestDetails == null ? void 0 : requestDetails._id}|${(_a2 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a2.id}`
574
+ );
575
+ },
576
+ children: "Approve"
577
+ }
578
+ ) : /* @__PURE__ */ jsx(
569
579
  WorkflowButton_default,
570
580
  {
571
581
  variant: currentStatus === "approved" ? "approved" : currentStatus === "rejected" ? "rejected" : "pending",
@@ -687,6 +697,7 @@ function SendBackDialog({
687
697
  },
688
698
  serviceURL: "api"
689
699
  });
700
+ console.log("\u{1F680} ~ onSubmit ~ res:", res);
690
701
  if ((res == null ? void 0 : res.status) === 200) {
691
702
  setSnackbar({
692
703
  open: true,
@@ -894,11 +905,18 @@ function ApproveDialog({
894
905
  created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
895
906
  },
896
907
  serviceURL: "api"
897
- });
898
- setSnackbar({
899
- open: true,
900
- message: "Approved successfully!",
901
- severity: "success"
908
+ }).then((res) => {
909
+ var _a2, _b2;
910
+ console.log("\u{1F680} ~ onSubmit ~ res:", res);
911
+ ((_a2 = res == null ? void 0 : res.error) == null ? void 0 : _a2.status) == 500 ? setSnackbar({
912
+ open: true,
913
+ message: ((_b2 = res == null ? void 0 : res.error) == null ? void 0 : _b2.message) || "Something unexpected occurred!",
914
+ severity: "error"
915
+ }) : setSnackbar({
916
+ open: true,
917
+ message: "Approved successfully!",
918
+ severity: "success"
919
+ });
902
920
  });
903
921
  } catch (e) {
904
922
  setSnackbar({
@@ -1094,11 +1112,18 @@ function RejectDialog({
1094
1112
  created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
1095
1113
  },
1096
1114
  serviceURL: "api"
1097
- });
1098
- setSnackbar({
1099
- open: true,
1100
- message: "Rejected successfully!",
1101
- severity: "success"
1115
+ }).then((res) => {
1116
+ var _a2;
1117
+ console.log("\u{1F680} ~ onSubmit ~ res:", res);
1118
+ (res == null ? void 0 : res.status) == 200 ? setSnackbar({
1119
+ open: true,
1120
+ message: "Rejected successfully!",
1121
+ severity: "success"
1122
+ }) : setSnackbar({
1123
+ open: true,
1124
+ message: ((_a2 = res == null ? void 0 : res.error) == null ? void 0 : _a2.message) || "Something unexpected occurred!",
1125
+ severity: "error"
1126
+ });
1102
1127
  });
1103
1128
  } catch (e) {
1104
1129
  const message = ((_c = (_b = e == null ? void 0 : e.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || "Something went wrong!";
@@ -1426,8 +1451,8 @@ var SearchBox = ({
1426
1451
  className: "custom-search",
1427
1452
  sx: {
1428
1453
  "& .MuiOutlinedInput-root": {
1429
- height: "38px",
1430
- borderRadius: "20px"
1454
+ height: "38px !important",
1455
+ borderRadius: "20px !important"
1431
1456
  }
1432
1457
  },
1433
1458
  InputProps: {
@@ -1796,7 +1821,6 @@ function ApprovalWorkflow({
1796
1821
  filters: null
1797
1822
  }
1798
1823
  });
1799
- console.log("\u{1F680} ~ ApprovalWorkflow ~ tabs:", tabs);
1800
1824
  const [searchText, setSearchText] = useState("");
1801
1825
  const debouncedSearchTerm = useDebounce_default(searchText, 500);
1802
1826
  useEffect(() => {
@@ -1883,7 +1907,6 @@ function ApprovalWorkflow({
1883
1907
  var _a2, _b2;
1884
1908
  if (!((_a2 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a2.id)) return;
1885
1909
  const currentFilters = filtersOverride || ((_b2 = tabs[tab]) == null ? void 0 : _b2.filters);
1886
- console.log("\u{1F680} ~ ApprovalWorkflow ~ currentFilters:", currentFilters);
1887
1910
  let filterQuery = "";
1888
1911
  if (currentFilters) {
1889
1912
  if (currentFilters.approvalType)
@@ -2092,6 +2115,27 @@ function ApprovalWorkflow({
2092
2115
  const m = totalMinutes % 60;
2093
2116
  return `${d}d: ${h}h: ${m}m`;
2094
2117
  }
2118
+ const callAllApi = () => {
2119
+ var _a2, _b2, _c2, _d2, _e2, _f2;
2120
+ fetchData(
2121
+ "Assign To Me",
2122
+ 1,
2123
+ (_a2 = tabs["Assign To Me"]) == null ? void 0 : _a2.search,
2124
+ (_b2 = tabs["Assign To Me"]) == null ? void 0 : _b2.filters
2125
+ );
2126
+ fetchData(
2127
+ "All Requests",
2128
+ 1,
2129
+ (_c2 = tabs["All Requests"]) == null ? void 0 : _c2.search,
2130
+ (_d2 = tabs["All Requests"]) == null ? void 0 : _d2.filters
2131
+ );
2132
+ fetchData(
2133
+ "Completed",
2134
+ 1,
2135
+ (_e2 = tabs["Completed"]) == null ? void 0 : _e2.search,
2136
+ (_f2 = tabs["Completed"]) == null ? void 0 : _f2.filters
2137
+ );
2138
+ };
2095
2139
  if (((_e = tabs[selectedOption]) == null ? void 0 : _e.loading) && ((_f = tabs[selectedOption]) == null ? void 0 : _f.page) === 1 && loadingComponent)
2096
2140
  return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
2097
2141
  console.info("LIBRARY RUNNING...");
@@ -2262,15 +2306,7 @@ function ApprovalWorkflow({
2262
2306
  closeModal: () => setSendDialog(null),
2263
2307
  header: "Send Back",
2264
2308
  workflowLogId: sendDialog || "",
2265
- onSuccess: () => {
2266
- var _a2, _b2;
2267
- return fetchData(
2268
- selectedOption,
2269
- 1,
2270
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2271
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2272
- );
2273
- }
2309
+ onSuccess: () => callAllApi()
2274
2310
  }
2275
2311
  ),
2276
2312
  /* @__PURE__ */ jsx(
@@ -2281,15 +2317,7 @@ function ApprovalWorkflow({
2281
2317
  header: "Approve",
2282
2318
  workflowLogId: (_m = approveTarget == null ? void 0 : approveTarget.split("|")) == null ? void 0 : _m[0],
2283
2319
  statusId: (_n = approveTarget == null ? void 0 : approveTarget.split("|")) == null ? void 0 : _n[1],
2284
- onSuccess: () => {
2285
- var _a2, _b2;
2286
- return fetchData(
2287
- selectedOption,
2288
- 1,
2289
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2290
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2291
- );
2292
- }
2320
+ onSuccess: () => callAllApi()
2293
2321
  }
2294
2322
  ),
2295
2323
  /* @__PURE__ */ jsx(
@@ -2301,15 +2329,7 @@ function ApprovalWorkflow({
2301
2329
  workflowLogId: (_o = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _o[0],
2302
2330
  statusId: (_p = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _p[1],
2303
2331
  rejection_reason_master: (_q = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _q[2],
2304
- onSuccess: () => {
2305
- var _a2, _b2;
2306
- return fetchData(
2307
- selectedOption,
2308
- 1,
2309
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2310
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2311
- );
2312
- }
2332
+ onSuccess: () => callAllApi()
2313
2333
  }
2314
2334
  ),
2315
2335
  /* @__PURE__ */ jsx(
@@ -2320,15 +2340,7 @@ function ApprovalWorkflow({
2320
2340
  header: "On Hold",
2321
2341
  workflowLogId: (_r = onHoldTarget == null ? void 0 : onHoldTarget.split("|")) == null ? void 0 : _r[0],
2322
2342
  statusId: (_s = onHoldTarget == null ? void 0 : onHoldTarget.split("|")) == null ? void 0 : _s[1],
2323
- onSuccess: () => {
2324
- var _a2, _b2;
2325
- return fetchData(
2326
- selectedOption,
2327
- 1,
2328
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2329
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2330
- );
2331
- }
2343
+ onSuccess: () => callAllApi()
2332
2344
  }
2333
2345
  ),
2334
2346
  /* @__PURE__ */ jsxs(