flowcore-fn 10.2.7 → 10.2.8

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.
@@ -52,8 +52,6 @@
52
52
  --fc-color-emerald-600: oklch(59.6% 0.145 163.225);
53
53
  --fc-color-emerald-700: oklch(50.8% 0.118 165.612);
54
54
  --fc-color-emerald-800: oklch(43.2% 0.095 166.913);
55
- --fc-color-teal-100: oklch(95.3% 0.051 180.801);
56
- --fc-color-teal-700: oklch(51.1% 0.096 186.391);
57
55
  --fc-color-cyan-200: oklch(91.7% 0.08 205.041);
58
56
  --fc-color-cyan-400: oklch(78.9% 0.154 211.53);
59
57
  --fc-color-cyan-500: oklch(71.5% 0.143 215.221);
@@ -1840,9 +1838,6 @@
1840
1838
  background-color: color-mix(in oklab, var(--fc-color-slate-900) 60%, transparent);
1841
1839
  }
1842
1840
  }
1843
- .fc\:bg-teal-100 {
1844
- background-color: var(--fc-color-teal-100);
1845
- }
1846
1841
  .fc\:bg-white {
1847
1842
  background-color: var(--fc-color-white);
1848
1843
  }
@@ -2487,9 +2482,6 @@
2487
2482
  .fc\:text-slate-900 {
2488
2483
  color: var(--fc-color-slate-900);
2489
2484
  }
2490
- .fc\:text-teal-700 {
2491
- color: var(--fc-color-teal-700);
2492
- }
2493
2485
  .fc\:text-white {
2494
2486
  color: var(--fc-color-white);
2495
2487
  }
package/dist/pkg-index.js CHANGED
@@ -18977,7 +18977,7 @@ var import_react101 = require("@remixicon/react");
18977
18977
  var import_react94 = __toESM(require("react"));
18978
18978
  var import_react95 = require("@remixicon/react");
18979
18979
  var import_jsx_runtime94 = require("react/jsx-runtime");
18980
- function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18980
+ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file, isSubmitting = false }) {
18981
18981
  (0, import_react94.useEffect)(() => {
18982
18982
  if (!isOpen) return;
18983
18983
  const handleKeyDown = (e) => {
@@ -19000,8 +19000,8 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
19000
19000
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-3", children: [
19001
19001
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "fc:w-10 fc:h-10 fc:bg-blue-50 fc:text-blue-600 fc:rounded-xl fc:flex fc:items-center fc:justify-center fc:shadow-inner", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react95.RiInboxArchiveLine, { size: 20 }) }),
19002
19002
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { children: [
19003
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("h3", { className: "fc:text-base fc:font-bold fc:text-slate-800", children: "Confirm Pool File" }),
19004
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("p", { className: "fc:text-xs fc:text-slate-500", children: "Claim file into your personal work queue" })
19003
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("h3", { className: "fc:text-base fc:font-bold fc:text-slate-800", children: "Claim Workflow Files" }),
19004
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("p", { className: "fc:text-xs fc:text-slate-500", children: "Claim unclaimed files for the selected step" })
19005
19005
  ] })
19006
19006
  ] }),
19007
19007
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
@@ -19009,6 +19009,7 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
19009
19009
  {
19010
19010
  type: "button",
19011
19011
  onClick: onClose,
19012
+ disabled: isSubmitting,
19012
19013
  className: "fc:text-slate-400 hover:fc:text-slate-600 hover:fc:bg-slate-100 fc:p-1.5 fc:rounded-full fc:transition-all",
19013
19014
  children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react95.RiCloseLine, { size: 20 })
19014
19015
  }
@@ -19018,9 +19019,11 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
19018
19019
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "fc:flex fc:items-start fc:gap-3 fc:p-3.5 fc:bg-blue-50/70 fc:border fc:border-blue-100 fc:rounded-2xl", children: [
19019
19020
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react95.RiAlertLine, { size: 20, className: "fc:text-blue-600 fc:shrink-0 fc:mt-0.5" }),
19020
19021
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "fc:text-xs fc:text-blue-900 fc:leading-relaxed", children: [
19021
- "Are you sure you want to pool this file? Once confirmed, this file will be locked from the common pool and assigned to your ",
19022
+ "Confirming will claim ",
19023
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("strong", { className: "fc:font-bold", children: "all unclaimed files" }),
19024
+ " for this workflow step and assign them to your ",
19022
19025
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("strong", { className: "fc:font-bold", children: "My Files" }),
19023
- " tab for processing."
19026
+ " queue."
19024
19027
  ] })
19025
19028
  ] }),
19026
19029
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "fc:bg-slate-50/80 fc:rounded-2xl fc:p-4 fc:border fc:border-slate-100 fc:space-y-2.5", children: [
@@ -19058,6 +19061,7 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
19058
19061
  {
19059
19062
  type: "button",
19060
19063
  onClick: onClose,
19064
+ disabled: isSubmitting,
19061
19065
  className: "fc:px-4 fc:py-2 fc:border fc:border-slate-200 fc:text-slate-600 hover:fc:bg-slate-100 fc:text-xs fc:font-bold fc:rounded-xl fc:transition-all",
19062
19066
  children: "Cancel"
19063
19067
  }
@@ -19066,11 +19070,12 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
19066
19070
  "button",
19067
19071
  {
19068
19072
  type: "button",
19069
- onClick: () => onConfirm(file),
19070
- className: "fc:px-5 fc:py-2 fc:bg-blue-600 hover:fc:bg-blue-700 fc:text-white fc:text-xs fc:font-bold fc:rounded-xl fc:shadow-md fc:shadow-blue-500/20 fc:transition-all fc:flex fc:items-center fc:gap-1.5",
19073
+ onClick: onConfirm,
19074
+ disabled: isSubmitting,
19075
+ className: "fc:px-5 fc:py-2 fc:bg-blue-600 hover:fc:bg-blue-700 fc:text-white fc:text-xs fc:font-bold fc:rounded-xl fc:shadow-md fc:shadow-blue-500/20 fc:transition-all fc:flex fc:items-center fc:gap-1.5 disabled:fc:cursor-not-allowed disabled:fc:opacity-60",
19071
19076
  children: [
19072
19077
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react95.RiCheckLine, { size: 16 }),
19073
- "Yes, Pool File"
19078
+ isSubmitting ? "Claiming..." : "Yes, Claim Files"
19074
19079
  ]
19075
19080
  }
19076
19081
  )
@@ -19348,12 +19353,99 @@ function ViewFileModal({ isOpen, onClose, file }) {
19348
19353
  }
19349
19354
 
19350
19355
  // src/components/inbox/InboxMain.jsx
19356
+ init_ApiEndpointsProvider();
19357
+ init_ApiServicepackage();
19351
19358
  var import_jsx_runtime97 = require("react/jsx-runtime");
