flowcore-fn 10.1.4 → 10.1.5

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/pkg-index.js CHANGED
@@ -4693,7 +4693,7 @@ function User_hierarchy_mapping_main() {
4693
4693
  };
4694
4694
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "fc:min-h-screen fc:bg-slate-50 fc:p-4 md:fc:fc:p-6", children: [
4695
4695
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "fc:w-full fc:space-y-5", children: [
4696
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CommonHeader, { title: "Workflow Step Hierarchy Mapping", breadcrumbs: [{
4696
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CommonHeader, { title: "Workflow Step User Mapping", breadcrumbs: [{
4697
4697
  label: "Dashboard",
4698
4698
  href: "/dashboard"
4699
4699
  }, {
@@ -11526,22 +11526,26 @@ function UploadedDocumentMain() {
11526
11526
 
11527
11527
  // src/components/BuisnessEntity/BusinessEntitymain.js
11528
11528
  var import_react80 = __toESM(require("react"));
11529
- var import_link3 = __toESM(require("next/link"));
11529
+ var import_sweetalert216 = __toESM(require("sweetalert2"));
11530
11530
 
11531
11531
  // src/components/BuisnessEntity/AddBusinessEntityModal.js
11532
11532
  var import_react79 = __toESM(require("react"));
11533
11533
  var import_jsx_runtime79 = require("react/jsx-runtime");
11534
- function AddBusinessEntityModal({ onClose }) {
11535
- const [formData, setFormData] = (0, import_react79.useState)({
11536
- entityType: "",
11537
- entityKey: "",
11538
- displayNumber: "",
11539
- displayTitle: "",
11540
- isDefault: false,
11541
- isVisible: true,
11542
- status: "Active"
11534
+ function AddBusinessEntityModal({ onClose, onSave, editData }) {
11535
+ const [formData, setFormData] = (0, import_react79.useState)(() => {
11536
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
11537
+ return {
11538
+ entityType: (_b = (_a = editData == null ? void 0 : editData.entityType) != null ? _a : editData == null ? void 0 : editData.EntityType) != null ? _b : "",
11539
+ entityKey: String((_d = (_c = editData == null ? void 0 : editData.entityKey) != null ? _c : editData == null ? void 0 : editData.EntityKey) != null ? _d : ""),
11540
+ displayNumber: (_f = (_e = editData == null ? void 0 : editData.displayNumber) != null ? _e : editData == null ? void 0 : editData.DisplayNumber) != null ? _f : "",
11541
+ displayTitle: (_h = (_g = editData == null ? void 0 : editData.displayTitle) != null ? _g : editData == null ? void 0 : editData.DisplayTitle) != null ? _h : "",
11542
+ isDefault: (_i = editData == null ? void 0 : editData.isDefault) != null ? _i : false,
11543
+ isVisible: (_j = editData == null ? void 0 : editData.isVisible) != null ? _j : true,
11544
+ status: ((_l = (_k = editData == null ? void 0 : editData.isActive) != null ? _k : editData == null ? void 0 : editData.IsActive) != null ? _l : true) ? "Active" : "Inactive"
11545
+ };
11543
11546
  });
11544
11547
  const [errors, setErrors] = (0, import_react79.useState)({});
11548
+ const [isSubmitting, setIsSubmitting] = (0, import_react79.useState)(false);
11545
11549
  const handleChange = (field, value) => {
11546
11550
  setFormData((prev) => __spreadProps(__spreadValues({}, prev), {
11547
11551
  [field]: value
@@ -11561,10 +11565,17 @@ function AddBusinessEntityModal({ onClose }) {
11561
11565
  setErrors(newErrors);
11562
11566
  return Object.keys(newErrors).length === 0;
11563
11567
  };
11564
- const handleSubmit = (e) => {
11568
+ const handleSubmit = async (e) => {
11569
+ var _a, _b, _c;
11565
11570
  e.preventDefault();
11566
- if (validate()) {
11567
- console.log("Form Submitted Successfully", formData);
11571
+ if (!validate() || !onSave) return;
11572
+ const isEdit = Boolean(editData);
11573
+ const payload = isEdit ? { businessEntityId: (_a = editData.businessEntityId) != null ? _a : editData.BusinessEntityId, entityType: formData.entityType, entityKey: Number(formData.entityKey), displayNumber: formData.displayNumber.trim(), displayTitle: formData.displayTitle.trim(), isActive: formData.status === "Active", updatedBy: (_c = (_b = editData.updatedBy) != null ? _b : editData.createdBy) != null ? _c : "System" } : { entityType: formData.entityType, entityKey: Number(formData.entityKey), displayNumber: formData.displayNumber.trim(), displayTitle: formData.displayTitle.trim(), createdBy: "System" };
11574
+ setIsSubmitting(true);
11575
+ try {
11576
+ if (await onSave(payload, isEdit)) onClose();
11577
+ } finally {
11578
+ setIsSubmitting(false);
11568
11579
  }
11569
11580
  };
11570
11581
  return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:p-4", children: [
@@ -11580,7 +11591,7 @@ function AddBusinessEntityModal({ onClose }) {
11580
11591
  /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-4", children: [
11581
11592
  /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "fc:w-12 fc:h-12 fc:bg-indigo-50 fc:text-indigo-600 fc:rounded-xl fc:flex fc:items-center fc:justify-center fc:shadow-sm fc:transition-transform hover:fc:scale-105", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("svg", { className: "fc:w-6 fc:h-6", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5m0 0v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" }) }) }),
11582
11593
  /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { children: [
11583
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("h2", { className: "fc:text-xl fc:font-extrabold fc:text-slate-800", children: "Add Business Entity" }),
11594
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("h2", { className: "fc:text-xl fc:font-extrabold fc:text-slate-800", children: editData ? "Edit Business Entity" : "Add Business Entity" }),
11584
11595
  /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "fc:text-xs fc:text-slate-400 fc:mt-0.5", children: "Create a new business entity for the workflow engine" })
11585
11596
  ] })
11586
11597
  ] }),
@@ -11816,10 +11827,11 @@ function AddBusinessEntityModal({ onClose }) {
11816
11827
  {
11817
11828
  type: "button",
11818
11829
  onClick: handleSubmit,
11830
+ disabled: isSubmitting,
11819
11831
  className: "fc:px-6 fc:py-2.5 fc:bg-indigo-600 hover:fc:bg-indigo-700 fc:text-white fc:text-xs fc:font-bold fc:rounded-xl fc:shadow-md fc:shadow-indigo-500/20 hover:fc:shadow-indigo-500/30 fc:transition-all active:fc:scale-95 fc:flex fc:items-center fc:gap-2",
11820
11832
  children: [
11821
11833
  /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("svg", { className: "fc:w-4 fc:h-4", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" }) }),
11822
- "Save Business Entity"
11834
+ isSubmitting ? "Saving..." : editData ? "Update Business Entity" : "Save Business Entity"
11823
11835
  ]
11824
11836
  }
11825
11837
  )
@@ -11829,192 +11841,242 @@ function AddBusinessEntityModal({ onClose }) {
11829
11841
  }
11830
11842
 
11831
11843
  // src/components/BuisnessEntity/BusinessEntitymain.js
11844
+ init_ApiEndpointsProvider();
11845
+ init_ApiServicepackage();
11832
11846
  var import_jsx_runtime80 = require("react/jsx-runtime");
11833
- var BusinessEntitys = [{
11834
- BusinessEntityId: 1,
11835
- EntityType: "Application",
11836
- EntityKey: "5001",
11837
- DisplayNumber: "App-001",
11838
- DisplayTitle: "Building Permission"
11839
- }, {
11840
- BusinessEntityId: 1,
11841
- EntityType: "Application",
11842
- EntityKey: "5001",
11843
- DisplayNumber: "App-001",
11844
- DisplayTitle: "Building Permission"
11845
- }, {
11846
- BusinessEntityId: 1,
11847
- EntityType: "Application",
11848
- EntityKey: "5001",
11849
- DisplayNumber: "App-001",
11850
- DisplayTitle: "Building Permission"
11851
- }, {
11852
- BusinessEntityId: 1,
11853
- EntityType: "Application",
11854
- EntityKey: "5001",
11855
- DisplayNumber: "App-001",
11856
- DisplayTitle: "Building Permission"
11857
- }, {
11858
- BusinessEntityId: 1,
11859
- EntityType: "Application",
11860
- EntityKey: "5001",
11861
- DisplayNumber: "App-001",
11862
- DisplayTitle: "Building Permission"
11863
- }, {
11864
- BusinessEntityId: 1,
11865
- EntityType: "Application",
11866
- EntityKey: "5001",
11867
- DisplayNumber: "App-001",
11868
- DisplayTitle: "Building Permission"
11869
- }, {
11870
- BusinessEntityId: 1,
11871
- EntityType: "Application",
11872
- EntityKey: "5001",
11873
- DisplayNumber: "App-001",
11874
- DisplayTitle: "Building Permission"
11875
- }, {
11876
- BusinessEntityId: 1,
11877
- EntityType: "Application",
11878
- EntityKey: "5001",
11879
- DisplayNumber: "App-001",
11880
- DisplayTitle: "Building Permission"
11881
- }, {
11882
- BusinessEntityId: 1,
11883
- EntityType: "Application",
11884
- EntityKey: "5001",
11885
- DisplayNumber: "App-001",
11886
- DisplayTitle: "Building Permission"
11887
- }, {
11888
- BusinessEntityId: 2,
11889
- EntityType: "Application",
11890
- EntityKey: "5002",
11891
- DisplayNumber: "App-002",
11892
- DisplayTitle: "Building Permission"
11893
- }, {
11894
- BusinessEntityId: 3,
11895
- EntityType: "Application",
11896
- EntityKey: "5003",
11897
- DisplayNumber: "App-003",
11898
- DisplayTitle: "Building Permission"
11899
- }, {
11900
- BusinessEntityId: 4,
11901
- EntityType: "Application",
11902
- EntityKey: "5004",
11903
- DisplayNumber: "App-004",
11904
- DisplayTitle: "Building Permission"
11905
- }, {
11906
- BusinessEntityId: 5,
11907
- EntityType: "Application",
11908
- EntityKey: "5005",
11909
- DisplayNumber: "App-005",
11910
- DisplayTitle: "Building Permission"
11911
- }];
11847
+ var BUSINESS_ENTITY_ENDPOINTS = {
11848
+ create: "/api/flowcore/BusinessEntity/Create",
11849
+ update: "/api/flowcore/BusinessEntity/Update",
11850
+ getById: "/api/flowcore/BusinessEntity/GetById",
11851
+ getList: "/api/flowcore/BusinessEntity/GetList"
11852
+ };
11853
+ var getBusinessEntityEndpoint = (action) => {
11854
+ var _a, _b, _c, _d;
11855
+ try {
11856
+ return (_d = (_c = (_b = (_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) == null ? void 0 : _b.businessEntity) == null ? void 0 : _c[action]) != null ? _d : BUSINESS_ENTITY_ENDPOINTS[action];
11857
+ } catch (e) {
11858
+ return BUSINESS_ENTITY_ENDPOINTS[action];
11859
+ }
11860
+ };
11861
+ var getBusinessEntityByIdEndpoint = (id) => {
11862
+ const endpoint = getBusinessEntityEndpoint("getById");
11863
+ return typeof endpoint === "function" ? endpoint(id) : `${endpoint}/${id}`;
11864
+ };
11865
+ var getRows = (response) => {
11866
+ var _a, _b, _c, _d, _e, _f, _g;
11867
+ 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;
11868
+ return Array.isArray(value) ? value : (_g = (_f = value == null ? void 0 : value.items) != null ? _f : value == null ? void 0 : value.records) != null ? _g : [];
11869
+ };
11870
+ var normalise = (item) => {
11871
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
11872
+ return __spreadProps(__spreadValues({}, item), {
11873
+ businessEntityId: (_b = (_a = item.businessEntityId) != null ? _a : item.BusinessEntityId) != null ? _b : item.id,
11874
+ entityType: (_d = (_c = item.entityType) != null ? _c : item.EntityType) != null ? _d : "",
11875
+ entityKey: (_f = (_e = item.entityKey) != null ? _e : item.EntityKey) != null ? _f : "",
11876
+ displayNumber: (_h = (_g = item.displayNumber) != null ? _g : item.DisplayNumber) != null ? _h : "",
11877
+ displayTitle: (_j = (_i = item.displayTitle) != null ? _i : item.DisplayTitle) != null ? _j : "",
11878
+ isActive: (_l = (_k = item.isActive) != null ? _k : item.IsActive) != null ? _l : true
11879
+ });
11880
+ };
11912
11881
  function BusinessEntity() {
11913
- const handleRefresh = () => {
11914
- console.log("Refresh clicked");
11915
- };
11916
- const handleDownload = () => {
11917
- console.log("Download clicked");
11918
- };
11919
11882
  const tableRef = (0, import_react80.useRef)(null);
11883
+ const [rows, setRows] = (0, import_react80.useState)([]);
11920
11884
  const [showModal, setShowModal] = (0, import_react80.useState)(false);
11885
+ const [editingEntity, setEditingEntity] = (0, import_react80.useState)(null);
11921
11886
  const [pageSize, setPageSize] = (0, import_react80.useState)(5);
11922
- const [sortConfig, setSortConfig] = (0, import_react80.useState)({
11923
- key: "",
11924
- direction: "asc"
11925
- });
11926
- const handleSort = (key) => {
11927
- let direction = "asc";
11928
- if (sortConfig.key === key && sortConfig.direction === "asc") {
11929
- direction = "desc";
11887
+ const [search, setSearch] = (0, import_react80.useState)("");
11888
+ const [sortConfig, setSortConfig] = (0, import_react80.useState)({ key: "", direction: "asc" });
11889
+ const [refreshKey, setRefreshKey] = (0, import_react80.useState)(0);
11890
+ (0, import_react80.useEffect)(() => {
11891
+ const load = async () => {
11892
+ var _a, _b;
11893
+ try {
11894
+ const endpoint = getBusinessEntityEndpoint("getList");
11895
+ const response = await getApiService().get(endpoint);
11896
+ setRows(getRows(response).map(normalise));
11897
+ } catch (error) {
11898
+ await import_sweetalert216.default.fire("Error", ((_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 business entities.", "error");
11899
+ }
11900
+ };
11901
+ load();
11902
+ }, [refreshKey]);
11903
+ const refresh = () => setRefreshKey((value) => value + 1);
11904
+ const saveEntity = async (payload, isEdit) => {
11905
+ var _a, _b;
11906
+ try {
11907
+ const endpoint = getBusinessEntityEndpoint(isEdit ? "update" : "create");
11908
+ await getApiService()[isEdit ? "put" : "post"](endpoint, payload);
11909
+ await import_sweetalert216.default.fire("Success", `Business entity ${isEdit ? "updated" : "created"} successfully.`, "success");
11910
+ refresh();
11911
+ return true;
11912
+ } catch (error) {
11913
+ await import_sweetalert216.default.fire("Error", ((_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 ${isEdit ? "update" : "create"} business entity.`, "error");
11914
+ return false;
11930
11915
  }
11931
- setSortConfig({
11932
- key,
11933
- direction
11934
- });
11935
11916
  };
11936
- return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_jsx_runtime80.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:p-5 fc:bg-[#f5f7fb] fc:min-h-screen fc:font-sans fc:text-slate-700 fc:flex fc:flex-col", children: [
11937
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(CommonHeader, { title: "Business Entity", breadcrumbs: [{
11938
- label: "Dashboard",
11939
- href: "/dashboard"
11940
- }, {
11941
- label: "Runtime",
11942
- href: "/Sidebar"
11943
- }, {
11944
- label: "Business Entity",
11945
- href: "/BuisnessEntity"
11946
- }], buttonText: "Add Business Entity", onButtonClick: () => setShowModal(true) }),
11917
+ const editEntity = async (entity) => {
11918
+ var _a, _b, _c, _d, _e, _f, _g, _h;
11919
+ try {
11920
+ const response = await getApiService().get(getBusinessEntityByIdEndpoint(entity.businessEntityId));
11921
+ const data = (_f = (_e = (_d = (_b = getRows(response)[0]) != null ? _b : (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) != null ? _d : (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.result) != null ? _e : response == null ? void 0 : response.data) != null ? _f : response;
11922
+ setEditingEntity(normalise(data));
11923
+ setShowModal(true);
11924
+ } catch (error) {
11925
+ await import_sweetalert216.default.fire("Error", ((_h = (_g = error == null ? void 0 : error.response) == null ? void 0 : _g.data) == null ? void 0 : _h.message) || (error == null ? void 0 : error.message) || "Unable to load business entity details.", "error");
11926
+ }
11927
+ };
11928
+ const visibleRows = rows.filter((item) => [item.entityType, item.entityKey, item.displayNumber, item.displayTitle].join(" ").toLowerCase().includes(search.toLowerCase())).sort((a, b) => {
11929
+ var _a, _b;
11930
+ if (!sortConfig.key) return 0;
11931
+ const result = String((_a = a[sortConfig.key]) != null ? _a : "").localeCompare(String((_b = b[sortConfig.key]) != null ? _b : ""), void 0, { numeric: true });
11932
+ return sortConfig.direction === "asc" ? result : -result;
11933
+ });
11934
+ const sort = (key) => setSortConfig((current) => ({ key, direction: current.key === key && current.direction === "asc" ? "desc" : "asc" }));
11935
+ const columns = [["BusinessEntityId", "businessEntityId"], ["EntityType", "entityType"], ["EntityKey", "entityKey"], ["DisplayNumber", "displayNumber"], ["DisplayTitle", "displayTitle"]];
11936
+ return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:p-5 fc:bg-[#f5f7fb] fc:min-h-screen fc:font-sans fc:text-slate-700 fc:flex fc:flex-col", children: [
11937
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(CommonHeader, { title: "Business Entity", breadcrumbs: [{ label: "Dashboard", href: "/dashboard" }, { label: "Runtime", href: "/Sidebar" }, { label: "Business Entity", href: "/BuisnessEntity" }], buttonText: "Add Business Entity", onButtonClick: () => {
11938
+ setEditingEntity(null);
11939
+ setShowModal(true);
11940
+ } }),
11947
11941
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:bg-white fc:rounded-3xl fc:shadow-sm fc:border fc:border-slate-100 fc:p-6 fc:flex fc:flex-col fc:gap-6", children: [
11948
11942
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:flex fc:justify-between fc:items-center fc:flex-wrap fc:gap-3", children: [
11949
- /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:relative fc:max-w-xs fc:w-full", children: [
11950
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "fc:absolute fc:inset-y-0 fc:left-0 fc:flex fc:items-center fc:pl-3.5 fc:pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("svg", { className: "fc:w-4 fc:h-5 fc:text-slate-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }) }) }),
11951
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("input", { type: "text", placeholder: "Search workflow name or code...", className: "fc:w-full fc:pl-10 fc:pr-4 fc:py-2.5 fc:border fc:border-slate-200 fc:rounded-xl fc:text-xs fc:text-[14px] fc:text-bold fc:bg-slate-50/50 focus:fc:fc:outline-none focus:fc:fc:ring-4 focus:fc:fc:ring-blue-500/10 focus:fc:fc:border-blue-500 fc:text-slate-700 fc:placeholder-slate-400 fc:transition-all" })
11952
- ] }),
11953
- /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-2 fc:text-xs fc:text-slate-500 fc:font-semibold", children: [
11954
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Refresh_default, { onRefresh: handleRefresh }),
11943
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("input", { value: search, onChange: (event) => setSearch(event.target.value), type: "text", placeholder: "Search business entities...", className: "fc:max-w-xs fc:w-full fc:px-4 fc:py-2.5 fc:border fc:border-slate-200 fc:rounded-xl fc:text-sm" }),
11944
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-2", children: [
11945
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Refresh_default, { onRefresh: refresh }),
11955
11946
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Download_default, { targetRef: tableRef, fileName: "business-entity" }),
11956
- /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("select", { value: pageSize, onChange: (e) => setPageSize(Number(e.target.value)), className: "fc:inline-flex fc:items-center fc:px-4 fc:py-2 fc:rounded-xl fc:bg-white fc:text-slate-700 fc:text-[14px] fc:font-semibold fc:border fc:border-slate-200 focus:fc:fc:outline-none fc:cursor-pointer fc:shadow-md", children: [
11947
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("select", { value: pageSize, onChange: (event) => setPageSize(Number(event.target.value)), className: "fc:px-4 fc:py-2 fc:rounded-xl fc:border fc:border-slate-200", children: [
11957
11948
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("option", { value: 5, children: "5 Rows" }),
11958
11949
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("option", { value: 10, children: "10 Rows" }),
11959
11950
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("option", { value: 25, children: "25 Rows" })
11960
11951
  ] })
11961
11952
  ] })
11962
11953
  ] }),
11963
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "fc:border fc:border-slate-200 fc:rounded-2xl fc:overflow-hidden fc:bg-white fc:shadow-md", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "fc:max-h-[350px] fc:overflow-y-auto fc:overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("table", { className: "fc:min-w-max fc:w-full fc:border-collapse", children: [
11964
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("thead", { className: "fc:bg-slate-50 fc:sticky fc:top-0 fc:z-10", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("tr", { className: "fc:text-[11px] fc:font-bold fc:uppercase fc:tracking-wider fc:text-slate-400", children: [{
11965
- label: "BusinessEntityId",
11966
- key: "BusinessEntityId"
11967
- }, {
11968
- label: "EntityType",
11969
- key: "EntityType"
11970
- }, {
11971
- label: "EntityKey",
11972
- key: "EntityKey"
11973
- }, {
11974
- label: "DisplayNumber",
11975
- key: "DisplayNumber"
11976
- }, {
11977
- label: "DisplayTitle",
11978
- key: "DisplayTitle"
11979
- }].map((column) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("th", { onClick: () => handleSort(column.key), className: "fc:px-6 fc:py-4 fc:text-left fc:text-xs fc:font-bold fc:text-slate-500 fc:uppercase fc:tracking-wider fc:cursor-pointer fc:select-none hover:fc:fc:bg-slate-100 fc:transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:flex fc:items-center fc:justify-center fc:gap-2", children: [
11980
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { children: column.label }),
11981
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "fc:text-gray-400 fc:text-xs", children: sortConfig.key === column.key ? sortConfig.direction === "asc" ? "\u25B2" : "\u25BC" : "\u2195" })
11982
- ] }) }, column.key)) }) }),
11983
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("tbody", { children: BusinessEntitys.slice(0, pageSize).map((item) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("tr", { className: "hover:fc:fc:bg-slate-50/80 fc:transition-colors fc:border-b fc:border-slate-100 last:fc:fc:border-0", children: [
11984
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-600 fc:font-bold", children: item.BusinessEntityId }),
11985
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-500 fc:font-semibold", children: item.EntityType }),
11986
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-600 fc:font-bold", children: item.EntityKey }),
11987
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-500 fc:font-semibold", children: item.DisplayNumber }),
11988
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-500 fc:font-semibold", children: item.DisplayTitle })
11989
- ] }, item.BusinessEntityId)) })
11990
- ] }) }) }),
11991
- /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "fc:rounded-xl fc:bg-slate-50/50", children: [
11992
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Footer, {}),
11993
- showModal && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(AddBusinessEntityModal, { onClose: () => setShowModal(false) })
11994
- ] })
11995
- ] })
11996
- ] }) });
11954
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { ref: tableRef, className: "fc:border fc:border-slate-200 fc:rounded-2xl fc:overflow-auto", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("table", { className: "fc:min-w-max fc:w-full", children: [
11955
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("thead", { className: "fc:bg-slate-50", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("tr", { children: [
11956
+ columns.map(([label, key]) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("th", { onClick: () => sort(key), className: "fc:px-6 fc:py-4 fc:text-center fc:text-xs fc:cursor-pointer", children: [
11957
+ label,
11958
+ " ",
11959
+ sortConfig.key === key ? sortConfig.direction === "asc" ? "\u25B2" : "\u25BC" : "\u2195"
11960
+ ] }, key)),
11961
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("th", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-xs", children: "Action" })
11962
+ ] }) }),
11963
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("tbody", { children: visibleRows.slice(0, pageSize).map((item) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("tr", { className: "fc:border-t fc:border-slate-100", children: [
11964
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: item.businessEntityId }),
11965
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: item.entityType }),
11966
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: item.entityKey }),
11967
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: item.displayNumber }),
11968
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: item.displayTitle }),
11969
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("button", { onClick: () => editEntity(item), className: "fc:bg-blue-50 hover:fc:bg-blue-100 fc:text-blue-600 fc:px-3 fc:py-1 fc:rounded-lg fc:text-xs fc:font-semibold", children: "Edit" }) })
11970
+ ] }, item.businessEntityId)) })
11971
+ ] }) }),
11972
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Footer, {})
11973
+ ] }),
11974
+ showModal && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(AddBusinessEntityModal, { editData: editingEntity, onClose: () => {
11975
+ setShowModal(false);
11976
+ setEditingEntity(null);
11977
+ }, onSave: saveEntity })
11978
+ ] });
11997
11979
  }
11998
11980
 
11999
11981
  // src/components/FileInstance/FileInstancemain.js
12000
11982
  var import_react82 = __toESM(require("react"));
12001
- var import_link4 = __toESM(require("next/link"));
11983
+ var import_sweetalert217 = __toESM(require("sweetalert2"));
12002
11984
 
12003
11985
  // src/components/FileInstance/AddWorkFlowFileInstanceModal.js
12004
11986
  var import_react81 = __toESM(require("react"));
11987
+ init_ApiEndpointsProvider();
11988
+ init_ApiServicepackage();
12005
11989
  var import_jsx_runtime81 = require("react/jsx-runtime");
12006
- function AddFileInstanceModal({ onClose }) {
12007
- const [formData, setFormData] = (0, import_react81.useState)({
12008
- workflow: "",
12009
- businessEntityType: "",
12010
- businessEntity: "",
12011
- hierarchyNode: "",
12012
- currentStep: "",
12013
- currentTaskInstance: "",
12014
- status: "Pending",
12015
- priority: "High"
11990
+ var LOOKUP_ENDPOINTS = {
11991
+ workflow: "/api/flowcore/WorkFlow/GetList",
11992
+ businessEntity: "/api/flowcore/BusinessEntity/GetList",
11993
+ hierarchyNode: "/api/flowcore/HierarchyNode/GetList"
11994
+ };
11995
+ var getLookupRows = (response) => {
11996
+ var _a, _b, _c, _d, _e, _f, _g;
11997
+ 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;
11998
+ return Array.isArray(value) ? value : (_g = (_f = value == null ? void 0 : value.items) != null ? _f : value == null ? void 0 : value.records) != null ? _g : [];
11999
+ };
12000
+ var getLookupEndpoint = (resource) => {
12001
+ var _a, _b, _c, _d;
12002
+ try {
12003
+ return (_d = (_c = (_b = (_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) == null ? void 0 : _b[resource]) == null ? void 0 : _c.getList) != null ? _d : LOOKUP_ENDPOINTS[resource];
12004
+ } catch (e) {
12005
+ return LOOKUP_ENDPOINTS[resource];
12006
+ }
12007
+ };
12008
+ function AddFileInstanceModal({ onClose, onSave, editData }) {
12009
+ const [formData, setFormData] = (0, import_react81.useState)(() => {
12010
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
12011
+ return {
12012
+ workflow: String((_b = (_a = editData == null ? void 0 : editData.workflowId) != null ? _a : editData == null ? void 0 : editData.WorkflowId) != null ? _b : ""),
12013
+ businessEntityType: (_d = (_c = editData == null ? void 0 : editData.businessEntityType) != null ? _c : editData == null ? void 0 : editData.BusinessEntityType) != null ? _d : "",
12014
+ businessEntity: String((_f = (_e = editData == null ? void 0 : editData.businessEntityId) != null ? _e : editData == null ? void 0 : editData.BusinessEntityId) != null ? _f : ""),
12015
+ hierarchyNode: String((_h = (_g = editData == null ? void 0 : editData.hierarchyNodeId) != null ? _g : editData == null ? void 0 : editData.HierarchyNodeId) != null ? _h : ""),
12016
+ currentStep: String((_j = (_i = editData == null ? void 0 : editData.currentStepId) != null ? _i : editData == null ? void 0 : editData.CurrentStepId) != null ? _j : ""),
12017
+ currentTaskInstance: String((_l = (_k = editData == null ? void 0 : editData.currentTaskInstanceId) != null ? _k : editData == null ? void 0 : editData.CurrentTaskInstanceId) != null ? _l : ""),
12018
+ status: (_n = (_m = editData == null ? void 0 : editData.status) != null ? _m : editData == null ? void 0 : editData.Status) != null ? _n : "Pending",
12019
+ priority: (_p = (_o = editData == null ? void 0 : editData.priority) != null ? _o : editData == null ? void 0 : editData.Priority) != null ? _p : "High"
12020
+ };
12016
12021
  });
12017
12022
  const [errors, setErrors] = (0, import_react81.useState)({});
12023
+ const [isSubmitting, setIsSubmitting] = (0, import_react81.useState)(false);
12024
+ const [workflows, setWorkflows] = (0, import_react81.useState)([]);
12025
+ const [businessEntities, setBusinessEntities] = (0, import_react81.useState)([]);
12026
+ const [hierarchyNodes, setHierarchyNodes] = (0, import_react81.useState)([]);
12027
+ const [isLoadingLookups, setIsLoadingLookups] = (0, import_react81.useState)(true);
12028
+ (0, import_react81.useEffect)(() => {
12029
+ let isMounted = true;
12030
+ const loadLookups = async () => {
12031
+ try {
12032
+ const apiService2 = getApiService();
12033
+ const [workflowResponse, businessEntityResponse, hierarchyNodeResponse] = await Promise.all([
12034
+ apiService2.get(getLookupEndpoint("workflow")),
12035
+ apiService2.get(getLookupEndpoint("businessEntity")),
12036
+ apiService2.get(getLookupEndpoint("hierarchyNode"))
12037
+ ]);
12038
+ if (!isMounted) return;
12039
+ setWorkflows(getLookupRows(workflowResponse));
12040
+ setBusinessEntities(getLookupRows(businessEntityResponse));
12041
+ setHierarchyNodes(getLookupRows(hierarchyNodeResponse));
12042
+ } catch (error) {
12043
+ if (!isMounted) return;
12044
+ setErrors((current) => {
12045
+ var _a, _b;
12046
+ return __spreadProps(__spreadValues({}, current), {
12047
+ lookup: ((_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 workflow, Business Entity, or Hierarchy Node options."
12048
+ });
12049
+ });
12050
+ } finally {
12051
+ if (isMounted) setIsLoadingLookups(false);
12052
+ }
12053
+ };
12054
+ loadLookups();
12055
+ return () => {
12056
+ isMounted = false;
12057
+ };
12058
+ }, []);
12059
+ const entityTypes = (0, import_react81.useMemo)(() => [...new Set(businessEntities.map((entity) => {
12060
+ var _a;
12061
+ return (_a = entity.entityType) != null ? _a : entity.EntityType;
12062
+ }).filter(Boolean))], [businessEntities]);
12063
+ const visibleBusinessEntities = (0, import_react81.useMemo)(() => businessEntities.filter((entity) => {
12064
+ var _a;
12065
+ const entityType = (_a = entity.entityType) != null ? _a : entity.EntityType;
12066
+ return !formData.businessEntityType || entityType === formData.businessEntityType;
12067
+ }), [businessEntities, formData.businessEntityType]);
12068
+ const handleSubmit = async () => {
12069
+ var _a, _b, _c, _d, _e;
12070
+ if (!validateForm() || !onSave) return;
12071
+ const isEdit = Boolean(editData);
12072
+ const payload = isEdit ? { fileInstanceId: (_a = editData.fileInstanceId) != null ? _a : editData.FileInstanceId, currentStepId: Number(formData.currentStep), currentTaskInstanceId: Number(formData.currentTaskInstance), status: formData.status, priority: formData.priority, isActive: (_c = (_b = editData.isActive) != null ? _b : editData.IsActive) != null ? _c : true, updatedBy: (_e = (_d = editData.updatedBy) != null ? _d : editData.createdBy) != null ? _e : "System" } : { workflowId: Number(formData.workflow), businessEntityType: formData.businessEntityType, businessEntityId: Number(formData.businessEntity), hierarchyNodeId: Number(formData.hierarchyNode), currentStepId: Number(formData.currentStep), currentTaskInstanceId: Number(formData.currentTaskInstance), status: formData.status, priority: formData.priority, createdBy: "System" };
12073
+ setIsSubmitting(true);
12074
+ try {
12075
+ if (await onSave(payload, isEdit)) onClose();
12076
+ } finally {
12077
+ setIsSubmitting(false);
12078
+ }
12079
+ };
12018
12080
  const validateForm = () => {
12019
12081
  const newErrors = {};
12020
12082
  if (!formData.workflow) newErrors.workflow = "Workflow is required.";
@@ -12039,7 +12101,7 @@ function AddFileInstanceModal({ onClose }) {
12039
12101
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-4", children: [
12040
12102
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "fc:w-12 fc:h-12 fc:bg-indigo-50 fc:text-indigo-600 fc:rounded-xl fc:flex fc:items-center fc:justify-center fc:shadow-inner fc:border fc:border-indigo-100", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("svg", { className: "fc:w-6 fc:h-6", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h5l2 2h5a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2z" }) }) }),
12041
12103
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { children: [
12042
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("h2", { className: "fc:text-xl fc:font-extrabold fc:text-slate-800", children: "Add FileInstance" }),
12104
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("h2", { className: "fc:text-xl fc:font-extrabold fc:text-slate-800", children: editData ? "Edit FileInstance" : "Add FileInstance" }),
12043
12105
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { className: "fc:text-xs fc:text-slate-400 fc:mt-0.5", children: "Create a new File Instance and configure its details" })
12044
12106
  ] })
12045
12107
  ] }),
@@ -12075,9 +12137,13 @@ function AddFileInstanceModal({ onClose }) {
12075
12137
  },
12076
12138
  className: `fc:w-full fc:p-2.5 fc:border fc:rounded-xl fc:text-xs fc:bg-white focus:fc:outline-none focus:fc:ring-2 focus:fc:ring-indigo-500/20 focus:fc:border-indigo-500 fc:transition-all ${formData.workflow ? "fc:text-slate-800 fc:font-medium" : "fc:text-slate-400"} ${errors.workflow ? "fc:border-red-500" : "fc:border-slate-200"}`,
12077
12139
  children: [
12078
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: "Select Workflow" }),
12079
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Petition Workflow", children: "Petition Workflow" }),
12080
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Building Workflow", children: "Building Workflow" })
12140
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: isLoadingLookups ? "Loading workflows..." : "Select Workflow" }),
12141
+ workflows.map((workflow) => {
12142
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12143
+ const id = (_b = (_a = workflow.workflowId) != null ? _a : workflow.WorkflowId) != null ? _b : workflow.id;
12144
+ const name = (_h = (_g = (_f = (_e = (_d = (_c = workflow.workflowName) != null ? _c : workflow.WorkflowName) != null ? _d : workflow.name) != null ? _e : workflow.Name) != null ? _f : workflow.workflowCode) != null ? _g : workflow.WorkflowCode) != null ? _h : `Workflow ${id}`;
12145
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: String(id), children: name }, id);
12146
+ })
12081
12147
  ]
12082
12148
  }
12083
12149
  ),
@@ -12094,15 +12160,13 @@ function AddFileInstanceModal({ onClose }) {
12094
12160
  {
12095
12161
  value: formData.businessEntityType,
12096
12162
  onChange: (e) => {
12097
- setFormData(__spreadProps(__spreadValues({}, formData), { businessEntityType: e.target.value }));
12163
+ setFormData(__spreadProps(__spreadValues({}, formData), { businessEntityType: e.target.value, businessEntity: "" }));
12098
12164
  setErrors(__spreadProps(__spreadValues({}, errors), { businessEntityType: "" }));
12099
12165
  },
12100
12166
  className: `fc:w-full fc:p-2.5 fc:border fc:rounded-xl fc:text-xs fc:bg-white focus:fc:outline-none focus:fc:ring-2 focus:fc:ring-indigo-500/20 focus:fc:border-indigo-500 fc:transition-all ${formData.businessEntityType ? "fc:text-slate-800 fc:font-medium" : "fc:text-slate-400"} ${errors.businessEntityType ? "fc:border-red-500" : "fc:border-slate-200"}`,
12101
12167
  children: [
12102
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: "Select Type" }),
12103
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Application", children: "Application" }),
12104
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Petition", children: "Petition" }),
12105
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Complaint", children: "Complaint" })
12168
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: isLoadingLookups ? "Loading types..." : "Select Type" }),
12169
+ entityTypes.map((entityType) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: entityType, children: entityType }, entityType))
12106
12170
  ]
12107
12171
  }
12108
12172
  ),
@@ -12121,14 +12185,31 @@ function AddFileInstanceModal({ onClose }) {
12121
12185
  {
12122
12186
  value: formData.businessEntity,
12123
12187
  onChange: (e) => {
12124
- setFormData(__spreadProps(__spreadValues({}, formData), { businessEntity: e.target.value }));
12188
+ var _a, _b;
12189
+ const entity = businessEntities.find((item) => {
12190
+ var _a2, _b2;
12191
+ return String((_b2 = (_a2 = item.businessEntityId) != null ? _a2 : item.BusinessEntityId) != null ? _b2 : item.id) === e.target.value;
12192
+ });
12193
+ setFormData(__spreadProps(__spreadValues({}, formData), {
12194
+ businessEntity: e.target.value,
12195
+ businessEntityType: (_b = (_a = entity == null ? void 0 : entity.entityType) != null ? _a : entity == null ? void 0 : entity.EntityType) != null ? _b : formData.businessEntityType
12196
+ }));
12125
12197
  setErrors(__spreadProps(__spreadValues({}, errors), { businessEntity: "" }));
12126
12198
  },
12127
12199
  className: `fc:w-full fc:p-2.5 fc:border fc:rounded-xl fc:text-xs fc:bg-white focus:fc:outline-none focus:fc:ring-2 focus:fc:ring-indigo-500/20 focus:fc:border-indigo-500 fc:transition-all ${formData.businessEntity ? "fc:text-slate-800 fc:font-medium" : "fc:text-slate-400"} ${errors.businessEntity ? "fc:border-red-500" : "fc:border-slate-200"}`,
12128
12200
  children: [
12129
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: "Select Business Entity" }),
12130
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "APP-001 - Building Permission", children: "APP-001 - Building Permission" }),
12131
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "APP-002 - Citizen Petition", children: "APP-002 - Citizen Petition" })
12201
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: isLoadingLookups ? "Loading business entities..." : "Select Business Entity" }),
12202
+ visibleBusinessEntities.map((entity) => {
12203
+ var _a, _b, _c, _d, _e, _f;
12204
+ const id = (_b = (_a = entity.businessEntityId) != null ? _a : entity.BusinessEntityId) != null ? _b : entity.id;
12205
+ const displayNumber = (_d = (_c = entity.displayNumber) != null ? _c : entity.DisplayNumber) != null ? _d : id;
12206
+ const displayTitle = (_f = (_e = entity.displayTitle) != null ? _e : entity.DisplayTitle) != null ? _f : "Business Entity";
12207
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("option", { value: String(id), children: [
12208
+ displayNumber,
12209
+ " - ",
12210
+ displayTitle
12211
+ ] }, id);
12212
+ })
12132
12213
  ]
12133
12214
  }
12134
12215
  ),
@@ -12150,16 +12231,20 @@ function AddFileInstanceModal({ onClose }) {
12150
12231
  },
12151
12232
  className: `fc:w-full fc:p-2.5 fc:border fc:rounded-xl fc:text-xs fc:bg-white focus:fc:outline-none focus:fc:ring-2 focus:fc:ring-indigo-500/20 focus:fc:border-indigo-500 fc:transition-all ${formData.hierarchyNode ? "fc:text-slate-800 fc:font-medium" : "fc:text-slate-400"} ${errors.hierarchyNode ? "fc:border-red-500" : "fc:border-slate-200"}`,
12152
12233
  children: [
12153
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: "Select Hierarchy" }),
12154
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "District Office", children: "District Office" }),
12155
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Block Office", children: "Block Office" }),
12156
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Panchayat", children: "Panchayat" })
12234
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: isLoadingLookups ? "Loading hierarchy nodes..." : "Select Hierarchy" }),
12235
+ hierarchyNodes.map((node) => {
12236
+ var _a, _b, _c, _d, _e, _f;
12237
+ const id = (_b = (_a = node.hierarchyNodeId) != null ? _a : node.HierarchyNodeId) != null ? _b : node.id;
12238
+ const name = (_f = (_e = (_d = (_c = node.nodeName) != null ? _c : node.NodeName) != null ? _d : node.name) != null ? _e : node.Name) != null ? _f : `Hierarchy Node ${id}`;
12239
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: String(id), children: name }, id);
12240
+ })
12157
12241
  ]
12158
12242
  }
12159
12243
  ),
12160
12244
  errors.hierarchyNode && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { className: "fc:text-red-500 fc:text-[11px] fc:mt-1 fc:font-medium", children: errors.hierarchyNode })
12161
12245
  ] })
12162
12246
  ] }),
12247
+ errors.lookup && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { className: "fc:text-red-500 fc:text-[11px] fc:font-medium", children: errors.lookup }),
12163
12248
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "fc:grid fc:grid-cols-2 md:fc:grid-cols-2 fc:gap-5", children: [
12164
12249
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { children: [
12165
12250
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("label", { className: "fc:flex fc:items-center fc:gap-1.5 fc:text-xs fc:font-bold fc:text-slate-700 fc:mb-1.5", children: [
@@ -12178,8 +12263,8 @@ function AddFileInstanceModal({ onClose }) {
12178
12263
  className: `fc:w-full fc:p-2.5 fc:border fc:rounded-xl fc:text-xs fc:bg-white focus:fc:outline-none focus:fc:ring-2 focus:fc:ring-indigo-500/20 focus:fc:border-indigo-500 fc:transition-all ${formData.currentStep ? "fc:text-slate-800 fc:font-medium" : "fc:text-slate-400"} ${errors.currentStep ? "fc:border-red-500" : "fc:border-slate-200"}`,
12179
12264
  children: [
12180
12265
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "", children: "Select Step" }),
12181
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Scrutiny", children: "Scrutiny" }),
12182
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "Approval", children: "Approval" })
12266
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "1", children: "Scrutiny" }),
12267
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("option", { value: "2", children: "Approval" })
12183
12268
  ]
12184
12269
  }
12185
12270
  ),
@@ -12268,15 +12353,12 @@ function AddFileInstanceModal({ onClose }) {
12268
12353
  "button",
12269
12354
  {
12270
12355
  type: "button",
12271
- onClick: () => {
12272
- if (validateForm()) {
12273
- console.log("Form Submitted Successfully:", formData);
12274
- }
12275
- },
12356
+ onClick: handleSubmit,
12357
+ disabled: isSubmitting,
12276
12358
  className: "fc:px-6 fc:py-2.5 fc:bg-indigo-600 hover:fc:bg-indigo-700 fc:text-white fc:text-xs fc:font-bold fc:rounded-xl fc:shadow-md fc:shadow-indigo-500/20 hover:fc:shadow-indigo-500/30 fc:transition-all fc:flex fc:items-center fc:gap-2",
12277
12359
  children: [
12278
12360
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("svg", { className: "fc:w-3.5 fc:h-3.5", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" }) }),
12279
- "Save FileInstance"
12361
+ isSubmitting ? "Saving..." : editData ? "Update FileInstance" : "Save FileInstance"
12280
12362
  ]
12281
12363
  }
12282
12364
  )
@@ -12286,252 +12368,128 @@ function AddFileInstanceModal({ onClose }) {
12286
12368
  }
12287
12369
 
12288
12370
  // src/components/FileInstance/FileInstancemain.js
12371
+ init_ApiEndpointsProvider();
12372
+ init_ApiServicepackage();
12289
12373
  var import_jsx_runtime82 = require("react/jsx-runtime");
12290
- var FileInstances = [{
12291
- FileInstanceId: 1,
12292
- workflowId: 1,
12293
- BusinessEntityType: "Application",
12294
- BusinessEntityId: 5001,
12295
- HierarchyNodeId: 2,
12296
- CurrentStepId: 1,
12297
- CurrentTaskInstanceId: 1,
12298
- Status: "Approved",
12299
- Priority: "High"
12300
- }, {
12301
- FileInstanceId: 1,
12302
- workflowId: 1,
12303
- BusinessEntityType: "Application",
12304
- BusinessEntityId: 5001,
12305
- HierarchyNodeId: 2,
12306
- CurrentStepId: 1,
12307
- CurrentTaskInstanceId: 1,
12308
- Status: "Pending",
12309
- Priority: "High"
12310
- }, {
12311
- FileInstanceId: 1,
12312
- workflowId: 1,
12313
- BusinessEntityType: "Application",
12314
- BusinessEntityId: 5001,
12315
- HierarchyNodeId: 2,
12316
- CurrentStepId: 1,
12317
- CurrentTaskInstanceId: 1,
12318
- Status: "Pending",
12319
- Priority: "High"
12320
- }, {
12321
- FileInstanceId: 1,
12322
- workflowId: 1,
12323
- BusinessEntityType: "Application",
12324
- BusinessEntityId: 5001,
12325
- HierarchyNodeId: 2,
12326
- CurrentStepId: 1,
12327
- CurrentTaskInstanceId: 1,
12328
- Status: "Pending",
12329
- Priority: "High"
12330
- }, {
12331
- FileInstanceId: 1,
12332
- workflowId: 1,
12333
- BusinessEntityType: "Application",
12334
- BusinessEntityId: 5001,
12335
- HierarchyNodeId: 2,
12336
- CurrentStepId: 1,
12337
- CurrentTaskInstanceId: 1,
12338
- Status: "Pending",
12339
- Priority: "High"
12340
- }, {
12341
- FileInstanceId: 1,
12342
- workflowId: 1,
12343
- BusinessEntityType: "Application",
12344
- BusinessEntityId: 5001,
12345
- HierarchyNodeId: 2,
12346
- CurrentStepId: 1,
12347
- CurrentTaskInstanceId: 1,
12348
- Status: "Pending",
12349
- Priority: "High"
12350
- }, {
12351
- FileInstanceId: 1,
12352
- workflowId: 1,
12353
- BusinessEntityType: "Application",
12354
- BusinessEntityId: 5001,
12355
- HierarchyNodeId: 2,
12356
- CurrentStepId: 1,
12357
- CurrentTaskInstanceId: 1,
12358
- Status: "Pending",
12359
- Priority: "High"
12360
- }, {
12361
- FileInstanceId: 1,
12362
- workflowId: 1,
12363
- BusinessEntityType: "Application",
12364
- BusinessEntityId: 5001,
12365
- HierarchyNodeId: 2,
12366
- CurrentStepId: 1,
12367
- CurrentTaskInstanceId: 1,
12368
- Status: "Pending",
12369
- Priority: "High"
12370
- }, {
12371
- FileInstanceId: 1,
12372
- workflowId: 1,
12373
- BusinessEntityType: "Application",
12374
- BusinessEntityId: 5001,
12375
- HierarchyNodeId: 2,
12376
- CurrentStepId: 1,
12377
- CurrentTaskInstanceId: 1,
12378
- Status: "Pending",
12379
- Priority: "High"
12380
- }, {
12381
- FileInstanceId: 1,
12382
- workflowId: 1,
12383
- BusinessEntityType: "Application",
12384
- BusinessEntityId: 5001,
12385
- HierarchyNodeId: 2,
12386
- CurrentStepId: 1,
12387
- CurrentTaskInstanceId: 1,
12388
- Status: "Pending",
12389
- Priority: "High"
12390
- }, {
12391
- FileInstanceId: 1,
12392
- workflowId: 1,
12393
- BusinessEntityType: "Application",
12394
- BusinessEntityId: 5001,
12395
- HierarchyNodeId: 2,
12396
- CurrentStepId: 1,
12397
- CurrentTaskInstanceId: 1,
12398
- Status: "Pending",
12399
- Priority: "High"
12400
- }, {
12401
- FileInstanceId: 1,
12402
- workflowId: 1,
12403
- BusinessEntityType: "Application",
12404
- BusinessEntityId: 5001,
12405
- HierarchyNodeId: 2,
12406
- CurrentStepId: 1,
12407
- CurrentTaskInstanceId: 1,
12408
- Status: "Pending",
12409
- Priority: "High"
12410
- }, {
12411
- FileInstanceId: 1,
12412
- workflowId: 1,
12413
- BusinessEntityType: "Application",
12414
- BusinessEntityId: 5001,
12415
- HierarchyNodeId: 2,
12416
- CurrentStepId: 1,
12417
- CurrentTaskInstanceId: 1,
12418
- Status: "Pending",
12419
- Priority: "High"
12420
- }];
12374
+ var FILE_INSTANCE_ENDPOINTS = {
12375
+ create: "/api/flowcore/FileInstance/Create",
12376
+ update: "/api/flowcore/FileInstance/Update",
12377
+ getById: "/api/flowcore/FileInstance/GetById",
12378
+ getList: "/api/flowcore/FileInstance/GetList"
12379
+ };
12380
+ var getFileInstanceEndpoint = (action) => {
12381
+ var _a, _b, _c, _d;
12382
+ try {
12383
+ return (_d = (_c = (_b = (_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) == null ? void 0 : _b.fileInstance) == null ? void 0 : _c[action]) != null ? _d : FILE_INSTANCE_ENDPOINTS[action];
12384
+ } catch (e) {
12385
+ return FILE_INSTANCE_ENDPOINTS[action];
12386
+ }
12387
+ };
12388
+ var getFileInstanceByIdEndpoint = (id) => {
12389
+ const endpoint = getFileInstanceEndpoint("getById");
12390
+ return typeof endpoint === "function" ? endpoint(id) : `${endpoint}/${id}`;
12391
+ };
12392
+ var getRows2 = (response) => {
12393
+ var _a, _b, _c, _d, _e, _f, _g;
12394
+ 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;
12395
+ return Array.isArray(value) ? value : (_g = (_f = value == null ? void 0 : value.items) != null ? _f : value == null ? void 0 : value.records) != null ? _g : [];
12396
+ };
12397
+ var normalise2 = (item) => {
12398
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
12399
+ return __spreadProps(__spreadValues({}, item), { fileInstanceId: (_b = (_a = item.fileInstanceId) != null ? _a : item.FileInstanceId) != null ? _b : item.id, workflowId: (_d = (_c = item.workflowId) != null ? _c : item.WorkflowId) != null ? _d : "", businessEntityType: (_f = (_e = item.businessEntityType) != null ? _e : item.BusinessEntityType) != null ? _f : "", businessEntityId: (_h = (_g = item.businessEntityId) != null ? _g : item.BusinessEntityId) != null ? _h : "", hierarchyNodeId: (_j = (_i = item.hierarchyNodeId) != null ? _i : item.HierarchyNodeId) != null ? _j : "", currentStepId: (_l = (_k = item.currentStepId) != null ? _k : item.CurrentStepId) != null ? _l : "", currentTaskInstanceId: (_n = (_m = item.currentTaskInstanceId) != null ? _m : item.CurrentTaskInstanceId) != null ? _n : "", status: (_p = (_o = item.status) != null ? _o : item.Status) != null ? _p : "", priority: (_r = (_q = item.priority) != null ? _q : item.Priority) != null ? _r : "", isActive: (_t = (_s = item.isActive) != null ? _s : item.IsActive) != null ? _t : true });
12400
+ };
12421
12401
  function FileInstance() {
12422
- const handleRefresh = () => {
12423
- console.log("Refresh clicked");
12424
- };
12425
- const handleDownload = () => {
12426
- console.log("Download clicked");
12427
- };
12428
12402
  const tableRef = (0, import_react82.useRef)(null);
12403
+ const [rows, setRows] = (0, import_react82.useState)([]);
12429
12404
  const [showModal, setShowModal] = (0, import_react82.useState)(false);
12405
+ const [editingFile, setEditingFile] = (0, import_react82.useState)(null);
12430
12406
  const [pageSize, setPageSize] = (0, import_react82.useState)(5);
12431
- const [sortConfig, setSortConfig] = (0, import_react82.useState)({
12432
- key: "",
12433
- direction: "asc"
12434
- });
12435
- const handleSort = (key) => {
12436
- let direction = "asc";
12437
- if (sortConfig.key === key && sortConfig.direction === "asc") {
12438
- direction = "desc";
12407
+ const [search, setSearch] = (0, import_react82.useState)("");
12408
+ const [sortConfig, setSortConfig] = (0, import_react82.useState)({ key: "", direction: "asc" });
12409
+ const [refreshKey, setRefreshKey] = (0, import_react82.useState)(0);
12410
+ (0, import_react82.useEffect)(() => {
12411
+ const load = async () => {
12412
+ var _a, _b;
12413
+ try {
12414
+ const response = await getApiService().get(getFileInstanceEndpoint("getList"));
12415
+ setRows(getRows2(response).map(normalise2));
12416
+ } catch (error) {
12417
+ await import_sweetalert217.default.fire("Error", ((_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 file instances.", "error");
12418
+ }
12419
+ };
12420
+ load();
12421
+ }, [refreshKey]);
12422
+ const refresh = () => setRefreshKey((value) => value + 1);
12423
+ const saveFile = async (payload, isEdit) => {
12424
+ var _a, _b;
12425
+ try {
12426
+ const endpoint = getFileInstanceEndpoint(isEdit ? "update" : "create");
12427
+ await getApiService()[isEdit ? "put" : "post"](endpoint, payload);
12428
+ await import_sweetalert217.default.fire("Success", `File instance ${isEdit ? "updated" : "created"} successfully.`, "success");
12429
+ refresh();
12430
+ return true;
12431
+ } catch (error) {
12432
+ await import_sweetalert217.default.fire("Error", ((_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 ${isEdit ? "update" : "create"} file instance.`, "error");
12433
+ return false;
12439
12434
  }
12440
- setSortConfig({
12441
- key,
12442
- direction
12443
- });
12444
12435
  };
12445
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(import_jsx_runtime82.Fragment, { children: [
12446
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:p-5 fc:bg-[#f5f7fb] fc:font-sans fc:text-slate-700 fc:flex fc:flex-col", children: [
12447
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(CommonHeader, { title: "File Instance ", breadcrumbs: [{
12448
- label: "Dashboard",
12449
- href: "/dashboard"
12450
- }, {
12451
- label: "Runtime",
12452
- href: "/Sidebar"
12453
- }, {
12454
- label: "File Instance",
12455
- href: "/FileInstance"
12456
- }], buttonText: "Add File Instance", onButtonClick: () => setShowModal(true) }),
12457
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:bg-white fc:rounded-3xl fc:shadow-sm fc:border fc:border-slate-100 fc:p-6 fc:flex fc:flex-col fc:gap-6", children: [
12458
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:flex fc:justify-between fc:items-center fc:flex-wrap fc:gap-3", children: [
12459
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:relative fc:max-w-xs fc:w-full", children: [
12460
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "fc:absolute fc:inset-y-0 fc:left-0 fc:flex fc:items-center fc:pl-3.5 fc:pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("svg", { className: "fc:w-4 fc:h-5 fc:text-slate-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }) }) }),
12461
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("input", { type: "text", placeholder: "Search workflow name or code...", className: "fc:w-full fc:pl-10 fc:pr-4 fc:py-2.5 fc:shadow-md fc:border fc:border-slate-200 fc:rounded-xl fc:text-xs fc:text-[14px] fc:text-bold fc:bg-slate-50/50 focus:fc:fc:outline-none focus:fc:fc:ring-4 focus:fc:fc:ring-blue-500/10 focus:fc:fc:border-blue-500 fc:text-slate-700 fc:placeholder-slate-400 fc:transition-all" })
12462
- ] }),
12463
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-2 fc:text-xs fc:text-slate-500 fc:font-semibold ", children: [
12464
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Refresh_default, { onRefresh: handleRefresh }),
12465
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Download_default, { targetRef: tableRef, fileName: "file-instance" }),
12466
- /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("select", { value: pageSize, onChange: (e) => setPageSize(Number(e.target.value)), className: "fc:inline-flex fc:items-center fc:px-4 fc:py-2 fc:rounded-xl fc:bg-white fc:text-slate-700 fc:text-[14px] fc:font-semibold fc:border fc:border-slate-200 focus:fc:fc:outline-none fc:cursor-pointer fc:shadow-md", children: [
12467
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("option", { value: 5, children: "5 Rows" }),
12468
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("option", { value: 10, children: "10 Rows" }),
12469
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("option", { value: 25, children: "25 Rows" })
12470
- ] })
12436
+ const editFile = async (file) => {
12437
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12438
+ try {
12439
+ const response = await getApiService().get(getFileInstanceByIdEndpoint(file.fileInstanceId));
12440
+ const data = (_f = (_e = (_d = (_b = getRows2(response)[0]) != null ? _b : (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) != null ? _d : (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.result) != null ? _e : response == null ? void 0 : response.data) != null ? _f : response;
12441
+ setEditingFile(normalise2(data));
12442
+ setShowModal(true);
12443
+ } catch (error) {
12444
+ await import_sweetalert217.default.fire("Error", ((_h = (_g = error == null ? void 0 : error.response) == null ? void 0 : _g.data) == null ? void 0 : _h.message) || (error == null ? void 0 : error.message) || "Unable to load file instance details.", "error");
12445
+ }
12446
+ };
12447
+ const columns = [["FileInstanceId", "fileInstanceId"], ["WorkflowId", "workflowId"], ["BusinessEntityType", "businessEntityType"], ["BusinessEntityId", "businessEntityId"], ["HierarchyNodeId", "hierarchyNodeId"], ["CurrentStepId", "currentStepId"], ["CurrentTaskInstanceId", "currentTaskInstanceId"], ["Status", "status"], ["Priority", "priority"]];
12448
+ const sort = (key) => setSortConfig((current) => ({ key, direction: current.key === key && current.direction === "asc" ? "desc" : "asc" }));
12449
+ const visibleRows = rows.filter((item) => Object.values(item).join(" ").toLowerCase().includes(search.toLowerCase())).sort((a, b) => {
12450
+ var _a, _b;
12451
+ if (!sortConfig.key) return 0;
12452
+ const result = String((_a = a[sortConfig.key]) != null ? _a : "").localeCompare(String((_b = b[sortConfig.key]) != null ? _b : ""), void 0, { numeric: true });
12453
+ return sortConfig.direction === "asc" ? result : -result;
12454
+ });
12455
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:p-5 fc:bg-[#f5f7fb] fc:min-h-screen fc:font-sans fc:text-slate-700 fc:flex fc:flex-col", children: [
12456
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(CommonHeader, { title: "File Instance", breadcrumbs: [{ label: "Dashboard", href: "/dashboard" }, { label: "Runtime", href: "/Sidebar" }, { label: "File Instance", href: "/FileInstance" }], buttonText: "Add File Instance", onButtonClick: () => {
12457
+ setEditingFile(null);
12458
+ setShowModal(true);
12459
+ } }),
12460
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:bg-white fc:rounded-3xl fc:shadow-sm fc:border fc:border-slate-100 fc:p-6 fc:flex fc:flex-col fc:gap-6", children: [
12461
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:flex fc:justify-between fc:items-center fc:flex-wrap fc:gap-3", children: [
12462
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("input", { value: search, onChange: (event) => setSearch(event.target.value), type: "text", placeholder: "Search file instances...", className: "fc:max-w-xs fc:w-full fc:px-4 fc:py-2.5 fc:border fc:border-slate-200 fc:rounded-xl fc:text-sm" }),
12463
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:flex fc:items-center fc:gap-2", children: [
12464
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Refresh_default, { onRefresh: refresh }),
12465
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Download_default, { targetRef: tableRef, fileName: "file-instance" }),
12466
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("select", { value: pageSize, onChange: (event) => setPageSize(Number(event.target.value)), className: "fc:px-4 fc:py-2 fc:rounded-xl fc:border fc:border-slate-200", children: [
12467
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("option", { value: 5, children: "5 Rows" }),
12468
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("option", { value: 10, children: "10 Rows" }),
12469
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("option", { value: 25, children: "25 Rows" })
12471
12470
  ] })
12472
- ] }),
12473
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "fc:border fc:border-slate-200 fc:rounded-2xl fc:overflow-hidden fc:bg-white fc:shadow-md", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "fc:max-h-[350px] fc:overflow-y-auto fc:overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("table", { className: "fc:min-w-max fc:w-full fc:border-collapse", children: [
12474
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("thead", { className: "fc:bg-slate-50 fc:sticky fc:top-0 fc:z-10", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("tr", { className: "fc:text-[11px] fc:font-bold fc:uppercase fc:tracking-wider fc:text-slate-400", children: [{
12475
- label: "FileInstanceId",
12476
- key: "FileInstanceId"
12477
- }, {
12478
- label: "WorkflowId",
12479
- key: "workflowId"
12480
- }, {
12481
- label: "BusinessEntityType",
12482
- key: "BusinessEntityType"
12483
- }, {
12484
- label: "BusinessEntityId",
12485
- key: "BusinessEntityId"
12486
- }, {
12487
- label: "HierarchyNodeId",
12488
- key: "HierarchyNodeId"
12489
- }, {
12490
- label: "CurrentStepId",
12491
- key: "CurrentStepId"
12492
- }, {
12493
- label: "CurrentTaskInstanceId",
12494
- key: "CurrentTaskInstanceId"
12495
- }, {
12496
- label: "Status",
12497
- key: "Status"
12498
- }, {
12499
- label: "Priority",
12500
- key: "Priority"
12501
- }].map((column) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("th", { onClick: () => handleSort(column.key), className: "fc:px-6 fc:py-4 fc:text-left fc:text-xs fc:font-bold fc:text-slate-500 fc:uppercase fc:tracking-wider fc:cursor-pointer fc:select-none hover:fc:fc:bg-slate-100 fc:transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "fc:flex fc:items-center fc:justify-center fc:gap-2", children: [
12502
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { children: column.label }),
12503
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "fc:text-gray-400 fc:text-xs", children: sortConfig.key === column.key ? sortConfig.direction === "asc" ? "\u25B2" : "\u25BC" : "\u2195" })
12504
- ] }) }, column.key)) }) }),
12505
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("tbody", { children: FileInstances.slice(0, pageSize).map((item) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("tr", { className: "hover:fc:fc:bg-slate-50/80 fc:transition-colors fc:border-b fc:border-slate-100 last:fc:fc:border-0", children: [
12506
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:p-4 fc:border-b fc:border-slate-100 fc:text-[14px] fc:text-center fc:text-slate-600 fc:font-bold", children: item.FileInstanceId }),
12507
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-600 fc:font-bold", children: item.workflowId }),
12508
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-500 fc:font-semibold", children: item.BusinessEntityType }),
12509
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-[14px fc:text-slate-600 fc:font-bold", children: item.BusinessEntityId }),
12510
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-[14px] fc:text-slate-600 fc:font-bold", children: item.HierarchyNodeId }),
12511
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-600 fc:font-bold", children: item.CurrentStepId }),
12512
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-align fc:center fc:text-[14px] fc:text-slate-600 fc:font-bold", children: item.CurrentTaskInstanceId }),
12513
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:border-b fc:border-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
12514
- "span",
12515
- {
12516
- className: `fc:inline-flex fc:items-center fc:rounded-full fc:px-3 fc:py-1 fc:text-xs fc:font-semibold
12517
- ${item.Status === "Approved" ? "fc:bg-green-100 fc:text-green-700" : "fc:bg-red-100 fc:text-red-700"}`,
12518
- children: item.Status
12519
- }
12520
- ) }),
12521
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:border-b fc:border-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
12522
- "span",
12523
- {
12524
- className: `fc:inline-flex fc:items-center fc:rounded-full fc:px-3 fc:py-1 fc:text-xs fc:font-semibold
12525
- ${item.Priority === "High" ? "fc:bg-green-100 fc:text-green-700" : "fc:bg-red-100 fc:text-red-700"}`,
12526
- children: item.Priority
12527
- }
12528
- ) })
12529
- ] }, item.TransitionId)) })
12530
- ] }) }) }),
12531
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "fc:rounded-xl fc:bg-slate-50/50", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Footer, {}) })
12532
- ] })
12471
+ ] })
12472
+ ] }),
12473
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { ref: tableRef, className: "fc:border fc:border-slate-200 fc:rounded-2xl fc:overflow-auto", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("table", { className: "fc:min-w-max fc:w-full", children: [
12474
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("thead", { className: "fc:bg-slate-50", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("tr", { children: [
12475
+ columns.map(([label, key]) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("th", { onClick: () => sort(key), className: "fc:px-6 fc:py-4 fc:text-center fc:text-xs fc:cursor-pointer", children: [
12476
+ label,
12477
+ " ",
12478
+ sortConfig.key === key ? sortConfig.direction === "asc" ? "\u25B2" : "\u25BC" : "\u2195"
12479
+ ] }, key)),
12480
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("th", { className: "fc:px-6 fc:py-4 fc:text-center fc:text-xs", children: "Action" })
12481
+ ] }) }),
12482
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("tbody", { children: visibleRows.slice(0, pageSize).map((item) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("tr", { className: "fc:border-t fc:border-slate-100", children: [
12483
+ columns.map(([, key]) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: item[key] }, key)),
12484
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("td", { className: "fc:px-6 fc:py-4 fc:text-center", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("button", { onClick: () => editFile(item), className: "fc:bg-blue-50 hover:fc:bg-blue-100 fc:text-blue-600 fc:px-3 fc:py-1 fc:rounded-lg fc:text-xs fc:font-semibold", children: "Edit" }) })
12485
+ ] }, item.fileInstanceId)) })
12486
+ ] }) }),
12487
+ /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Footer, {})
12533
12488
  ] }),
