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.js CHANGED
@@ -296,6 +296,7 @@ function WorkflowRequestCard({
296
296
  helpers
297
297
  }) {
298
298
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
299
+ console.log("\u{1F680} ~ WorkflowRequestCard ~ requestDetails:", requestDetails);
299
300
  const { timeLeftDHm, getStatus, buildRedirectionUrl } = helpers;
300
301
  const allCurrentAssignees = (_a = requestDetails == null ? void 0 : requestDetails.levels) == null ? void 0 : _a.map(
301
302
  (level) => {
@@ -312,7 +313,6 @@ function WorkflowRequestCard({
312
313
  const allAssignees = [
313
314
  .../* @__PURE__ */ new Set([...allCurrentAssignees, ...allCurrentEscalatedAssignees])
314
315
  ].filter((item) => item);
315
- console.log("\u{1F680} ~ WorkflowRequestCard ~ allAssignees:", allAssignees);
316
316
  const currentLevel = (_c = requestDetails == null ? void 0 : requestDetails.levels) == null ? void 0 : _c.find(
317
317
  (level_) => level_.id === (requestDetails == null ? void 0 : requestDetails.current_level)
318
318
  );
@@ -320,10 +320,6 @@ function WorkflowRequestCard({
320
320
  const currentlyEscaltedUserArray = (currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name) || [];
321
321
  const currentlyAssignedUser = (currentLevel == null ? void 0 : currentLevel.assign_to_name) ? currentLevel == null ? void 0 : currentLevel.assign_to_name[0] : "NA";
322
322
  const currentlyEscalatedUser = (currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name) ? currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name[0] : "NA";
323
- console.log(
324
- "\u{1F680} ~ WorkflowRequestCard ~ currentlyEscalatedUser:",
325
- currentLevel == null ? void 0 : currentLevel.escalate_assign_to_name
326
- );
327
323
  const extraCurrentlyAssignedUserCount = currentlyAssignedUserArray.length - 1;
328
324
  const extraCurrentlyEscalatedUserCount = currentlyEscaltedUserArray.length - 1;
329
325
  const statusList = currentLevel ? currentLevel.status_list : [];
@@ -347,6 +343,7 @@ function WorkflowRequestCard({
347
343
  (lvl) => lvl.id === (requestDetails == null ? void 0 : requestDetails.current_level)
348
344
  )) != null ? _l : -1) + 1 || "");
349
345
  const tatExpired = timeLeftDHm(currentLevel == null ? void 0 : currentLevel.tat_expiry) === "0d: 0h: 0m";
346
+ const userDetails = userInfo == null ? void 0 : userInfo.userInfo;
350
347
  return /* @__PURE__ */ jsxRuntime.jsxs(
351
348
  material.Box,
352
349
  {
@@ -537,7 +534,7 @@ function WorkflowRequestCard({
537
534
  tatExpired ? currentlyEscalatedUser : currentlyAssignedUser
538
535
  ] })
539
536
  ] }),
540
- (requestDetails == null ? void 0 : requestDetails.current_status) !== "completed" ? /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { className: "action-buttons", children: [
537
+ (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__ */ jsxRuntime.jsxs(material.Box, { className: "action-buttons", children: [
541
538
  filterRejectForLevelZero(statusList, requestDetails).find(
542
539
  (list) => list.status == 3
543
540
  ) && /* @__PURE__ */ jsxRuntime.jsx(
@@ -579,7 +576,20 @@ function WorkflowRequestCard({
579
576
  children: "Approve"
580
577
  }
581
578
  )
582
- ] }) : /* @__PURE__ */ jsxRuntime.jsx(
579
+ ] }) : (requestDetails == null ? void 0 : requestDetails.isLevelZero) ? /* @__PURE__ */ jsxRuntime.jsx(
580
+ material.Button,
581
+ {
582
+ variant: "contained",
583
+ className: "btn-approve",
584
+ onClick: () => {
585
+ var _a2;
586
+ return handleApprove(
587
+ `${requestDetails == null ? void 0 : requestDetails._id}|${(_a2 = statusList.find((i) => i.status == 1)) == null ? void 0 : _a2.id}`
588
+ );
589
+ },
590
+ children: "Approve"
591
+ }
592
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
583
593
  WorkflowButton_default,
584
594
  {
585
595
  variant: currentStatus === "approved" ? "approved" : currentStatus === "rejected" ? "rejected" : "pending",
@@ -701,6 +711,7 @@ function SendBackDialog({
701
711
  },
702
712
  serviceURL: "api"
703
713
  });
714
+ console.log("\u{1F680} ~ onSubmit ~ res:", res);
704
715
  if ((res == null ? void 0 : res.status) === 200) {
705
716
  setSnackbar({
706
717
  open: true,
@@ -908,11 +919,18 @@ function ApproveDialog({
908
919
  created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
909
920
  },
910
921
  serviceURL: "api"
911
- });
912
- setSnackbar({
913
- open: true,
914
- message: "Approved successfully!",
915
- severity: "success"
922
+ }).then((res) => {
923
+ var _a2, _b2;
924
+ console.log("\u{1F680} ~ onSubmit ~ res:", res);
925
+ ((_a2 = res == null ? void 0 : res.error) == null ? void 0 : _a2.status) == 500 ? setSnackbar({
926
+ open: true,
927
+ message: ((_b2 = res == null ? void 0 : res.error) == null ? void 0 : _b2.message) || "Something unexpected occurred!",
928
+ severity: "error"
929
+ }) : setSnackbar({
930
+ open: true,
931
+ message: "Approved successfully!",
932
+ severity: "success"
933
+ });
916
934
  });
917
935
  } catch (e) {
918
936
  setSnackbar({
@@ -1108,11 +1126,18 @@ function RejectDialog({
1108
1126
  created_by: (_a = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a.id
1109
1127
  },
1110
1128
  serviceURL: "api"
1111
- });
1112
- setSnackbar({
1113
- open: true,
1114
- message: "Rejected successfully!",
1115
- severity: "success"
1129
+ }).then((res) => {
1130
+ var _a2;
1131
+ console.log("\u{1F680} ~ onSubmit ~ res:", res);
1132
+ (res == null ? void 0 : res.status) == 200 ? setSnackbar({
1133
+ open: true,
1134
+ message: "Rejected successfully!",
1135
+ severity: "success"
1136
+ }) : setSnackbar({
1137
+ open: true,
1138
+ message: ((_a2 = res == null ? void 0 : res.error) == null ? void 0 : _a2.message) || "Something unexpected occurred!",
1139
+ severity: "error"
1140
+ });
1116
1141
  });
1117
1142
  } catch (e) {
1118
1143
  const message = ((_c = (_b = e == null ? void 0 : e.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || "Something went wrong!";
@@ -1440,8 +1465,8 @@ var SearchBox = ({
1440
1465
  className: "custom-search",
1441
1466
  sx: {
1442
1467
  "& .MuiOutlinedInput-root": {
1443
- height: "38px",
1444
- borderRadius: "20px"
1468
+ height: "38px !important",
1469
+ borderRadius: "20px !important"
1445
1470
  }
1446
1471
  },
1447
1472
  InputProps: {
@@ -1810,7 +1835,6 @@ function ApprovalWorkflow({
1810
1835
  filters: null
1811
1836
  }
1812
1837
  });
1813
- console.log("\u{1F680} ~ ApprovalWorkflow ~ tabs:", tabs);
1814
1838
  const [searchText, setSearchText] = React7.useState("");
1815
1839
  const debouncedSearchTerm = useDebounce_default(searchText, 500);
1816
1840
  React7.useEffect(() => {
@@ -1897,7 +1921,6 @@ function ApprovalWorkflow({
1897
1921
  var _a2, _b2;
1898
1922
  if (!((_a2 = userInfo == null ? void 0 : userInfo.userInfo) == null ? void 0 : _a2.id)) return;
1899
1923
  const currentFilters = filtersOverride || ((_b2 = tabs[tab]) == null ? void 0 : _b2.filters);
1900
- console.log("\u{1F680} ~ ApprovalWorkflow ~ currentFilters:", currentFilters);
1901
1924
  let filterQuery = "";
1902
1925
  if (currentFilters) {
1903
1926
  if (currentFilters.approvalType)
@@ -2106,6 +2129,27 @@ function ApprovalWorkflow({
2106
2129
  const m = totalMinutes % 60;
2107
2130
  return `${d}d: ${h}h: ${m}m`;
2108
2131
  }
2132
+ const callAllApi = () => {
2133
+ var _a2, _b2, _c2, _d2, _e2, _f2;
2134
+ fetchData(
2135
+ "Assign To Me",
2136
+ 1,
2137
+ (_a2 = tabs["Assign To Me"]) == null ? void 0 : _a2.search,
2138
+ (_b2 = tabs["Assign To Me"]) == null ? void 0 : _b2.filters
2139
+ );
2140
+ fetchData(
2141
+ "All Requests",
2142
+ 1,
2143
+ (_c2 = tabs["All Requests"]) == null ? void 0 : _c2.search,
2144
+ (_d2 = tabs["All Requests"]) == null ? void 0 : _d2.filters
2145
+ );
2146
+ fetchData(
2147
+ "Completed",
2148
+ 1,
2149
+ (_e2 = tabs["Completed"]) == null ? void 0 : _e2.search,
2150
+ (_f2 = tabs["Completed"]) == null ? void 0 : _f2.filters
2151
+ );
2152
+ };
2109
2153
  if (((_e = tabs[selectedOption]) == null ? void 0 : _e.loading) && ((_f = tabs[selectedOption]) == null ? void 0 : _f.page) === 1 && loadingComponent)
2110
2154
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: loadingComponent });
2111
2155
  console.info("LIBRARY RUNNING...");
@@ -2276,15 +2320,7 @@ function ApprovalWorkflow({
2276
2320
  closeModal: () => setSendDialog(null),
2277
2321
  header: "Send Back",
2278
2322
  workflowLogId: sendDialog || "",
2279
- onSuccess: () => {
2280
- var _a2, _b2;
2281
- return fetchData(
2282
- selectedOption,
2283
- 1,
2284
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2285
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2286
- );
2287
- }
2323
+ onSuccess: () => callAllApi()
2288
2324
  }
2289
2325
  ),
2290
2326
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2295,15 +2331,7 @@ function ApprovalWorkflow({
2295
2331
  header: "Approve",
2296
2332
  workflowLogId: (_m = approveTarget == null ? void 0 : approveTarget.split("|")) == null ? void 0 : _m[0],
2297
2333
  statusId: (_n = approveTarget == null ? void 0 : approveTarget.split("|")) == null ? void 0 : _n[1],
2298
- onSuccess: () => {
2299
- var _a2, _b2;
2300
- return fetchData(
2301
- selectedOption,
2302
- 1,
2303
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2304
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2305
- );
2306
- }
2334
+ onSuccess: () => callAllApi()
2307
2335
  }
2308
2336
  ),
2309
2337
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2315,15 +2343,7 @@ function ApprovalWorkflow({
2315
2343
  workflowLogId: (_o = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _o[0],
2316
2344
  statusId: (_p = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _p[1],
2317
2345
  rejection_reason_master: (_q = rejectTarget == null ? void 0 : rejectTarget.split("|")) == null ? void 0 : _q[2],
2318
- onSuccess: () => {
2319
- var _a2, _b2;
2320
- return fetchData(
2321
- selectedOption,
2322
- 1,
2323
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2324
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2325
- );
2326
- }
2346
+ onSuccess: () => callAllApi()
2327
2347
  }
2328
2348
  ),
2329
2349
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2334,15 +2354,7 @@ function ApprovalWorkflow({
2334
2354
  header: "On Hold",
2335
2355
  workflowLogId: (_r = onHoldTarget == null ? void 0 : onHoldTarget.split("|")) == null ? void 0 : _r[0],
2336
2356
  statusId: (_s = onHoldTarget == null ? void 0 : onHoldTarget.split("|")) == null ? void 0 : _s[1],
2337
- onSuccess: () => {
2338
- var _a2, _b2;
2339
- return fetchData(
2340
- selectedOption,
2341
- 1,
2342
- (_a2 = tabs[selectedOption]) == null ? void 0 : _a2.search,
2343
- (_b2 = tabs[selectedOption]) == null ? void 0 : _b2.filters
2344
- );
2345
- }
2357
+ onSuccess: () => callAllApi()
2346
2358
  }
2347
2359
  ),
2348
2360
  /* @__PURE__ */ jsxRuntime.jsxs(