19352
- var INBOX_ROLES = [
19353
- { name: "Reviewer", marker: "RV", step: "Scrutiny & Review", description: "Review applications and findings", color: "fc:bg-blue-100 fc:text-blue-700" },
19354
- { name: "Verifier", marker: "VF", step: "Document Verification", description: "Validate submitted documents", color: "fc:bg-teal-100 fc:text-teal-700" },
19355
- { name: "Approver", marker: "AP", step: "Final Approval", description: "Approve or return completed cases", color: "fc:bg-amber-100 fc:text-amber-700" }
19356
- ];
19359
+ var getInboxEndpoint = (resourceNames, actions) => {
19360
+ var _a, _b;
19361
+ const flowCore = ((_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) || {};
19362
+ const actionNames = Array.isArray(actions) ? actions : [actions];
19363
+ for (const resourceName of resourceNames) {
19364
+ const resource = flowCore[resourceName];
19365
+ for (const action of actionNames) {
19366
+ const actionName = action.charAt(0).toUpperCase() + action.slice(1);
19367
+ const endpoint2 = (_b = resource == null ? void 0 : resource[action]) != null ? _b : resource == null ? void 0 : resource[actionName];
19368
+ if (endpoint2) return endpoint2;
19369
+ }
19370
+ }
19371
+ return null;
19372
+ };
19373
+ var deriveAssignedStepsEndpoint = (filePoolEndpoint) => {
19374
+ if (typeof filePoolEndpoint !== "string") return null;
19375
+ const endpoint2 = filePoolEndpoint.trim().replace(/\/+$/, "").split("?")[0];
19376
+ const filePoolRoute = "/FilePool/GetUnclaimedFilesByWorkflowStepId";
19377
+ if (!endpoint2.endsWith(filePoolRoute)) return null;
19378
+ return `${endpoint2.slice(0, -filePoolRoute.length)}/WorkflowStepUserMapping/GetAssignedStepsByUser`;
19379
+ };
19380
+ var unwrapInboxRows = (response) => {
19381
+ var _a, _b, _c, _d, _e, _f, _g;
19382
+ const value = (_e = (_d = (_c = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) != null ? _c : (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.result) != null ? _d : response == null ? void 0 : response.data) != null ? _e : response;
19383
+ return Array.isArray(value) ? value : (_g = (_f = value == null ? void 0 : value.items) != null ? _f : value == null ? void 0 : value.records) != null ? _g : [];
19384
+ };
19385
+ var formatInboxDate = (value) => {
19386
+ if (!value) return "-";
19387
+ const date = new Date(value);
19388
+ return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleString("en-GB", {
19389
+ day: "2-digit",
19390
+ month: "short",
19391
+ year: "numeric",
19392
+ hour: "2-digit",
19393
+ minute: "2-digit"
19394
+ });
19395
+ };
19396
+ var normalizePoolFile = (file) => {
19397
+ 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;
19398
+ const taskInstanceId = (_a = file.taskInstanceId) != null ? _a : file.TaskInstanceId;
19399
+ const filePoolId = (_b = file.filePoolId) != null ? _b : file.FilePoolId;
19400
+ const businessEntity = (_c = file.businessEntityType) != null ? _c : file.BusinessEntityType;
19401
+ const businessEntityId = (_d = file.businessEntityId) != null ? _d : file.BusinessEntityId;
19402
+ return __spreadProps(__spreadValues({}, file), {
19403
+ fileId: filePoolId != null ? filePoolId : taskInstanceId,
19404
+ taskInstanceId,
19405
+ workflowStepId: (_e = file.workflowStepId) != null ? _e : file.WorkflowStepId,
19406
+ fileNumber: (_g = (_f = file.fileNumber) != null ? _f : file.applicationNumber) != null ? _g : `TASK-${taskInstanceId != null ? taskInstanceId : filePoolId}`,
19407
+ subject: (_i = (_h = file.subject) != null ? _h : businessEntityId ? `${businessEntity || "File"} #${businessEntityId}` : businessEntity) != null ? _i : `Workflow task ${taskInstanceId != null ? taskInstanceId : ""}`,
19408
+ workflowName: (_k = (_j = file.workflowName) != null ? _j : file.WorkflowName) != null ? _k : "-",
19409
+ department: (_l = file.department) != null ? _l : "-",
19410
+ applicant: (_m = file.applicant) != null ? _m : businessEntityId ? String(businessEntityId) : "-",
19411
+ category: (_p = (_o = (_n = file.category) != null ? _n : file.workflowTypeName) != null ? _o : file.WorkflowTypeName) != null ? _p : "-",
19412
+ financialYear: (_q = file.financialYear) != null ? _q : "-",
19413
+ sender: (_s = (_r = file.sender) != null ? _r : file.initiator) != null ? _s : "-",
19414
+ priority: (_t = file.priority) != null ? _t : "Medium",
19415
+ receivedDate: formatInboxDate((_v = (_u = file.addedOn) != null ? _u : file.createdAt) != null ? _v : file.receivedDate),
19416
+ dueDate: formatInboxDate(file.dueDate),
19417
+ slaStatus: (_w = file.slaStatus) != null ? _w : "-",
19418
+ status: "Available",
19419
+ assignedTo: "-",
19420
+ currentStep: (_x = file.stepName) != null ? _x : "-"
19421
+ });
19422
+ };
19423
+ var normalizeMyFile = (file) => {
19424
+ 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;
19425
+ const taskInstanceId = (_a = file.taskInstanceId) != null ? _a : file.TaskInstanceId;
19426
+ const businessEntityId = (_b = file.businessEntityId) != null ? _b : file.BusinessEntityId;
19427
+ const businessEntity = (_c = file.businessEntityType) != null ? _c : file.BusinessEntityType;
19428
+ return __spreadProps(__spreadValues({}, file), {
19429
+ fileId: (_d = taskInstanceId != null ? taskInstanceId : file.fileInstanceId) != null ? _d : file.FileInstanceId,
19430
+ taskInstanceId,
19431
+ workflowStepId: (_e = file.workflowStepId) != null ? _e : file.WorkflowStepId,
19432
+ fileNumber: (_g = (_f = file.fileNumber) != null ? _f : file.applicationNumber) != null ? _g : `TASK-${taskInstanceId != null ? taskInstanceId : ""}`,
19433
+ subject: (_i = (_h = file.subject) != null ? _h : businessEntityId ? `${businessEntity || "File"} #${businessEntityId}` : businessEntity) != null ? _i : `Workflow task ${taskInstanceId != null ? taskInstanceId : ""}`,
19434
+ workflowName: (_k = (_j = file.workflowName) != null ? _j : file.WorkflowName) != null ? _k : "-",
19435
+ department: (_l = file.department) != null ? _l : file.hierarchyNodeId ? `Node ${file.hierarchyNodeId}` : "-",
19436
+ applicant: (_m = file.applicant) != null ? _m : businessEntityId ? String(businessEntityId) : "-",
19437
+ category: (_p = (_o = (_n = file.category) != null ? _n : file.workflowTypeName) != null ? _o : file.WorkflowTypeName) != null ? _p : "-",
19438
+ financialYear: (_q = file.financialYear) != null ? _q : "-",
19439
+ sender: (_s = (_r = file.sender) != null ? _r : businessEntity) != null ? _s : "-",
19440
+ priority: (_t = file.priority) != null ? _t : "Medium",
19441
+ receivedDate: formatInboxDate((_u = file.createdAt) != null ? _u : file.receivedDate),
19442
+ dueDate: formatInboxDate(file.dueDate),
19443
+ slaStatus: (_v = file.slaStatus) != null ? _v : "-",
19444
+ status: (_x = (_w = file.fileStatus) != null ? _w : file.statusName) != null ? _x : "In Progress",
19445
+ assignedTo: "Pankaj Jain",
19446
+ currentStep: (_y = file.stepName) != null ? _y : "-"
19447
+ });
19448
+ };
19357
19449
  var INITIAL_FILE_POOL = [
19358
19450
  {
19359
19451
  fileId: 101,
@@ -19602,13 +19694,125 @@ var INITIAL_TOTAL_FILES = [
19602
19694
  ];
19603
19695
  function InboxMain() {
19604
19696
  const [activeTab, setActiveTab] = (0, import_react100.useState)("filePool");
19605
- const [activeRole, setActiveRole] = (0, import_react100.useState)("Reviewer");
19697
+ const [assignedSteps, setAssignedSteps] = (0, import_react100.useState)([]);
19698
+ const [activeWorkflowStepId, setActiveWorkflowStepId] = (0, import_react100.useState)(null);
19606
19699
  const [roleDropdownOpen, setRoleDropdownOpen] = (0, import_react100.useState)(false);
19607
19700
  const roleDropdownRef = (0, import_react100.useRef)(null);
19608
- const activeRoleDetails = INBOX_ROLES.find((role) => role.name === activeRole) || INBOX_ROLES[0];
19609
- const [filePoolFiles, setFilePoolFiles] = (0, import_react100.useState)(INITIAL_FILE_POOL);
19610
- const [myFiles, setMyFiles] = (0, import_react100.useState)(INITIAL_MY_FILES);
19701
+ const activeRoleDetails = assignedSteps.find(
19702
+ (step) => Number(step.workflowStepId) === Number(activeWorkflowStepId)
19703
+ );
19704
+ const activeRole = (activeRoleDetails == null ? void 0 : activeRoleDetails.stepName) || "No Assigned Step";
19705
+ const [filePoolFiles, setFilePoolFiles] = (0, import_react100.useState)([]);
19706
+ const [myFiles, setMyFiles] = (0, import_react100.useState)([]);
19611
19707
  const [totalFiles, setTotalFiles] = (0, import_react100.useState)(INITIAL_TOTAL_FILES);
19708
+ const [refreshKey, setRefreshKey] = (0, import_react100.useState)(0);
19709
+ (0, import_react100.useEffect)(() => {
19710
+ let isCurrent = true;
19711
+ const loadAssignedSteps = async () => {
19712
+ var _a, _b;
19713
+ try {
19714
+ const apiService2 = getApiService();
19715
+ const unclaimedFilesEndpoint = getInboxEndpoint(
19716
+ ["inbox", "Inbox", "filePool", "FilePool"],
19717
+ "getUnclaimedFilesByWorkflowStepId"
19718
+ );
19719
+ if (!unclaimedFilesEndpoint) {
19720
+ throw new Error("File Pool endpoint is not configured (flowCore.inbox.getUnclaimedFilesByWorkflowStepId).");
19721
+ }
19722
+ const configuredAssignedStepsEndpoint = getInboxEndpoint(
19723
+ ["inbox", "Inbox", "mapping", "Mapping", "workflowStepUserMapping", "WorkflowStepUserMapping", "workflowStep", "WorkFlowStep", "WorkflowStep"],
19724
+ "getAssignedStepsByUser"
19725
+ );
19726
+ const assignedStepsEndpoint = configuredAssignedStepsEndpoint || deriveAssignedStepsEndpoint(unclaimedFilesEndpoint);
19727
+ if (!assignedStepsEndpoint) throw new Error("Assigned workflow steps endpoint is not configured.");
19728
+ const assignedStepsResponse = await apiService2.post(assignedStepsEndpoint, {});
19729
+ const stepsById = /* @__PURE__ */ new Map();
19730
+ unwrapInboxRows(assignedStepsResponse).forEach((step) => {
19731
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
19732
+ const workflowStepId = Number((_a2 = step.workflowStepId) != null ? _a2 : step.WorkflowStepId);
19733
+ const isActiveMapping = (_b2 = step.isActiveMapping) != null ? _b2 : step.IsActiveMapping;
19734
+ const isReleased = (_c = step.isReleased) != null ? _c : step.IsReleased;
19735
+ if (!Number.isInteger(workflowStepId) || workflowStepId <= 0 || isActiveMapping === false || isReleased === true) return;
19736
+ stepsById.set(workflowStepId, __spreadProps(__spreadValues({}, step), {
19737
+ workflowStepId,
19738
+ stepName: (_e = (_d = step.stepName) != null ? _d : step.StepName) != null ? _e : `Workflow Step ${workflowStepId}`,
19739
+ stepCode: (_g = (_f = step.stepCode) != null ? _f : step.StepCode) != null ? _g : "",
19740
+ workflowName: (_i = (_h = step.workflowName) != null ? _h : step.WorkflowName) != null ? _i : ""
19741
+ }));
19742
+ });
19743
+ const nextAssignedSteps = [...stepsById.values()];
19744
+ if (!isCurrent) return;
19745
+ setAssignedSteps(nextAssignedSteps);
19746
+ setActiveWorkflowStepId(
19747
+ (currentStepId) => {
19748
+ var _a2, _b2;
19749
+ return nextAssignedSteps.some((step) => step.workflowStepId === Number(currentStepId)) ? Number(currentStepId) : (_b2 = (_a2 = nextAssignedSteps[0]) == null ? void 0 : _a2.workflowStepId) != null ? _b2 : null;
19750
+ }
19751
+ );
19752
+ } catch (error) {
19753
+ if (!isCurrent) return;
19754
+ setAssignedSteps([]);
19755
+ setActiveWorkflowStepId(null);
19756
+ await import_sweetalert229.default.fire(
19757
+ "Error",
19758
+ ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || (error == null ? void 0 : error.message) || "Unable to load assigned workflow steps.",
19759
+ "error"
19760
+ );
19761
+ }
19762
+ };
19763
+ loadAssignedSteps();
19764
+ return () => {
19765
+ isCurrent = false;
19766
+ };
19767
+ }, []);
19768
+ (0, import_react100.useEffect)(() => {
19769
+ let isCurrent = true;
19770
+ const loadStepFiles = async () => {
19771
+ var _a, _b;
19772
+ if (!activeWorkflowStepId) {
19773
+ setFilePoolFiles([]);
19774
+ setMyFiles([]);
19775
+ return;
19776
+ }
19777
+ try {
19778
+ const unclaimedFilesEndpoint = getInboxEndpoint(
19779
+ ["inbox", "Inbox", "filePool", "FilePool"],
19780
+ "getUnclaimedFilesByWorkflowStepId"
19781
+ );
19782
+ if (!unclaimedFilesEndpoint) {
19783
+ throw new Error("File Pool endpoint is not configured (flowCore.inbox.getUnclaimedFilesByWorkflowStepId).");
19784
+ }
19785
+ const myFilesEndpoint = getInboxEndpoint(
19786
+ ["inbox", "Inbox", "myFiles", "MyFiles"],
19787
+ ["getMyFilesList", "getList"]
19788
+ );
19789
+ if (!myFilesEndpoint) {
19790
+ throw new Error("My Files list endpoint is not configured (flowCore.inbox.getMyFilesList).");
19791
+ }
19792
+ const payload = { workflowStepId: Number(activeWorkflowStepId) };
19793
+ const [poolResponse, myFilesResponse] = await Promise.all([
19794
+ getApiService().post(unclaimedFilesEndpoint, payload),
19795
+ getApiService().post(myFilesEndpoint, payload)
19796
+ ]);
19797
+ if (!isCurrent) return;
19798
+ setFilePoolFiles(unwrapInboxRows(poolResponse).map(normalizePoolFile));
19799
+ setMyFiles(unwrapInboxRows(myFilesResponse).map(normalizeMyFile));
19800
+ } catch (error) {
19801
+ if (!isCurrent) return;
19802
+ setFilePoolFiles([]);
19803
+ setMyFiles([]);
19804
+ await import_sweetalert229.default.fire(
19805
+ "Error",
19806
+ ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || (error == null ? void 0 : error.message) || "Unable to load inbox files.",
19807
+ "error"
19808
+ );
19809
+ }
19810
+ };
19811
+ loadStepFiles();
19812
+ return () => {
19813
+ isCurrent = false;
19814
+ };
19815
+ }, [activeWorkflowStepId, refreshKey]);
19612
19816
  const [dynamicColumns, setDynamicColumns] = (0, import_react100.useState)([
19613
19817
  { key: "department", label: "Department", width: "190px", visible: true },
19614
19818
  { key: "applicant", label: "Applicant / Entity", width: "210px", visible: true },
@@ -19625,6 +19829,7 @@ function InboxMain() {
19625
19829
  const [sortDirection, setSortDirection] = (0, import_react100.useState)("asc");
19626
19830
  const [poolModalOpen, setPoolModalOpen] = (0, import_react100.useState)(false);
19627
19831
  const [selectedPoolFile, setSelectedPoolFile] = (0, import_react100.useState)(null);
19832
+ const [isClaimingPool, setIsClaimingPool] = (0, import_react100.useState)(false);
19628
19833
  const [actionModalOpen, setActionModalOpen] = (0, import_react100.useState)(false);
19629
19834
  const [selectedActionFile, setSelectedActionFile] = (0, import_react100.useState)(null);
19630
19835
  const [viewModalOpen, setViewModalOpen] = (0, import_react100.useState)(false);
@@ -19798,27 +20003,45 @@ function InboxMain() {
19798
20003
  setSelectedPoolFile(file);
19799
20004
  setPoolModalOpen(true);
19800
20005
  };
19801
- const handleConfirmPool = async (fileToPool) => {
19802
- setPoolModalOpen(false);
19803
- setFilePoolFiles((prev) => prev.filter((item) => item.fileId !== fileToPool.fileId));
19804
- const claimedFile = __spreadProps(__spreadValues({}, fileToPool), {
19805
- status: "In Progress",
19806
- assignedTo: "Pankaj Jain"
19807
- });
19808
- setMyFiles((prev) => [claimedFile, ...prev]);
19809
- setTotalFiles(
19810
- (prev) => prev.map(
19811
- (item) => item.fileId === fileToPool.fileId ? __spreadProps(__spreadValues({}, item), { status: "In Progress", assignedTo: "Pankaj Jain" }) : item
19812
- )
19813
- );
19814
- await import_sweetalert229.default.fire({
19815
- icon: "success",
19816
- title: "File Pooled Successfully!",
19817
- html: `File <strong>${fileToPool.fileNumber}</strong> has been moved to your <strong>My Files</strong> queue.`,
19818
- confirmButtonColor: "#2563eb",
19819
- timer: 3e3,
19820
- timerProgressBar: true
19821
- });
20006
+ const handleConfirmPool = async () => {
20007
+ var _a, _b;
20008
+ if (!activeWorkflowStepId) {
20009
+ await import_sweetalert229.default.fire("Error", "Select an assigned workflow step before claiming files.", "error");
20010
+ return;
20011
+ }
20012
+ setIsClaimingPool(true);
20013
+ try {
20014
+ const claimEndpoint = getInboxEndpoint(
20015
+ ["inbox", "Inbox", "filePool", "FilePool"],
20016
+ "claimUnclaimedFilesByWorkflowStepId"
20017
+ );
20018
+ if (!claimEndpoint) {
20019
+ throw new Error("Claim endpoint is not configured (flowCore.inbox.claimUnclaimedFilesByWorkflowStepId).");
20020
+ }
20021
+ await getApiService().post(claimEndpoint, {
20022
+ workflowStepId: Number(activeWorkflowStepId)
20023
+ });
20024
+ setPoolModalOpen(false);
20025
+ setSelectedPoolFile(null);
20026
+ setCurrentPage(1);
20027
+ setRefreshKey((previous) => previous + 1);
20028
+ await import_sweetalert229.default.fire({
20029
+ icon: "success",
20030
+ title: "Files Claimed",
20031
+ text: "Unclaimed files for this workflow step have been assigned to your My Files queue.",
20032
+ confirmButtonColor: "#2563eb",
20033
+ timer: 3e3,
20034
+ timerProgressBar: true
20035
+ });
20036
+ } catch (error) {
20037
+ await import_sweetalert229.default.fire(
20038
+ "Error",
20039
+ ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || (error == null ? void 0 : error.message) || "Unable to claim files.",
20040
+ "error"
20041
+ );
20042
+ } finally {
20043
+ setIsClaimingPool(false);
20044
+ }
19822
20045
  };
19823
20046
  const handleOpenTakeAction = (file) => {
19824
20047
  setSelectedActionFile(file);
@@ -19841,11 +20064,12 @@ function InboxMain() {
19841
20064
  };
19842
20065
  const handleRefresh = () => {
19843
20066
  setCurrentPage(1);
20067
+ setRefreshKey((previous) => previous + 1);
19844
20068
  import_sweetalert229.default.fire({
19845
20069
  toast: true,
19846
20070
  position: "top-end",
19847
- icon: "success",
19848
- title: "Inbox updated with latest records",
20071
+ icon: "info",
20072
+ title: "Refreshing inbox files",
19849
20073
  showConfirmButton: false,
19850
20074
  timer: 2e3
19851
20075
  });
@@ -19931,7 +20155,7 @@ function InboxMain() {
19931
20155
  ] }),
19932
20156
  /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-1.5 fc:mt-0.5", children: [
19933
20157
  /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:text-[10px] fc:text-slate-400 fc:font-medium", children: "Active Step:" }),
19934
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:text-[10px] fc:font-bold fc:text-indigo-600 fc:bg-indigo-50/80 fc:px-1.5 fc:py-0.2 fc:rounded", children: activeRoleDetails.step })
20158
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:text-[10px] fc:font-bold fc:text-indigo-600 fc:bg-indigo-50/80 fc:px-1.5 fc:py-0.2 fc:rounded", children: (activeRoleDetails == null ? void 0 : activeRoleDetails.stepName) || "-" })
19935
20159
  ] })
19936
20160
  ] }),
19937
20161
  roleDropdownOpen && /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
@@ -19943,30 +20167,39 @@ function InboxMain() {
19943
20167
  children: [
19944
20168
  /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "fc:flex fc:items-center fc:justify-between fc:border-b fc:border-slate-100 fc:px-3 fc:pb-2 fc:pt-1.5", children: [
19945
20169
  /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { className: "fc:text-xs fc:font-bold fc:text-slate-800", children: "Switch role" }) }),
19946
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:rounded-full fc:bg-slate-100 fc:px-2 fc:text-[9px] fc:font-bold fc:text-slate-500", children: "3 ROLES" })
20170
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("span", { className: "fc:rounded-full fc:bg-slate-100 fc:px-2 fc:text-[9px] fc:font-bold fc:text-slate-500", children: [
20171
+ assignedSteps.length,
20172
+ " STEPS"
20173
+ ] })
19947
20174
  ] }),