12534
- showModal && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AddFileInstanceModal, { onClose: () => setShowModal(false) })
12489
+ showModal && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AddFileInstanceModal, { editData: editingFile, onClose: () => {
12490
+ setShowModal(false);
12491
+ setEditingFile(null);
12492
+ }, onSave: saveFile })
12535
12493
  ] });
12536
12494
  }
12537
12495
 
@@ -12996,12 +12954,12 @@ function AssignmentRuleMain() {
12996
12954
 
12997
12955
  // src/components/Workflow_Step_Hierarchy_Mapping/Workflow_Step_Hierarchy_Mapping_Main.jsx
12998
12956
  var import_react87 = __toESM(require("react"));
12999
- var import_sweetalert216 = __toESM(require("sweetalert2"));
12957
+ var import_sweetalert218 = __toESM(require("sweetalert2"));
13000
12958
  init_ApiEndpointsProvider();
13001
12959
  init_ApiServicepackage();
13002
12960
  var import_jsx_runtime87 = require("react/jsx-runtime");
13003
12961
  var emptyForm = { workflowStepId: "", hierarchyNodeId: "", isActive: "true" };
13004
- var getRows = (result) => {
12962
+ var getRows3 = (result) => {
13005
12963
  var _a, _b, _c, _d, _e, _f, _g;
13006
12964
  const value = (_e = (_d = (_c = (_a = result == null ? void 0 : result.data) == null ? void 0 : _a.data) != null ? _c : (_b = result == null ? void 0 : result.data) == null ? void 0 : _b.result) != null ? _d : result == null ? void 0 : result.data) != null ? _e : result;
13007
12965
  return Array.isArray(value) ? value : (_g = (_f = value == null ? void 0 : value.items) != null ? _f : value == null ? void 0 : value.records) != null ? _g : [];
@@ -13066,13 +13024,13 @@ function Workflow_Step_Hierarchy_Mapping_Main() {
13066
13024
  stepEndpoint ? getApiService().get(stepEndpoint) : Promise.resolve(null),
13067
13025
  nodeEndpoint ? getApiService().get(nodeEndpoint) : Promise.resolve(null)
13068
13026
  ]);
13069
- setMappings(getRows(mappingResult));
13070
- setWorkflowSteps(workflowStepResult ? getRows(workflowStepResult) : []);
13027
+ setMappings(getRows3(mappingResult));
13028
+ setWorkflowSteps(workflowStepResult ? getRows3(workflowStepResult) : []);
13071
13029
  setHierarchyNodes(
13072
- hierarchyNodeResult ? getRows(hierarchyNodeResult) : []
13030
+ hierarchyNodeResult ? getRows3(hierarchyNodeResult) : []
13073
13031
  );
13074
13032
  } catch (error) {
13075
- await import_sweetalert216.default.fire(
13033
+ await import_sweetalert218.default.fire(
13076
13034
  "Error",
13077
13035
  ((_j = (_i = error == null ? void 0 : error.response) == null ? void 0 : _i.data) == null ? void 0 : _j.message) || (error == null ? void 0 : error.message) || "Unable to load workflow step hierarchy mappings.",
13078
13036
  "error"
@@ -13103,7 +13061,7 @@ function Workflow_Step_Hierarchy_Mapping_Main() {
13103
13061
  var _a, _b, _c;
13104
13062
  event.preventDefault();
13105
13063
  if (!formData.workflowStepId || !formData.hierarchyNodeId)
13106
- return import_sweetalert216.default.fire(
13064
+ return import_sweetalert218.default.fire(
13107
13065
  "Required fields",
13108
13066
  "Please select a workflow step and hierarchy node.",
13109
13067
  "warning"
@@ -13128,7 +13086,7 @@ function Workflow_Step_Hierarchy_Mapping_Main() {
13128
13086
  updatedBy: "System"
13129
13087
  } : { createdBy: "System" });
13130
13088
  await getApiService()[editingMapping ? "put" : "post"](endpoint, payload);
13131
- await import_sweetalert216.default.fire(
13089
+ await import_sweetalert218.default.fire(
13132
13090
  "Success",
13133
13091
  `Workflow step hierarchy mapping ${editingMapping ? "updated" : "created"} successfully.`,
13134
13092
  "success"
@@ -13136,7 +13094,7 @@ function Workflow_Step_Hierarchy_Mapping_Main() {
13136
13094
  setIsModalOpen(false);
13137
13095
  setRefreshKey((previous) => previous + 1);
13138
13096
  } catch (error) {
13139
- await import_sweetalert216.default.fire(
13097
+ await import_sweetalert218.default.fire(
13140
13098
  "Error",
13141
13099
  ((_c = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || (error == null ? void 0 : error.message) || "Unable to save workflow step hierarchy mapping.",
13142
13100
  "error"
@@ -13147,7 +13105,7 @@ function Workflow_Step_Hierarchy_Mapping_Main() {
13147
13105
  };
13148
13106
  const handleDelete = async (mapping) => {
13149
13107
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
13150
- const confirmation = await import_sweetalert216.default.fire({
13108
+ const confirmation = await import_sweetalert218.default.fire({
13151
13109
  title: "Delete mapping?",
13152
13110
  text: "This mapping will be marked inactive.",
13153
13111
  icon: "warning",
@@ -13177,14 +13135,14 @@ function Workflow_Step_Hierarchy_Mapping_Main() {
13177
13135
  isActive: false,
13178
13136
  updatedBy: "System"
13179
13137
  });
13180
- await import_sweetalert216.default.fire(
13138
+ await import_sweetalert218.default.fire(
13181
13139
  "Deleted",
13182
13140
  "Workflow step hierarchy mapping has been deactivated.",
13183
13141
  "success"
13184
13142
  );
13185
13143
  setRefreshKey((previous) => previous + 1);
13186
13144
  } catch (error) {
13187
- await import_sweetalert216.default.fire(
13145
+ await import_sweetalert218.default.fire(
13188
13146
  "Error",
13189
13147
  ((_i = (_h = error == null ? void 0 : error.response) == null ? void 0 : _h.data) == null ? void 0 : _i.message) || (error == null ? void 0 : error.message) || "Unable to delete workflow step hierarchy mapping.",
13190
13148
  "error"
@@ -13552,13 +13510,13 @@ var documentItems = [{
13552
13510
  icon: import_react89.RiFileSettingsLine
13553
13511
  }];
13554
13512
  var fileItems = [{
13555
- name: "File Instance",
13556
- component: "FileInstanceMain",
13557
- icon: import_react89.RiFileList3Line
13558
- }, {
13559
13513
  name: "Business Entity",
13560
13514
  component: "BusinessEntitymain",
13561
13515
  icon: import_react89.RiFileList3Line
13516
+ }, {
13517
+ name: "File Instance",
13518
+ component: "FileInstanceMain",
13519
+ icon: import_react89.RiFileList3Line
13562
13520
  }, {
13563
13521
  name: "File Pool",
13564
13522
  component: "FilePoolMain",