19948
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "fc:space-y-1 fc:pt-0.5", children: INBOX_ROLES.map((role) => /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
19949
- "button",
19950
- {
19951
- type: "button",
19952
- role: "menuitemradio",
19953
- "aria-checked": activeRole === role.name,
19954
- onClick: () => {
19955
- setActiveRole(role.name);
19956
- setRoleDropdownOpen(false);
20175
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "fc:space-y-1 fc:pt-0.5", children: assignedSteps.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { className: "fc:px-3 fc:py-3 fc:text-xs fc:text-slate-500", children: "No assigned workflow steps" }) : assignedSteps.map((step) => {
20176
+ const isSelected = Number(activeWorkflowStepId) === step.workflowStepId;
20177
+ const stepName = step.stepName || `Workflow Step ${step.workflowStepId}`;
20178
+ const marker = String(step.stepCode || stepName).trim().slice(0, 2).toUpperCase();
20179
+ return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
20180
+ "button",
20181
+ {
20182
+ type: "button",
20183
+ role: "menuitemradio",
20184
+ "aria-checked": isSelected,
20185
+ onClick: () => {
20186
+ setActiveWorkflowStepId(step.workflowStepId);
20187
+ setCurrentPage(1);
20188
+ setRoleDropdownOpen(false);
20189
+ },
20190
+ className: `fc:flex fc:w-full fc:items-center fc:gap-3 fc:rounded-xl fc:border fc:px-3 fc:py-3 fc:text-left fc:transition-colors ${isSelected ? "fc:border-blue-200 fc:bg-blue-50/80" : "fc:border-transparent fc:bg-white hover:fc:border-slate-200 hover:fc:bg-slate-50"}`,
20191
+ children: [
20192
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:flex fc:h-9 fc:w-9 fc:shrink-0 fc:items-center fc:justify-center fc:rounded-xl fc:bg-blue-100 fc:text-[10px] fc:font-extrabold fc:text-blue-700", children: marker }),
20193
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("span", { className: "fc:min-w-0 fc:flex-1", children: [
20194
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: `fc:block fc:text-xs fc:font-bold ${isSelected ? "fc:text-blue-800" : "fc:text-slate-800"}`, children: stepName }),
20195
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:mt-0.5 fc:block fc:text-[10px] fc:leading-4 fc:text-slate-500", children: step.workflowName || `Workflow Step ID ${step.workflowStepId}` })
20196
+ ] }),
20197
+ isSelected && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:shrink-0 fc:rounded-full fc:bg-blue-100 fc:px-2 fc:py-1 fc:text-[9px] fc:font-bold fc:text-blue-700", children: "Current" })
20198
+ ]
19957
20199
  },
19958
- className: `fc:flex fc:w-full fc:items-center fc:gap-3 fc:rounded-xl fc:border fc:px-3 fc:py-3 fc:text-left fc:transition-colors ${activeRole === role.name ? "fc:border-blue-200 fc:bg-blue-50/80" : "fc:border-transparent fc:bg-white hover:fc:border-slate-200 hover:fc:bg-slate-50"}`,
19959
- children: [
19960
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: `fc:flex fc:h-9 fc:w-9 fc:shrink-0 fc:items-center fc:justify-center fc:rounded-xl fc:text-[10px] fc:font-extrabold ${role.color}`, children: role.marker }),
19961
- /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("span", { className: "fc:min-w-0 fc:flex-1", children: [
19962
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: `fc:block fc:text-xs fc:font-bold ${activeRole === role.name ? "fc:text-blue-800" : "fc:text-slate-800"}`, children: role.name }),
19963
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:mt-0.5 fc:block fc:text-[10px] fc:leading-4 fc:text-slate-500", children: role.description })
19964
- ] }),
19965
- activeRole === role.name && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "fc:shrink-0 fc:rounded-full fc:bg-blue-100 fc:px-2 fc:py-1 fc:text-[9px] fc:font-bold fc:text-blue-700", children: "Current" })
19966
- ]
19967
- },
19968
- role.name
19969
- )) })
20200
+ step.workflowStepId
20201
+ );
20202
+ }) })
19970
20203
  ]
19971
20204
  }
19972
20205
  )
@@ -20625,7 +20858,9 @@ function InboxMain() {
20625
20858
  {
20626
20859
  isOpen: poolModalOpen,
20627
20860
  file: selectedPoolFile,
20861
+ isSubmitting: isClaimingPool,
20628
20862
  onClose: () => {
20863
+ if (isClaimingPool) return;
20629
20864
  setPoolModalOpen(false);
20630
20865
  setSelectedPoolFile(null);
20631
20866
  },
@@ -18839,7 +18839,7 @@ import {
18839
18839
  import React94, { useEffect as useEffect48 } from "react";
18840
18840
  import { RiInboxArchiveLine, RiCloseLine, RiAlertLine, RiCheckLine } from "@remixicon/react";
18841
18841
  import { jsx as jsx94, jsxs as jsxs93 } from "react/jsx-runtime";
18842
- function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18842
+ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file, isSubmitting = false }) {
18843
18843
  useEffect48(() => {
18844
18844
  if (!isOpen) return;
18845
18845
  const handleKeyDown = (e) => {
@@ -18862,8 +18862,8 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18862
18862
  /* @__PURE__ */ jsxs93("div", { className: "fc:flex fc:items-center fc:gap-3", children: [
18863
18863
  /* @__PURE__ */ jsx94("div", { className: "fc:w-10 fc:h-10 fc:bg-blue-50 fc:text-blue-600 fc:rounded-xl fc:flex fc:items-center fc:justify-center fc:shadow-inner", children: /* @__PURE__ */ jsx94(RiInboxArchiveLine, { size: 20 }) }),
18864
18864
  /* @__PURE__ */ jsxs93("div", { children: [
18865
- /* @__PURE__ */ jsx94("h3", { className: "fc:text-base fc:font-bold fc:text-slate-800", children: "Confirm Pool File" }),
18866
- /* @__PURE__ */ jsx94("p", { className: "fc:text-xs fc:text-slate-500", children: "Claim file into your personal work queue" })
18865
+ /* @__PURE__ */ jsx94("h3", { className: "fc:text-base fc:font-bold fc:text-slate-800", children: "Claim Workflow Files" }),
18866
+ /* @__PURE__ */ jsx94("p", { className: "fc:text-xs fc:text-slate-500", children: "Claim unclaimed files for the selected step" })
18867
18867
  ] })
18868
18868
  ] }),
18869
18869
  /* @__PURE__ */ jsx94(
@@ -18871,6 +18871,7 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18871
18871
  {
18872
18872
  type: "button",
18873
18873
  onClick: onClose,
18874
+ disabled: isSubmitting,
18874
18875
  className: "fc:text-slate-400 hover:fc:text-slate-600 hover:fc:bg-slate-100 fc:p-1.5 fc:rounded-full fc:transition-all",
18875
18876
  children: /* @__PURE__ */ jsx94(RiCloseLine, { size: 20 })
18876
18877
  }
@@ -18880,9 +18881,11 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18880
18881
  /* @__PURE__ */ jsxs93("div", { className: "fc:flex fc:items-start fc:gap-3 fc:p-3.5 fc:bg-blue-50/70 fc:border fc:border-blue-100 fc:rounded-2xl", children: [
18881
18882
  /* @__PURE__ */ jsx94(RiAlertLine, { size: 20, className: "fc:text-blue-600 fc:shrink-0 fc:mt-0.5" }),
18882
18883
  /* @__PURE__ */ jsxs93("div", { className: "fc:text-xs fc:text-blue-900 fc:leading-relaxed", children: [
18883
- "Are you sure you want to pool this file? Once confirmed, this file will be locked from the common pool and assigned to your ",
18884
+ "Confirming will claim ",
18885
+ /* @__PURE__ */ jsx94("strong", { className: "fc:font-bold", children: "all unclaimed files" }),
18886
+ " for this workflow step and assign them to your ",
18884
18887
  /* @__PURE__ */ jsx94("strong", { className: "fc:font-bold", children: "My Files" }),
18885
- " tab for processing."
18888
+ " queue."
18886
18889
  ] })
18887
18890
  ] }),
18888
18891
  /* @__PURE__ */ jsxs93("div", { className: "fc:bg-slate-50/80 fc:rounded-2xl fc:p-4 fc:border fc:border-slate-100 fc:space-y-2.5", children: [
@@ -18920,6 +18923,7 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18920
18923
  {
18921
18924
  type: "button",
18922
18925
  onClick: onClose,
18926
+ disabled: isSubmitting,
18923
18927
  className: "fc:px-4 fc:py-2 fc:border fc:border-slate-200 fc:text-slate-600 hover:fc:bg-slate-100 fc:text-xs fc:font-bold fc:rounded-xl fc:transition-all",
18924
18928
  children: "Cancel"
18925
18929
  }
@@ -18928,11 +18932,12 @@ function PoolConfirmationModal({ isOpen, onClose, onConfirm, file }) {
18928
18932
  "button",
18929
18933
  {
18930
18934
  type: "button",
18931
- onClick: () => onConfirm(file),
18932
- className: "fc:px-5 fc:py-2 fc:bg-blue-600 hover:fc:bg-blue-700 fc:text-white fc:text-xs fc:font-bold fc:rounded-xl fc:shadow-md fc:shadow-blue-500/20 fc:transition-all fc:flex fc:items-center fc:gap-1.5",
18935
+ onClick: onConfirm,
18936
+ disabled: isSubmitting,
18937
+ className: "fc:px-5 fc:py-2 fc:bg-blue-600 hover:fc:bg-blue-700 fc:text-white fc:text-xs fc:font-bold fc:rounded-xl fc:shadow-md fc:shadow-blue-500/20 fc:transition-all fc:flex fc:items-center fc:gap-1.5 disabled:fc:cursor-not-allowed disabled:fc:opacity-60",
18933
18938
  children: [
18934
18939
  /* @__PURE__ */ jsx94(RiCheckLine, { size: 16 }),
18935
- "Yes, Pool File"
18940
+ isSubmitting ? "Claiming..." : "Yes, Claim Files"
18936
18941
  ]
18937
18942
  }
18938
18943
  )
@@ -19211,11 +19216,96 @@ function ViewFileModal({ isOpen, onClose, file }) {
19211
19216
 
19212
19217
  // src/components/inbox/InboxMain.jsx
19213
19218
  import { jsx as jsx97, jsxs as jsxs96 } from "react/jsx-runtime";
19214
- var INBOX_ROLES = [
19215
- { name: "Reviewer", marker: "RV", step: "Scrutiny & Review", description: "Review applications and findings", color: "fc:bg-blue-100 fc:text-blue-700" },
19216
- { name: "Verifier", marker: "VF", step: "Document Verification", description: "Validate submitted documents", color: "fc:bg-teal-100 fc:text-teal-700" },
19217
- { name: "Approver", marker: "AP", step: "Final Approval", description: "Approve or return completed cases", color: "fc:bg-amber-100 fc:text-amber-700" }
19218
- ];
19219
+ var getInboxEndpoint = (resourceNames, actions) => {
19220
+ var _a, _b;
19221
+ const flowCore = ((_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) || {};
19222
+ const actionNames = Array.isArray(actions) ? actions : [actions];
19223
+ for (const resourceName of resourceNames) {
19224
+ const resource = flowCore[resourceName];
19225
+ for (const action of actionNames) {
19226
+ const actionName = action.charAt(0).toUpperCase() + action.slice(1);
19227
+ const endpoint2 = (_b = resource == null ? void 0 : resource[action]) != null ? _b : resource == null ? void 0 : resource[actionName];
19228
+ if (endpoint2) return endpoint2;
19229
+ }
19230
+ }
19231
+ return null;
19232
+ };
19233
+ var deriveAssignedStepsEndpoint = (filePoolEndpoint) => {
19234
+ if (typeof filePoolEndpoint !== "string") return null;
19235
+ const endpoint2 = filePoolEndpoint.trim().replace(/\/+$/, "").split("?")[0];
19236
+ const filePoolRoute = "/FilePool/GetUnclaimedFilesByWorkflowStepId";
19237
+ if (!endpoint2.endsWith(filePoolRoute)) return null;
19238
+ return `${endpoint2.slice(0, -filePoolRoute.length)}/WorkflowStepUserMapping/GetAssignedStepsByUser`;
19239
+ };
19240
+ var unwrapInboxRows = (response) => {
19241
+ var _a, _b, _c, _d, _e, _f, _g;
19242
+ const value = (_e = (_d = (_c = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) != null ? _c : (_b = response == null ? void 0 : response.data) == null ? void 0 : _b.result) != null ? _d : response == null ? void 0 : response.data) != null ? _e : response;
19243
+ return Array.isArray(value) ? value : (_g = (_f = value == null ? void 0 : value.items) != null ? _f : value == null ? void 0 : value.records) != null ? _g : [];
19244
+ };
19245
+ var formatInboxDate = (value) => {
19246
+ if (!value) return "-";
19247
+ const date = new Date(value);
19248
+ return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleString("en-GB", {
19249
+ day: "2-digit",
19250
+ month: "short",
19251
+ year: "numeric",
19252
+ hour: "2-digit",
19253
+ minute: "2-digit"
19254
+ });
19255
+ };
19256
+ var normalizePoolFile = (file) => {
19257
+ 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;
19258
+ const taskInstanceId = (_a = file.taskInstanceId) != null ? _a : file.TaskInstanceId;
19259
+ const filePoolId = (_b = file.filePoolId) != null ? _b : file.FilePoolId;
19260
+ const businessEntity = (_c = file.businessEntityType) != null ? _c : file.BusinessEntityType;
19261
+ const businessEntityId = (_d = file.businessEntityId) != null ? _d : file.BusinessEntityId;
19262
+ return __spreadProps(__spreadValues({}, file), {
19263
+ fileId: filePoolId != null ? filePoolId : taskInstanceId,
19264
+ taskInstanceId,
19265
+ workflowStepId: (_e = file.workflowStepId) != null ? _e : file.WorkflowStepId,
19266
+ fileNumber: (_g = (_f = file.fileNumber) != null ? _f : file.applicationNumber) != null ? _g : `TASK-${taskInstanceId != null ? taskInstanceId : filePoolId}`,
19267
+ subject: (_i = (_h = file.subject) != null ? _h : businessEntityId ? `${businessEntity || "File"} #${businessEntityId}` : businessEntity) != null ? _i : `Workflow task ${taskInstanceId != null ? taskInstanceId : ""}`,
19268
+ workflowName: (_k = (_j = file.workflowName) != null ? _j : file.WorkflowName) != null ? _k : "-",
19269
+ department: (_l = file.department) != null ? _l : "-",
19270
+ applicant: (_m = file.applicant) != null ? _m : businessEntityId ? String(businessEntityId) : "-",
19271
+ category: (_p = (_o = (_n = file.category) != null ? _n : file.workflowTypeName) != null ? _o : file.WorkflowTypeName) != null ? _p : "-",
19272
+ financialYear: (_q = file.financialYear) != null ? _q : "-",
19273
+ sender: (_s = (_r = file.sender) != null ? _r : file.initiator) != null ? _s : "-",
19274
+ priority: (_t = file.priority) != null ? _t : "Medium",
19275
+ receivedDate: formatInboxDate((_v = (_u = file.addedOn) != null ? _u : file.createdAt) != null ? _v : file.receivedDate),
19276
+ dueDate: formatInboxDate(file.dueDate),
19277
+ slaStatus: (_w = file.slaStatus) != null ? _w : "-",
19278
+ status: "Available",
19279
+ assignedTo: "-",
19280
+ currentStep: (_x = file.stepName) != null ? _x : "-"
19281
+ });
19282
+ };
19283
+ var normalizeMyFile = (file) => {
19284
+ 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;
19285
+ const taskInstanceId = (_a = file.taskInstanceId) != null ? _a : file.TaskInstanceId;
19286
+ const businessEntityId = (_b = file.businessEntityId) != null ? _b : file.BusinessEntityId;
19287
+ const businessEntity = (_c = file.businessEntityType) != null ? _c : file.BusinessEntityType;
19288
+ return __spreadProps(__spreadValues({}, file), {
19289
+ fileId: (_d = taskInstanceId != null ? taskInstanceId : file.fileInstanceId) != null ? _d : file.FileInstanceId,
19290
+ taskInstanceId,
19291
+ workflowStepId: (_e = file.workflowStepId) != null ? _e : file.WorkflowStepId,
19292
+ fileNumber: (_g = (_f = file.fileNumber) != null ? _f : file.applicationNumber) != null ? _g : `TASK-${taskInstanceId != null ? taskInstanceId : ""}`,
19293
+ subject: (_i = (_h = file.subject) != null ? _h : businessEntityId ? `${businessEntity || "File"} #${businessEntityId}` : businessEntity) != null ? _i : `Workflow task ${taskInstanceId != null ? taskInstanceId : ""}`,
19294
+ workflowName: (_k = (_j = file.workflowName) != null ? _j : file.WorkflowName) != null ? _k : "-",
19295
+ department: (_l = file.department) != null ? _l : file.hierarchyNodeId ? `Node ${file.hierarchyNodeId}` : "-",
19296
+ applicant: (_m = file.applicant) != null ? _m : businessEntityId ? String(businessEntityId) : "-",
19297
+ category: (_p = (_o = (_n = file.category) != null ? _n : file.workflowTypeName) != null ? _o : file.WorkflowTypeName) != null ? _p : "-",
19298
+ financialYear: (_q = file.financialYear) != null ? _q : "-",
19299
+ sender: (_s = (_r = file.sender) != null ? _r : businessEntity) != null ? _s : "-",
19300
+ priority: (_t = file.priority) != null ? _t : "Medium",
19301
+ receivedDate: formatInboxDate((_u = file.createdAt) != null ? _u : file.receivedDate),
19302
+ dueDate: formatInboxDate(file.dueDate),
19303
+ slaStatus: (_v = file.slaStatus) != null ? _v : "-",
19304
+ status: (_x = (_w = file.fileStatus) != null ? _w : file.statusName) != null ? _x : "In Progress",
19305
+ assignedTo: "Pankaj Jain",
19306
+ currentStep: (_y = file.stepName) != null ? _y : "-"
19307
+ });
19308
+ };
19219
19309
  var INITIAL_FILE_POOL = [
19220
19310
  {
19221
19311
  fileId: 101,
@@ -19464,13 +19554,125 @@ var INITIAL_TOTAL_FILES = [
19464
19554
  ];
19465
19555
  function InboxMain() {
19466
19556
  const [activeTab, setActiveTab] = useState71("filePool");
19467
- const [activeRole, setActiveRole] = useState71("Reviewer");
19557
+ const [assignedSteps, setAssignedSteps] = useState71([]);
19558
+ const [activeWorkflowStepId, setActiveWorkflowStepId] = useState71(null);
19468
19559
  const [roleDropdownOpen, setRoleDropdownOpen] = useState71(false);
19469
19560
  const roleDropdownRef = useRef24(null);
19470
- const activeRoleDetails = INBOX_ROLES.find((role) => role.name === activeRole) || INBOX_ROLES[0];
19471
- const [filePoolFiles, setFilePoolFiles] = useState71(INITIAL_FILE_POOL);
19472
- const [myFiles, setMyFiles] = useState71(INITIAL_MY_FILES);
19561
+ const activeRoleDetails = assignedSteps.find(
19562
+ (step) => Number(step.workflowStepId) === Number(activeWorkflowStepId)
19563
+ );
19564
+ const activeRole = (activeRoleDetails == null ? void 0 : activeRoleDetails.stepName) || "No Assigned Step";
19565
+ const [filePoolFiles, setFilePoolFiles] = useState71([]);
19566
+ const [myFiles, setMyFiles] = useState71([]);
19473
19567
  const [totalFiles, setTotalFiles] = useState71(INITIAL_TOTAL_FILES);
19568
+ const [refreshKey, setRefreshKey] = useState71(0);
19569
+ useEffect51(() => {
19570
+ let isCurrent = true;
19571
+ const loadAssignedSteps = async () => {
19572
+ var _a, _b;
19573
+ try {
19574
+ const apiService = getApiService();
19575
+ const unclaimedFilesEndpoint = getInboxEndpoint(
19576
+ ["inbox", "Inbox", "filePool", "FilePool"],
19577
+ "getUnclaimedFilesByWorkflowStepId"
19578
+ );
19579
+ if (!unclaimedFilesEndpoint) {
19580
+ throw new Error("File Pool endpoint is not configured (flowCore.inbox.getUnclaimedFilesByWorkflowStepId).");
19581
+ }
19582
+ const configuredAssignedStepsEndpoint = getInboxEndpoint(
19583
+ ["inbox", "Inbox", "mapping", "Mapping", "workflowStepUserMapping", "WorkflowStepUserMapping", "workflowStep", "WorkFlowStep", "WorkflowStep"],
19584
+ "getAssignedStepsByUser"
19585
+ );
19586
+ const assignedStepsEndpoint = configuredAssignedStepsEndpoint || deriveAssignedStepsEndpoint(unclaimedFilesEndpoint);
19587
+ if (!assignedStepsEndpoint) throw new Error("Assigned workflow steps endpoint is not configured.");
19588
+ const assignedStepsResponse = await apiService.post(assignedStepsEndpoint, {});
19589
+ const stepsById = /* @__PURE__ */ new Map();
19590
+ unwrapInboxRows(assignedStepsResponse).forEach((step) => {
19591
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
19592
+ const workflowStepId = Number((_a2 = step.workflowStepId) != null ? _a2 : step.WorkflowStepId);
19593
+ const isActiveMapping = (_b2 = step.isActiveMapping) != null ? _b2 : step.IsActiveMapping;
19594
+ const isReleased = (_c = step.isReleased) != null ? _c : step.IsReleased;
19595
+ if (!Number.isInteger(workflowStepId) || workflowStepId <= 0 || isActiveMapping === false || isReleased === true) return;
19596
+ stepsById.set(workflowStepId, __spreadProps(__spreadValues({}, step), {
19597
+ workflowStepId,
19598
+ stepName: (_e = (_d = step.stepName) != null ? _d : step.StepName) != null ? _e : `Workflow Step ${workflowStepId}`,
19599
+ stepCode: (_g = (_f = step.stepCode) != null ? _f : step.StepCode) != null ? _g : "",
19600
+ workflowName: (_i = (_h = step.workflowName) != null ? _h : step.WorkflowName) != null ? _i : ""
19601
+ }));
19602
+ });
19603
+ const nextAssignedSteps = [...stepsById.values()];
19604
+ if (!isCurrent) return;
19605
+ setAssignedSteps(nextAssignedSteps);
19606
+ setActiveWorkflowStepId(
19607
+ (currentStepId) => {
19608
+ var _a2, _b2;
19609
+ return nextAssignedSteps.some((step) => step.workflowStepId === Number(currentStepId)) ? Number(currentStepId) : (_b2 = (_a2 = nextAssignedSteps[0]) == null ? void 0 : _a2.workflowStepId) != null ? _b2 : null;
19610
+ }
19611
+ );
19612
+ } catch (error) {
19613
+ if (!isCurrent) return;
19614
+ setAssignedSteps([]);
19615
+ setActiveWorkflowStepId(null);
19616
+ await Swal29.fire(
19617
+ "Error",
19618
+ ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || (error == null ? void 0 : error.message) || "Unable to load assigned workflow steps.",
19619
+ "error"
19620
+ );
19621
+ }
19622
+ };
19623
+ loadAssignedSteps();
19624
+ return () => {
19625
+ isCurrent = false;
19626
+ };
19627
+ }, []);
19628
+ useEffect51(() => {
19629
+ let isCurrent = true;
19630
+ const loadStepFiles = async () => {
19631
+ var _a, _b;
19632
+ if (!activeWorkflowStepId) {
19633
+ setFilePoolFiles([]);
19634
+ setMyFiles([]);
19635
+ return;
19636
+ }
19637
+ try {
19638
+ const unclaimedFilesEndpoint = getInboxEndpoint(
19639
+ ["inbox", "Inbox", "filePool", "FilePool"],
19640
+ "getUnclaimedFilesByWorkflowStepId"
19641
+ );
19642
+ if (!unclaimedFilesEndpoint) {
19643
+ throw new Error("File Pool endpoint is not configured (flowCore.inbox.getUnclaimedFilesByWorkflowStepId).");
19644
+ }
19645
+ const myFilesEndpoint = getInboxEndpoint(
19646
+ ["inbox", "Inbox", "myFiles", "MyFiles"],
19647
+ ["getMyFilesList", "getList"]
19648
+ );
19649
+ if (!myFilesEndpoint) {
19650
+ throw new Error("My Files list endpoint is not configured (flowCore.inbox.getMyFilesList).");
19651
+ }
19652
+ const payload = { workflowStepId: Number(activeWorkflowStepId) };
19653
+ const [poolResponse, myFilesResponse] = await Promise.all([
19654
+ getApiService().post(unclaimedFilesEndpoint, payload),
19655
+ getApiService().post(myFilesEndpoint, payload)
19656
+ ]);
19657
+ if (!isCurrent) return;
19658
+ setFilePoolFiles(unwrapInboxRows(poolResponse).map(normalizePoolFile));
19659
+ setMyFiles(unwrapInboxRows(myFilesResponse).map(normalizeMyFile));
19660
+ } catch (error) {
19661
+ if (!isCurrent) return;
19662
+ setFilePoolFiles([]);
19663
+ setMyFiles([]);
19664
+ await Swal29.fire(
19665
+ "Error",
19666
+ ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || (error == null ? void 0 : error.message) || "Unable to load inbox files.",
19667
+ "error"
19668
+ );
19669
+ }
19670
+ };
19671
+ loadStepFiles();
19672
+ return () => {
19673
+ isCurrent = false;
19674
+ };
19675
+ }, [activeWorkflowStepId, refreshKey]);
19474
19676
  const [dynamicColumns, setDynamicColumns] = useState71([
19475
19677
  { key: "department", label: "Department", width: "190px", visible: true },
19476
19678
  { key: "applicant", label: "Applicant / Entity", width: "210px", visible: true },
@@ -19487,6 +19689,7 @@ function InboxMain() {
19487
19689
  const [sortDirection, setSortDirection] = useState71("asc");
19488
19690
  const [poolModalOpen, setPoolModalOpen] = useState71(false);
19489
19691
  const [selectedPoolFile, setSelectedPoolFile] = useState71(null);
19692
+ const [isClaimingPool, setIsClaimingPool] = useState71(false);
19490
19693
  const [actionModalOpen, setActionModalOpen] = useState71(false);
19491
19694
  const [selectedActionFile, setSelectedActionFile] = useState71(null);
19492
19695
  const [viewModalOpen, setViewModalOpen] = useState71(false);
@@ -19660,27 +19863,45 @@ function InboxMain() {
19660
19863
  setSelectedPoolFile(file);
19661
19864
  setPoolModalOpen(true);
19662
19865
  };
19663
- const handleConfirmPool = async (fileToPool) => {
19664
- setPoolModalOpen(false);
19665
- setFilePoolFiles((prev) => prev.filter((item) => item.fileId !== fileToPool.fileId));
19666
- const claimedFile = __spreadProps(__spreadValues({}, fileToPool), {
19667
- status: "In Progress",
19668
- assignedTo: "Pankaj Jain"
19669
- });
19670
- setMyFiles((prev) => [claimedFile, ...prev]);
19671
- setTotalFiles(
19672
- (prev) => prev.map(
19673
- (item) => item.fileId === fileToPool.fileId ? __spreadProps(__spreadValues({}, item), { status: "In Progress", assignedTo: "Pankaj Jain" }) : item
19674
- )
19675
- );
19676
- await Swal29.fire({
19677
- icon: "success",
19678
- title: "File Pooled Successfully!",
19679
- html: `File <strong>${fileToPool.fileNumber}</strong> has been moved to your <strong>My Files</strong> queue.`,
19680
- confirmButtonColor: "#2563eb",
19681
- timer: 3e3,
19682
- timerProgressBar: true
19683
- });
19866
+ const handleConfirmPool = async () => {
19867
+ var _a, _b;
19868
+ if (!activeWorkflowStepId) {
19869
+ await Swal29.fire("Error", "Select an assigned workflow step before claiming files.", "error");
19870
+ return;
19871
+ }
19872
+ setIsClaimingPool(true);
19873
+ try {
19874
+ const claimEndpoint = getInboxEndpoint(
19875
+ ["inbox", "Inbox", "filePool", "FilePool"],
19876
+ "claimUnclaimedFilesByWorkflowStepId"
19877
+ );
19878
+ if (!claimEndpoint) {
19879
+ throw new Error("Claim endpoint is not configured (flowCore.inbox.claimUnclaimedFilesByWorkflowStepId).");
19880
+ }
19881
+ await getApiService().post(claimEndpoint, {
19882
+ workflowStepId: Number(activeWorkflowStepId)
19883
+ });
19884
+ setPoolModalOpen(false);
19885
+ setSelectedPoolFile(null);
19886
+ setCurrentPage(1);
19887
+ setRefreshKey((previous) => previous + 1);
19888
+ await Swal29.fire({
19889
+ icon: "success",
19890
+ title: "Files Claimed",
19891
+ text: "Unclaimed files for this workflow step have been assigned to your My Files queue.",
19892
+ confirmButtonColor: "#2563eb",
19893
+ timer: 3e3,
19894
+ timerProgressBar: true
19895
+ });
19896
+ } catch (error) {
19897
+ await Swal29.fire(
19898
+ "Error",
19899
+ ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || (error == null ? void 0 : error.message) || "Unable to claim files.",
19900
+ "error"
19901
+ );
19902
+ } finally {
19903
+ setIsClaimingPool(false);
19904
+ }
19684
19905
  };
19685
19906
  const handleOpenTakeAction = (file) => {
19686
19907
  setSelectedActionFile(file);
@@ -19703,11 +19924,12 @@ function InboxMain() {
19703
19924
  };
19704
19925
  const handleRefresh = () => {
19705
19926
  setCurrentPage(1);
19927
+ setRefreshKey((previous) => previous + 1);
19706
19928
  Swal29.fire({
19707
19929
  toast: true,
19708
19930
  position: "top-end",
19709
- icon: "success",
19710
- title: "Inbox updated with latest records",
19931
+ icon: "info",
19932
+ title: "Refreshing inbox files",
19711
19933
  showConfirmButton: false,
19712
19934
  timer: 2e3
19713
19935
  });
@@ -19793,7 +20015,7 @@ function InboxMain() {
19793
20015
  ] }),
19794
20016
  /* @__PURE__ */ jsxs96("div", { className: "fc:flex fc:items-center fc:gap-1.5 fc:mt-0.5", children: [
19795
20017
  /* @__PURE__ */ jsx97("span", { className: "fc:text-[10px] fc:text-slate-400 fc:font-medium", children: "Active Step:" }),
19796
- /* @__PURE__ */ jsx97("span", { className: "fc:text-[10px] fc:font-bold fc:text-indigo-600 fc:bg-indigo-50/80 fc:px-1.5 fc:py-0.2 fc:rounded", children: activeRoleDetails.step })
20018
+ /* @__PURE__ */ jsx97("span", { className: "fc:text-[10px] fc:font-bold fc:text-indigo-600 fc:bg-indigo-50/80 fc:px-1.5 fc:py-0.2 fc:rounded", children: (activeRoleDetails == null ? void 0 : activeRoleDetails.stepName) || "-" })
19797
20019
  ] })
19798
20020
  ] }),
19799
20021
  roleDropdownOpen && /* @__PURE__ */ jsxs96(
@@ -19805,30 +20027,39 @@ function InboxMain() {
19805
20027
  children: [
19806
20028
  /* @__PURE__ */ jsxs96("div", { className: "fc:flex fc:items-center fc:justify-between fc:border-b fc:border-slate-100 fc:px-3 fc:pb-2 fc:pt-1.5", children: [
19807
20029
  /* @__PURE__ */ jsx97("div", { children: /* @__PURE__ */ jsx97("p", { className: "fc:text-xs fc:font-bold fc:text-slate-800", children: "Switch role" }) }),
19808
- /* @__PURE__ */ jsx97("span", { className: "fc:rounded-full fc:bg-slate-100 fc:px-2 fc:text-[9px] fc:font-bold fc:text-slate-500", children: "3 ROLES" })
20030
+ /* @__PURE__ */ jsxs96("span", { className: "fc:rounded-full fc:bg-slate-100 fc:px-2 fc:text-[9px] fc:font-bold fc:text-slate-500", children: [
20031
+ assignedSteps.length,
20032
+ " STEPS"
20033
+ ] })
19809
20034
  ] }),
19810
- /* @__PURE__ */ jsx97("div", { className: "fc:space-y-1 fc:pt-0.5", children: INBOX_ROLES.map((role) => /* @__PURE__ */ jsxs96(
19811
- "button",
19812
- {
19813
- type: "button",
19814
- role: "menuitemradio",
19815
- "aria-checked": activeRole === role.name,
19816
- onClick: () => {
19817
- setActiveRole(role.name);
19818
- setRoleDropdownOpen(false);
20035
+ /* @__PURE__ */ jsx97("div", { className: "fc:space-y-1 fc:pt-0.5", children: assignedSteps.length === 0 ? /* @__PURE__ */ jsx97("p", { className: "fc:px-3 fc:py-3 fc:text-xs fc:text-slate-500", children: "No assigned workflow steps" }) : assignedSteps.map((step) => {
20036
+ const isSelected = Number(activeWorkflowStepId) === step.workflowStepId;
20037
+ const stepName = step.stepName || `Workflow Step ${step.workflowStepId}`;
20038
+ const marker = String(step.stepCode || stepName).trim().slice(0, 2).toUpperCase();
20039
+ return /* @__PURE__ */ jsxs96(
20040
+ "button",
20041
+ {
20042
+ type: "button",
20043
+ role: "menuitemradio",
20044
+ "aria-checked": isSelected,
20045
+ onClick: () => {
20046
+ setActiveWorkflowStepId(step.workflowStepId);
20047
+ setCurrentPage(1);
20048
+ setRoleDropdownOpen(false);
20049
+ },
20050
+ className: `fc:flex fc:w-full fc:items-center fc:gap-3 fc:rounded-xl fc:border fc:px-3 fc:py-3 fc:text-left fc:transition-colors ${isSelected ? "fc:border-blue-200 fc:bg-blue-50/80" : "fc:border-transparent fc:bg-white hover:fc:border-slate-200 hover:fc:bg-slate-50"}`,
20051
+ children: [
20052
+ /* @__PURE__ */ jsx97("span", { className: "fc:flex fc:h-9 fc:w-9 fc:shrink-0 fc:items-center fc:justify-center fc:rounded-xl fc:bg-blue-100 fc:text-[10px] fc:font-extrabold fc:text-blue-700", children: marker }),
20053
+ /* @__PURE__ */ jsxs96("span", { className: "fc:min-w-0 fc:flex-1", children: [
20054
+ /* @__PURE__ */ jsx97("span", { className: `fc:block fc:text-xs fc:font-bold ${isSelected ? "fc:text-blue-800" : "fc:text-slate-800"}`, children: stepName }),
20055
+ /* @__PURE__ */ jsx97("span", { className: "fc:mt-0.5 fc:block fc:text-[10px] fc:leading-4 fc:text-slate-500", children: step.workflowName || `Workflow Step ID ${step.workflowStepId}` })
20056
+ ] }),
20057
+ isSelected && /* @__PURE__ */ jsx97("span", { className: "fc:shrink-0 fc:rounded-full fc:bg-blue-100 fc:px-2 fc:py-1 fc:text-[9px] fc:font-bold fc:text-blue-700", children: "Current" })
20058
+ ]
19819
20059
  },
19820
- className: `fc:flex fc:w-full fc:items-center fc:gap-3 fc:rounded-xl fc:border fc:px-3 fc:py-3 fc:text-left fc:transition-colors ${activeRole === role.name ? "fc:border-blue-200 fc:bg-blue-50/80" : "fc:border-transparent fc:bg-white hover:fc:border-slate-200 hover:fc:bg-slate-50"}`,
19821
- children: [
19822
- /* @__PURE__ */ jsx97("span", { className: `fc:flex fc:h-9 fc:w-9 fc:shrink-0 fc:items-center fc:justify-center fc:rounded-xl fc:text-[10px] fc:font-extrabold ${role.color}`, children: role.marker }),
19823
- /* @__PURE__ */ jsxs96("span", { className: "fc:min-w-0 fc:flex-1", children: [
19824
- /* @__PURE__ */ jsx97("span", { className: `fc:block fc:text-xs fc:font-bold ${activeRole === role.name ? "fc:text-blue-800" : "fc:text-slate-800"}`, children: role.name }),
19825
- /* @__PURE__ */ jsx97("span", { className: "fc:mt-0.5 fc:block fc:text-[10px] fc:leading-4 fc:text-slate-500", children: role.description })
19826
- ] }),
19827
- activeRole === role.name && /* @__PURE__ */ jsx97("span", { className: "fc:shrink-0 fc:rounded-full fc:bg-blue-100 fc:px-2 fc:py-1 fc:text-[9px] fc:font-bold fc:text-blue-700", children: "Current" })
19828
- ]
19829
- },
19830
- role.name
19831
- )) })
20060
+ step.workflowStepId
20061
+ );
20062
+ }) })
19832
20063
  ]
19833
20064
  }
19834
20065
  )
@@ -20487,7 +20718,9 @@ function InboxMain() {
20487
20718
  {
20488
20719
  isOpen: poolModalOpen,
20489
20720
  file: selectedPoolFile,
20721
+ isSubmitting: isClaimingPool,
20490
20722
  onClose: () => {
20723
+ if (isClaimingPool) return;
20491
20724
  setPoolModalOpen(false);
20492
20725
  setSelectedPoolFile(null);
20493
20726
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowcore-fn",
3
- "version": "10.2.7",
3
+ "version": "10.2.8",
4
4
  "main": "dist/pkg-index.js",
5
5
  "module": "dist/pkg-index.mjs",
6
6
  "files": [