flowcore-fn 9.2.5 → 9.2.7

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.
@@ -1029,7 +1029,8 @@ function Workflow() {
1029
1029
  }
1030
1030
 
1031
1031
  // src/components/workflow-type/WorkflowTypeMains.js
1032
- import React15, { useState as useState9, useRef as useRef3 } from "react";
1032
+ import React15, { useCallback, useEffect as useEffect5, useRef as useRef3, useState as useState9 } from "react";
1033
+ import Swal2 from "sweetalert2";
1033
1034
 
1034
1035
  // src/components/workflow-type/SearchBar.jsx
1035
1036
  import React10 from "react";
@@ -1056,61 +1057,255 @@ function SearchBar2({
1056
1057
  }
1057
1058
 
1058
1059
  // src/components/workflow-type/WorkflowTypeTable.jsx
1059
- import React13, { useState as useState7, useEffect as useEffect4 } from "react";
1060
-
1061
- // src/components/workflow-type/DeleteWorkflowType.jsx
1062
- import React11 from "react";
1060
+ import React11, { useEffect as useEffect3, useMemo, useState as useState6 } from "react";
1063
1061
  import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1064
- var DeleteWorkflowType = ({
1065
- isOpen,
1066
- onClose,
1067
- onConfirm,
1068
- itemData
1069
- }) => {
1070
- if (!isOpen) return null;
1071
- return /* @__PURE__ */ jsx11("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:bg-black/40 fc:backdrop-blur-sm fc:p-4 fc:animate-in fc:fade-in fc:duration-200", children: /* @__PURE__ */ jsxs10("div", { className: "fc:relative fc:w-full fc:max-w-md fc:bg-white fc:rounded-3xl fc:shadow-2xl fc:border fc:border-gray-100 fc:overflow-hidden", children: [
1072
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: onClose, className: "fc:absolute fc:top-4 fc:right-4 fc:z-10 fc:flex fc:items-center fc:justify-center fc:w-8 fc:h-8 fc:rounded-full fc:text-gray-400 hover:fc:fc:text-gray-600 hover:fc:fc:bg-gray-100 fc:transition", children: "\u2715" }),
1073
- /* @__PURE__ */ jsxs10("div", { className: "fc:p-8 fc:text-center", children: [
1074
- /* @__PURE__ */ jsx11("div", { className: "fc:mx-auto fc:mb-4 fc:flex fc:h-14 fc:w-14 fc:items-center fc:justify-center fc:rounded-2xl fc:bg-red-50 fc:border fc:border-red-100 fc:text-red-500 fc:shadow-inner", children: /* @__PURE__ */ jsx11("span", { className: "fc:text-2xl", children: "\u26A0\uFE0F" }) }),
1075
- /* @__PURE__ */ jsx11("h3", { className: "fc:text-xl fc:font-bold fc:text-gray-900 fc:tracking-tight fc:mb-2", children: "Delete Configuration" }),
1076
- /* @__PURE__ */ jsxs10("p", { className: "fc:text-sm fc:text-gray-500 fc:leading-relaxed fc:px-2 fc:mb-6", children: [
1077
- "Are you sure you want to delete",
1078
- " ",
1079
- /* @__PURE__ */ jsxs10("span", { className: "fc:font-semibold fc:text-gray-900 fc:bg-gray-100 fc:px-2 fc:py-0.5 fc:rounded-md", children: [
1080
- '"',
1081
- (itemData == null ? void 0 : itemData.workflowTypeName) || (itemData == null ? void 0 : itemData.WorkflowTypeName) || "this item",
1082
- '"'
1062
+ function WorkflowTypeTable({ data = [], isLoading, pageSize, searchQuery = "", currentPage, setCurrentPage, setTotalEntries, onEdit, onDelete }) {
1063
+ const [sortOrder, setSortOrder] = useState6("asc");
1064
+ const [sortKey, setSortKey] = useState6("workflowTypeId");
1065
+ const handleSort = (columnKey) => {
1066
+ const isAsc = sortKey === columnKey && sortOrder === "asc";
1067
+ setSortOrder(isAsc ? "desc" : "asc");
1068
+ setSortKey(columnKey);
1069
+ };
1070
+ const filteredData = useMemo(() => {
1071
+ const query = searchQuery.toLowerCase();
1072
+ return data.filter((item) => [item.workflowTypeName, item.workflowTypeCode, item.description].some((value) => String(value || "").toLowerCase().includes(query)));
1073
+ }, [data, searchQuery]);
1074
+ const sortedData = useMemo(() => [...filteredData].sort((a, b) => {
1075
+ var _a, _b;
1076
+ const left = (_a = a[sortKey]) != null ? _a : "";
1077
+ const right = (_b = b[sortKey]) != null ? _b : "";
1078
+ if (left < right) return sortOrder === "asc" ? -1 : 1;
1079
+ if (left > right) return sortOrder === "asc" ? 1 : -1;
1080
+ return 0;
1081
+ }), [filteredData, sortKey, sortOrder]);
1082
+ useEffect3(() => {
1083
+ setTotalEntries == null ? void 0 : setTotalEntries(filteredData.length);
1084
+ }, [filteredData.length, setTotalEntries]);
1085
+ const totalPages = Math.ceil(sortedData.length / pageSize) || 1;
1086
+ useEffect3(() => {
1087
+ if (currentPage > totalPages) setCurrentPage(totalPages);
1088
+ }, [currentPage, setCurrentPage, totalPages]);
1089
+ const startIndex = (currentPage - 1) * pageSize;
1090
+ const visibleData = sortedData.slice(startIndex, startIndex + pageSize);
1091
+ const pageNumbers = Array.from({ length: totalPages }, (_, index) => index + 1);
1092
+ const sortIcon = (key) => sortKey === key ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25B2";
1093
+ return /* @__PURE__ */ jsxs10("div", { className: "fc:space-y-5", children: [
1094
+ /* @__PURE__ */ jsx11("div", { className: "fc:w-full fc:overflow-x-hidden fc:border fc:border-slate-200 fc:rounded-2xl fc:shadow-sm fc:max-h-[420px] fc:overflow-y-auto", children: /* @__PURE__ */ jsxs10("table", { className: "fc:w-full fc:text-left fc:border-collapse fc:bg-white fc:table-fixed", children: [
1095
+ /* @__PURE__ */ jsx11("thead", { className: "fc:sticky fc:top-0 fc:z-10 fc:bg-slate-50 fc:shadow-[0_1px_0_0_rgba(226,232,240,1)]", children: /* @__PURE__ */ jsxs10("tr", { className: "fc:text-xs fc:font-bold fc:tracking-wider fc:text-slate-500", children: [
1096
+ /* @__PURE__ */ jsxs10("th", { onClick: () => handleSort("workflowTypeId"), className: "fc:py-3 fc:px-2 fc:text-sm fc:text-center fc:bg-slate-50 fc:cursor-pointer fc:select-none fc:w-[6%]", children: [
1097
+ "ID ",
1098
+ sortIcon("workflowTypeId")
1083
1099
  ] }),
1084
- "? This action cannot be undone."
1100
+ /* @__PURE__ */ jsxs10("th", { onClick: () => handleSort("workflowTypeCode"), className: "fc:py-3 fc:px-3 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:w-[16%]", children: [
1101
+ "Code ",
1102
+ sortIcon("workflowTypeCode")
1103
+ ] }),
1104
+ /* @__PURE__ */ jsxs10("th", { onClick: () => handleSort("workflowTypeName"), className: "fc:py-3 fc:px-3 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:w-[20%]", children: [
1105
+ "Name ",
1106
+ sortIcon("workflowTypeName")
1107
+ ] }),
1108
+ /* @__PURE__ */ jsxs10("th", { onClick: () => handleSort("description"), className: "fc:py-3 fc:px-3 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:w-[22%]", children: [
1109
+ "Description ",
1110
+ sortIcon("description")
1111
+ ] }),
1112
+ /* @__PURE__ */ jsx11("th", { className: "fc:py-3 fc:px-2 fc:text-sm fc:bg-slate-50 fc:text-center fc:w-[12%]", children: "Status" }),
1113
+ /* @__PURE__ */ jsxs10("th", { onClick: () => handleSort("createdOn"), className: "fc:py-3 fc:px-2 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:text-center fc:w-[12%]", children: [
1114
+ "Created On ",
1115
+ sortIcon("createdOn")
1116
+ ] }),
1117
+ /* @__PURE__ */ jsx11("th", { className: "fc:py-3 fc:px-2 fc:text-sm fc:bg-slate-50 fc:text-center fc:w-[12%]", children: "Action" })
1118
+ ] }) }),
1119
+ /* @__PURE__ */ jsx11("tbody", { className: "fc:divide-y fc:divide-slate-100 fc:text-xs fc:text-slate-600", children: isLoading ? /* @__PURE__ */ jsx11("tr", { children: /* @__PURE__ */ jsx11("td", { colSpan: "7", className: "fc:py-8 fc:text-center fc:text-sm fc:text-slate-500", children: "Loading..." }) }) : visibleData.length === 0 ? /* @__PURE__ */ jsx11("tr", { children: /* @__PURE__ */ jsx11("td", { colSpan: "7", className: "fc:py-8 fc:text-center fc:text-sm fc:text-slate-500", children: "No workflow types found." }) }) : visibleData.map((item, index) => /* @__PURE__ */ jsxs10("tr", { className: "hover:fc:fc:bg-slate-50/50 fc:transition-colors", children: [
1120
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-2 fc:text-center fc:text-sm fc:font-medium fc:text-slate-700", children: startIndex + index + 1 }),
1121
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-3 fc:font-mono fc:text-sm fc:text-slate-700 fc:font-medium fc:break-words", children: item.workflowTypeCode }),
1122
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-3 fc:font-medium fc:text-slate-700 fc:text-sm fc:break-words", children: item.workflowTypeName }),
1123
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-3 fc:text-slate-700 fc:text-sm fc:break-words", children: item.description }),
1124
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-2 fc:text-center", children: /* @__PURE__ */ jsx11("span", { className: `fc:px-2 fc:py-1 fc:text-[13px] fc:font-semibold fc:rounded-full fc:inline-block ${item.isActive ? "fc:bg-emerald-100 fc:text-emerald-700 fc:border fc:border-emerald-200" : "fc:bg-rose-100 fc:text-rose-700 fc:border fc:border-rose-200"}`, children: item.isActive ? "Active" : "Inactive" }) }),
1125
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-2 fc:text-center fc:text-slate-700 fc:text-[13px] fc:font-mono", children: item.createdOn }),
1126
+ /* @__PURE__ */ jsx11("td", { className: "fc:py-3 fc:px-2 fc:text-center", children: /* @__PURE__ */ jsxs10("div", { className: "fc:flex fc:items-center fc:justify-center fc:gap-2", children: [
1127
+ /* @__PURE__ */ jsx11("button", { onClick: () => onEdit == null ? void 0 : onEdit(item), className: "fc:px-3 fc:py-1 fc:bg-blue-100/70 hover:fc:fc:bg-blue-200/80 fc:text-blue-600 fc:font-semibold fc:text-xs fc:rounded-full fc:transition-all fc:duration-150 fc:cursor-pointer", children: "Edit" }),
1128
+ /* @__PURE__ */ jsx11("button", { onClick: () => onDelete == null ? void 0 : onDelete(item), className: "fc:px-3 fc:py-1 fc:bg-rose-100/70 hover:fc:fc:bg-rose-200/80 fc:text-rose-600 fc:font-semibold fc:text-xs fc:rounded-full fc:transition-all fc:duration-150 fc:cursor-pointer", children: "Delete" })
1129
+ ] }) })
1130
+ ] }, item.workflowTypeId)) })
1131
+ ] }) }),
1132
+ /* @__PURE__ */ jsxs10("div", { className: "fc:flex fc:items-center fc:justify-end fc:gap-1 fc:text-[13px] fc:text-slate-700 fc:font-normal fc:mt-4 fc:bg-slate-50/50 fc:p-3 fc:rounded-xl fc:border fc:border-slate-100", children: [
1133
+ /* @__PURE__ */ jsx11("button", { onClick: () => setCurrentPage((previous) => Math.max(previous - 1, 1)), disabled: currentPage === 1, className: "fc:px-2 fc:py-1 fc:text-[15px] fc:border fc:border-slate-200 fc:rounded-lg fc:bg-white fc:text-slate-600 fc:shadow-sm fc:transition-all fc:duration-200 fc:hover:bg-blue-600 fc:hover:text-white fc:hover:border-blue-600", children: "\u2039 Prev" }),
1134
+ pageNumbers.map((pageNumber) => /* @__PURE__ */ jsx11("button", { onClick: () => setCurrentPage(pageNumber), className: `fc:px-2 fc:py-1 fc:text-[15px] fc:border fc:border-slate-200 fc:rounded-lg fc:bg-white fc:text-slate-600 fc:shadow-sm fc:transition-all fc:duration-200 fc:hover:bg-blue-600 fc:hover:text-white fc:hover:border-blue-600${currentPage === pageNumber ? "bg-blue-600 text-white font-medium shadow-sm" : "text-slate-600 hover:bg-slate-100"}`, children: pageNumber }, pageNumber)),
1135
+ /* @__PURE__ */ jsx11("button", { onClick: () => setCurrentPage((previous) => Math.min(previous + 1, totalPages)), disabled: currentPage === totalPages, className: "fc:px-2 fc:py-1 fc:text-[15px] fc:border fc:border-slate-200 fc:rounded-lg fc:bg-white fc:text-slate-600 fc:shadow-sm fc:transition-all fc:duration-200 fc:hover:bg-blue-600 fc:hover:text-white fc:hover:border-blue-600", children: "Next \u203A" })
1136
+ ] })
1137
+ ] });
1138
+ }
1139
+
1140
+ // src/components/workflow-type/AddWorkflowTypeModal.jsx
1141
+ import React12, { useState as useState7 } from "react";
1142
+ import Swal from "sweetalert2";
1143
+
1144
+ // src/components/Service/ApiEndpointsProvider.js
1145
+ var STORAGE_KEY = "FLOWCORE_API_ENDPOINTS";
1146
+ var apiEndpoints = null;
1147
+ var ApiEndpointsProvider = ({ apiEndpoints: endpoints }) => {
1148
+ if (typeof window !== "undefined" && endpoints) {
1149
+ apiEndpoints = endpoints;
1150
+ sessionStorage.setItem(
1151
+ STORAGE_KEY,
1152
+ JSON.stringify(endpoints)
1153
+ );
1154
+ }
1155
+ return null;
1156
+ };
1157
+ var getApiEndpoints = () => {
1158
+ if (apiEndpoints) {
1159
+ return apiEndpoints;
1160
+ }
1161
+ if (typeof window !== "undefined") {
1162
+ const data = sessionStorage.getItem(STORAGE_KEY);
1163
+ if (data) {
1164
+ apiEndpoints = JSON.parse(data);
1165
+ return apiEndpoints;
1166
+ }
1167
+ }
1168
+ throw new Error(
1169
+ "Api Endpoints not initialized. Please render <ApiEndpointsProvider apiEndpoints={ApiEndPoints} /> once before using FlowCore."
1170
+ );
1171
+ };
1172
+ var ApiEndpointsProvider_default = ApiEndpointsProvider;
1173
+
1174
+ // src/components/Service/ApiServicepackage.js
1175
+ var apiService = null;
1176
+ var ApiServicepackage = ({ apiService: service }) => {
1177
+ if (service) {
1178
+ apiService = service;
1179
+ }
1180
+ return null;
1181
+ };
1182
+ var getApiService = () => {
1183
+ if (apiService) {
1184
+ return apiService;
1185
+ }
1186
+ throw new Error(
1187
+ "ApiService not initialized. Please render <ApiServicepackage apiService={ApiService} /> once before using FlowCore."
1188
+ );
1189
+ };
1190
+ var ApiServicepackage_default = ApiServicepackage;
1191
+
1192
+ // src/components/workflow-type/AddWorkflowTypeModal.jsx
1193
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1194
+ var initialFormData = {
1195
+ workflowTypeCode: "",
1196
+ workflowTypeName: "",
1197
+ description: "",
1198
+ createdBy: ""
1199
+ };
1200
+ var AddWorkflowTypeModal = ({ isOpen, onClose, onSave, createdBy = "" }) => {
1201
+ const [formData, setFormData] = useState7(__spreadProps(__spreadValues({}, initialFormData), {
1202
+ createdBy
1203
+ }));
1204
+ const [errors, setErrors] = useState7({});
1205
+ const [isSubmitting, setIsSubmitting] = useState7(false);
1206
+ const [submitError, setSubmitError] = useState7("");
1207
+ const handleChange = ({ target: { name, value } }) => {
1208
+ if (name === "description" && value.length > 500) return;
1209
+ setFormData((previous) => __spreadProps(__spreadValues({}, previous), { [name]: value }));
1210
+ setErrors((previous) => __spreadProps(__spreadValues({}, previous), { [name]: "" }));
1211
+ setSubmitError("");
1212
+ };
1213
+ const validateForm = () => {
1214
+ const nextErrors = {};
1215
+ if (!formData.workflowTypeCode.trim()) nextErrors.workflowTypeCode = "Workflow type code is required";
1216
+ if (!formData.workflowTypeName.trim()) nextErrors.workflowTypeName = "Workflow type name is required";
1217
+ if (!formData.createdBy.trim()) nextErrors.createdBy = "Created by is required";
1218
+ setErrors(nextErrors);
1219
+ return Object.keys(nextErrors).length === 0;
1220
+ };
1221
+ const handleClose = () => {
1222
+ if (!isSubmitting) onClose();
1223
+ };
1224
+ const handleSubmit = async (event) => {
1225
+ var _a, _b, _c, _d, _e, _f, _g;
1226
+ event.preventDefault();
1227
+ if (!validateForm()) return;
1228
+ const payload = {
1229
+ workflowTypeCode: formData.workflowTypeCode.trim().toUpperCase(),
1230
+ workflowTypeName: formData.workflowTypeName.trim(),
1231
+ description: formData.description.trim(),
1232
+ createdBy: formData.createdBy.trim()
1233
+ };
1234
+ try {
1235
+ setIsSubmitting(true);
1236
+ setSubmitError("");
1237
+ const endpoints = getApiEndpoints();
1238
+ const endpoint = (_b = (_a = endpoints == null ? void 0 : endpoints.flowCore) == null ? void 0 : _a.workflowType) == null ? void 0 : _b.create;
1239
+ if (!endpoint) throw new Error("Create workflow type endpoint is not configured.");
1240
+ const response = await getApiService().post(endpoint, payload);
1241
+ await (onSave == null ? void 0 : onSave((_c = response == null ? void 0 : response.data) != null ? _c : response));
1242
+ setFormData(__spreadProps(__spreadValues({}, initialFormData), { createdBy }));
1243
+ setErrors({});
1244
+ onClose();
1245
+ } catch (error) {
1246
+ const message = ((_e = (_d = error == null ? void 0 : error.response) == null ? void 0 : _d.data) == null ? void 0 : _e.message) || ((_g = (_f = error == null ? void 0 : error.response) == null ? void 0 : _f.data) == null ? void 0 : _g.title) || (error == null ? void 0 : error.message) || "Unable to create workflow type. Please try again.";
1247
+ setSubmitError(message);
1248
+ await Swal.fire("Error", message, "error");
1249
+ } finally {
1250
+ setIsSubmitting(false);
1251
+ }
1252
+ };
1253
+ if (!isOpen) return null;
1254
+ return /* @__PURE__ */ jsx12("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:bg-black/20 fc:p-4 fc:backdrop-blur-sm", children: /* @__PURE__ */ jsxs11("div", { className: "fc:w-full fc:max-w-xl fc:overflow-hidden fc:rounded-2xl fc:border fc:border-gray-100 fc:bg-white fc:shadow-2xl", children: [
1255
+ /* @__PURE__ */ jsxs11("div", { className: "fc:flex fc:items-center fc:justify-between fc:border-b fc:border-gray-100 fc:px-6 fc:py-4", children: [
1256
+ /* @__PURE__ */ jsxs11("div", { children: [
1257
+ /* @__PURE__ */ jsx12("h2", { className: "fc:text-xl fc:font-bold fc:text-gray-800", children: "Add Workflow Type" }),
1258
+ /* @__PURE__ */ jsx12("p", { className: "fc:text-xs fc:text-gray-400", children: "Create a new workflow type" })
1085
1259
  ] }),
1086
- /* @__PURE__ */ jsxs10("div", { className: "fc:flex fc:items-center fc:gap-3", children: [
1087
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: onClose, className: "fc:w-1/2 fc:py-2.5 fc:px-4 fc:text-sm fc:font-semibold fc:text-gray-700 fc:bg-gray-100 hover:fc:fc:bg-gray-200 fc:rounded-xl fc:transition", children: "Cancel" }),
1088
- /* @__PURE__ */ jsx11("button", { type: "button", onClick: () => {
1089
- onConfirm(itemData);
1090
- onClose();
1091
- }, className: "fc:w-1/2 fc:py-2.5 fc:px-4 fc:text-sm fc:font-semibold fc:text-white fc:bg-red-600 hover:fc:fc:bg-red-700 fc:rounded-xl fc:shadow-md fc:shadow-red-500/20 fc:transition", children: "Delete" })
1260
+ /* @__PURE__ */ jsx12("button", { type: "button", onClick: handleClose, disabled: isSubmitting, "aria-label": "Close", className: "fc:text-xl fc:text-gray-400 hover:fc:text-gray-600", children: "\xD7" })
1261
+ ] }),
1262
+ /* @__PURE__ */ jsxs11("form", { onSubmit: handleSubmit, className: "fc:space-y-4 fc:p-6", children: [
1263
+ /* @__PURE__ */ jsxs11("div", { className: "fc:grid fc:grid-cols-2 fc:gap-4", children: [
1264
+ /* @__PURE__ */ jsx12(FormField, { label: "Workflow Type Code", required: true, error: errors.workflowTypeCode, children: /* @__PURE__ */ jsx12("input", { name: "workflowTypeCode", value: formData.workflowTypeCode, onChange: handleChange, placeholder: "e.g. PETITION", className: inputClass(errors.workflowTypeCode) }) }),
1265
+ /* @__PURE__ */ jsx12(FormField, { label: "Workflow Type Name", required: true, error: errors.workflowTypeName, children: /* @__PURE__ */ jsx12("input", { name: "workflowTypeName", value: formData.workflowTypeName, onChange: handleChange, placeholder: "Enter workflow type name", className: inputClass(errors.workflowTypeName) }) })
1266
+ ] }),
1267
+ /* @__PURE__ */ jsx12(FormField, { label: "Created By", required: true, error: errors.createdBy, children: /* @__PURE__ */ jsx12("input", { name: "createdBy", value: formData.createdBy, onChange: handleChange, placeholder: "Enter user name or ID", className: inputClass(errors.createdBy) }) }),
1268
+ /* @__PURE__ */ jsx12(FormField, { label: "Description", children: /* @__PURE__ */ jsxs11("div", { className: "fc:relative", children: [
1269
+ /* @__PURE__ */ jsx12("textarea", { name: "description", rows: "3", value: formData.description, onChange: handleChange, placeholder: "Enter description", className: "fc:w-full fc:resize-none fc:rounded-xl fc:border fc:border-slate-200 fc:p-3 fc:text-sm fc:text-slate-700 fc:outline-none focus:fc:border-indigo-500" }),
1270
+ /* @__PURE__ */ jsxs11("span", { className: "fc:absolute fc:bottom-2 fc:right-3 fc:text-xs fc:text-gray-400", children: [
1271
+ formData.description.length,
1272
+ "/500"
1273
+ ] })
1274
+ ] }) }),
1275
+ submitError && /* @__PURE__ */ jsx12("p", { role: "alert", className: "fc:rounded-lg fc:bg-red-50 fc:p-3 fc:text-sm fc:text-red-600", children: submitError }),
1276
+ /* @__PURE__ */ jsxs11("div", { className: "fc:flex fc:justify-end fc:gap-3 fc:border-t fc:border-gray-100 fc:pt-4", children: [
1277
+ /* @__PURE__ */ jsx12("button", { type: "button", onClick: handleClose, disabled: isSubmitting, className: "fc:rounded-xl fc:bg-gray-100 fc:px-5 fc:py-2.5 fc:text-sm fc:font-medium fc:text-gray-600 disabled:fc:cursor-not-allowed", children: "Cancel" }),
1278
+ /* @__PURE__ */ jsx12("button", { type: "submit", disabled: isSubmitting, className: "fc:flex fc:min-w-32 fc:justify-center fc:rounded-xl fc:bg-[#2563eb] fc:px-6 fc:py-2.5 fc:text-sm fc:font-semibold fc:text-white disabled:fc:cursor-not-allowed disabled:fc:opacity-60", children: isSubmitting ? "Saving..." : "Save Workflow Type" })
1092
1279
  ] })
1093
1280
  ] })
1094
1281
  ] }) });
1095
1282
  };
1096
- var DeleteWorkflowType_default = DeleteWorkflowType;
1283
+ var inputClass = (hasError) => `fc:w-full fc:rounded-xl fc:border fc:bg-white fc:p-3 fc:text-sm fc:text-slate-700 fc:outline-none focus:fc:border-indigo-500 ${hasError ? "fc:border-red-500" : "fc:border-slate-200"}`;
1284
+ var FormField = ({ label, required, error, children }) => /* @__PURE__ */ jsxs11("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700", children: [
1285
+ label,
1286
+ " ",
1287
+ required && /* @__PURE__ */ jsx12("span", { className: "fc:text-red-500", children: "*" }),
1288
+ /* @__PURE__ */ jsx12("div", { className: "fc:mt-1.5", children }),
1289
+ error && /* @__PURE__ */ jsx12("span", { className: "fc:mt-1 fc:block fc:text-xs fc:text-red-500", children: error })
1290
+ ] });
1291
+ var AddWorkflowTypeModal_default = AddWorkflowTypeModal;
1097
1292
 
1098
1293
  // src/components/workflow-type/EditWorkflowType.jsx
1099
- import React12, { useState as useState6, useEffect as useEffect3 } from "react";
1100
- import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1294
+ import React13, { useState as useState8, useEffect as useEffect4 } from "react";
1295
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1101
1296
  var EditWorkflowType = ({
1102
1297
  isOpen,
1103
1298
  onClose,
1104
1299
  onSave,
1105
1300
  selectedData
1106
1301
  }) => {
1107
- const [formData, setFormData] = useState6({
1302
+ const [formData, setFormData] = useState8({
1108
1303
  workflowTypeCode: "",
1109
1304
  workflowTypeName: "",
1110
1305
  description: "",
1111
1306
  isActive: true
1112
1307
  });
1113
- useEffect3(() => {
1308
+ useEffect4(() => {
1114
1309
  var _a, _b;
1115
1310
  if (selectedData) {
1116
1311
  setFormData({
@@ -1133,617 +1328,220 @@ var EditWorkflowType = ({
1133
1328
  [name]: type === "checkbox" ? checked : value
1134
1329
  }));
1135
1330
  };
1136
- const handleSubmit = (e) => {
1331
+ const handleSubmit = async (e) => {
1137
1332
  e.preventDefault();
1138
- onSave(__spreadValues(__spreadValues({}, selectedData), formData));
1139
- onClose();
1333
+ const wasSaved = await (onSave == null ? void 0 : onSave(__spreadValues(__spreadValues({}, selectedData), formData)));
1334
+ if (wasSaved) onClose();
1140
1335
  };
1141
- return /* @__PURE__ */ jsx12("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:bg-black/40 fc:backdrop-blur-sm fc:p-4 fc:animate-in fc:fade-in fc:duration-200", children: /* @__PURE__ */ jsxs11("div", { className: "fc:relative fc:w-full fc:max-w-md fc:bg-white fc:rounded-3xl fc:shadow-2xl fc:border fc:border-gray-100 fc:overflow-hidden", children: [
1142
- /* @__PURE__ */ jsxs11("div", { className: "fc:flex fc:items-center fc:justify-between fc:px-6 fc:py-4 fc:border-b fc:border-gray-100", children: [
1143
- /* @__PURE__ */ jsx12("h3", { className: "fc:text-lg fc:font-bold fc:text-gray-900", children: "Edit Workflow Type" }),
1144
- /* @__PURE__ */ jsx12("button", { onClick: onClose, className: "fc:text-gray-400 hover:fc:fc:text-gray-600 fc:w-8 fc:h-8 fc:rounded-full fc:flex fc:items-center fc:justify-center fc:transition", children: "\u2715" })
1336
+ return /* @__PURE__ */ jsx13("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:bg-black/40 fc:backdrop-blur-sm fc:p-4 fc:animate-in fc:fade-in fc:duration-200", children: /* @__PURE__ */ jsxs12("div", { className: "fc:relative fc:w-full fc:max-w-md fc:bg-white fc:rounded-3xl fc:shadow-2xl fc:border fc:border-gray-100 fc:overflow-hidden", children: [
1337
+ /* @__PURE__ */ jsxs12("div", { className: "fc:flex fc:items-center fc:justify-between fc:px-6 fc:py-4 fc:border-b fc:border-gray-100", children: [
1338
+ /* @__PURE__ */ jsx13("h3", { className: "fc:text-lg fc:font-bold fc:text-gray-900", children: "Edit Workflow Type" }),
1339
+ /* @__PURE__ */ jsx13("button", { onClick: onClose, className: "fc:text-gray-400 hover:fc:fc:text-gray-600 fc:w-8 fc:h-8 fc:rounded-full fc:flex fc:items-center fc:justify-center fc:transition", children: "\u2715" })
1145
1340
  ] }),
1146
- /* @__PURE__ */ jsxs11("form", { onSubmit: handleSubmit, className: "fc:p-6 fc:space-y-4", children: [
1147
- /* @__PURE__ */ jsxs11("div", { children: [
1148
- /* @__PURE__ */ jsx12("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:uppercase fc:tracking-wider fc:mb-1", children: "Workflow Type Code" }),
1149
- /* @__PURE__ */ jsx12("input", { type: "text", name: "workflowTypeCode", value: formData.workflowTypeCode, onChange: handleChange, className: "fc:w-full fc:rounded-xl fc:border fc:border-gray-200 fc:bg-gray-50 fc:px-3.5 fc:py-2 fc:text-sm fc:text-gray-900 focus:fc:fc:bg-white focus:fc:fc:border-blue-500 focus:fc:fc:outline-none focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 fc:transition", required: true })
1341
+ /* @__PURE__ */ jsxs12("form", { onSubmit: handleSubmit, className: "fc:p-6 fc:space-y-4", children: [
1342
+ /* @__PURE__ */ jsxs12("div", { children: [
1343
+ /* @__PURE__ */ jsx13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:uppercase fc:tracking-wider fc:mb-1", children: "Workflow Type Code" }),
1344
+ /* @__PURE__ */ jsx13("input", { type: "text", name: "workflowTypeCode", value: formData.workflowTypeCode, onChange: handleChange, className: "fc:w-full fc:rounded-xl fc:border fc:border-gray-200 fc:bg-gray-50 fc:px-3.5 fc:py-2 fc:text-sm fc:text-gray-900 focus:fc:fc:bg-white focus:fc:fc:border-blue-500 focus:fc:fc:outline-none focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 fc:transition", required: true })
1150
1345
  ] }),
1151
- /* @__PURE__ */ jsxs11("div", { children: [
1152
- /* @__PURE__ */ jsx12("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:uppercase fc:tracking-wider fc:mb-1", children: "Workflow Type Name" }),
1153
- /* @__PURE__ */ jsx12("input", { type: "text", name: "workflowTypeName", value: formData.workflowTypeName, onChange: handleChange, className: "fc:w-full fc:rounded-xl fc:border fc:border-gray-200 fc:bg-gray-50 fc:px-3.5 fc:py-2 fc:text-sm fc:text-gray-900 focus:fc:fc:bg-white focus:fc:fc:border-blue-500 focus:fc:fc:outline-none focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 fc:transition", required: true })
1346
+ /* @__PURE__ */ jsxs12("div", { children: [
1347
+ /* @__PURE__ */ jsx13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:uppercase fc:tracking-wider fc:mb-1", children: "Workflow Type Name" }),
1348
+ /* @__PURE__ */ jsx13("input", { type: "text", name: "workflowTypeName", value: formData.workflowTypeName, onChange: handleChange, className: "fc:w-full fc:rounded-xl fc:border fc:border-gray-200 fc:bg-gray-50 fc:px-3.5 fc:py-2 fc:text-sm fc:text-gray-900 focus:fc:fc:bg-white focus:fc:fc:border-blue-500 focus:fc:fc:outline-none focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 fc:transition", required: true })
1154
1349
  ] }),
1155
- /* @__PURE__ */ jsxs11("div", { children: [
1156
- /* @__PURE__ */ jsx12("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:uppercase fc:tracking-wider fc:mb-1", children: "Description" }),
1157
- /* @__PURE__ */ jsx12("textarea", { name: "description", value: formData.description, onChange: handleChange, rows: "3", className: "fc:w-full fc:rounded-xl fc:border fc:border-gray-200 fc:bg-gray-50 fc:px-3.5 fc:py-2 fc:text-sm fc:text-gray-900 focus:fc:fc:bg-white focus:fc:fc:border-blue-500 focus:fc:fc:outline-none focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 fc:transition fc:resize-none" })
1350
+ /* @__PURE__ */ jsxs12("div", { children: [
1351
+ /* @__PURE__ */ jsx13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:uppercase fc:tracking-wider fc:mb-1", children: "Description" }),
1352
+ /* @__PURE__ */ jsx13("textarea", { name: "description", value: formData.description, onChange: handleChange, rows: "3", className: "fc:w-full fc:rounded-xl fc:border fc:border-gray-200 fc:bg-gray-50 fc:px-3.5 fc:py-2 fc:text-sm fc:text-gray-900 focus:fc:fc:bg-white focus:fc:fc:border-blue-500 focus:fc:fc:outline-none focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 fc:transition fc:resize-none" })
1158
1353
  ] }),
1159
- /* @__PURE__ */ jsxs11("div", { className: "fc:flex fc:items-center fc:pt-1", children: [
1160
- /* @__PURE__ */ jsx12("input", { type: "checkbox", id: "isActive", name: "isActive", checked: formData.isActive, onChange: handleChange, className: "fc:h-4 fc:w-4 fc:rounded fc:border-gray-300 fc:text-blue-600 focus:fc:fc:ring-blue-500 fc:cursor-pointer" }),
1161
- /* @__PURE__ */ jsx12("label", { htmlFor: "isActive", className: "fc:ml-2 fc:text-sm fc:font-medium fc:text-gray-700 fc:cursor-pointer", children: "Is Active" })
1354
+ /* @__PURE__ */ jsxs12("div", { className: "fc:flex fc:items-center fc:pt-1", children: [
1355
+ /* @__PURE__ */ jsx13("input", { type: "checkbox", id: "isActive", name: "isActive", checked: formData.isActive, onChange: handleChange, className: "fc:h-4 fc:w-4 fc:rounded fc:border-gray-300 fc:text-blue-600 focus:fc:fc:ring-blue-500 fc:cursor-pointer" }),
1356
+ /* @__PURE__ */ jsx13("label", { htmlFor: "isActive", className: "fc:ml-2 fc:text-sm fc:font-medium fc:text-gray-700 fc:cursor-pointer", children: "Is Active" })
1162
1357
  ] }),
1163
- /* @__PURE__ */ jsxs11("div", { className: "fc:flex fc:items-center fc:justify-end fc:gap-3 fc:pt-4 fc:border-t fc:border-gray-100", children: [
1164
- /* @__PURE__ */ jsx12("button", { type: "button", onClick: onClose, className: "fc:py-2 fc:px-4 fc:text-sm fc:font-semibold fc:text-gray-700 fc:bg-gray-100 hover:fc:fc:bg-gray-200 fc:rounded-xl fc:transition", children: "Cancel" }),
1165
- /* @__PURE__ */ jsx12("button", { type: "submit", className: "fc:py-2 fc:px-5 fc:text-sm fc:font-semibold fc:text-white fc:bg-blue-600 hover:fc:fc:bg-blue-700 fc:rounded-xl fc:shadow-md fc:shadow-blue-500/20 fc:transition", children: "Update" })
1358
+ /* @__PURE__ */ jsxs12("div", { className: "fc:flex fc:items-center fc:justify-end fc:gap-3 fc:pt-4 fc:border-t fc:border-gray-100", children: [
1359
+ /* @__PURE__ */ jsx13("button", { type: "button", onClick: onClose, className: "fc:py-2 fc:px-4 fc:text-sm fc:font-semibold fc:text-gray-700 fc:bg-gray-100 hover:fc:fc:bg-gray-200 fc:rounded-xl fc:transition", children: "Cancel" }),
1360
+ /* @__PURE__ */ jsx13("button", { type: "submit", className: "fc:py-2 fc:px-5 fc:text-sm fc:font-semibold fc:text-white fc:bg-blue-600 hover:fc:fc:bg-blue-700 fc:rounded-xl fc:shadow-md fc:shadow-blue-500/20 fc:transition", children: "Update" })
1166
1361
  ] })
1167
1362
  ] })
1168
1363
  ] }) });
1169
1364
  };
1170
1365
  var EditWorkflowType_default = EditWorkflowType;
1171
1366
 
1172
- // src/components/workflow-type/WorkflowTypeTable.jsx
1173
- import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1174
- function WorkflowTypeTable({
1175
- pageSize,
1176
- searchQuery = "",
1177
- currentPage,
1178
- setCurrentPage,
1179
- setTotalEntries
1180
- }) {
1181
- const initialData = [{
1182
- workflowTypeId: 1,
1183
- workflowTypeCode: "PETITION",
1184
- workflowTypeName: "Citizen Petition",
1185
- description: "Petition workflow for citizens",
1186
- isActive: true,
1187
- createdOn: "2026-01-01",
1188
- createdBy: "1",
1189
- updatedOn: "2026-01-05",
1190
- updatedBy: "Admin"
1191
- }, {
1192
- workflowTypeId: 2,
1193
- workflowTypeCode: "BUILDING",
1194
- workflowTypeName: "Building Permission",
1195
- description: "Building approval process",
1196
- isActive: true,
1197
- createdOn: "2026-01-01",
1198
- createdBy: "1",
1199
- updatedOn: "2026-01-06",
1200
- updatedBy: "Admin"
1201
- }, {
1202
- workflowTypeId: 3,
1203
- workflowTypeCode: "LEAVE",
1204
- workflowTypeName: "Leave Application",
1205
- description: "Employee leave management",
1206
- isActive: true,
1207
- createdOn: "2026-01-02",
1208
- createdBy: "2",
1209
- updatedOn: "2026-01-07",
1210
- updatedBy: "HR"
1211
- }, {
1212
- workflowTypeId: 4,
1213
- workflowTypeCode: "GRIEVANCE",
1214
- workflowTypeName: "Grievance Redressal",
1215
- description: "Public grievance workflow",
1216
- isActive: false,
1217
- createdOn: "2026-01-03",
1218
- createdBy: "1",
1219
- updatedOn: "2026-01-08",
1220
- updatedBy: "Admin"
1221
- }, {
1222
- workflowTypeId: 5,
1223
- workflowTypeCode: "TRADE",
1224
- workflowTypeName: "Trade License",
1225
- description: "Trade license issuance",
1226
- isActive: true,
1227
- createdOn: "2026-01-04",
1228
- createdBy: "3",
1229
- updatedOn: "2026-01-09",
1230
- updatedBy: "Manager"
1231
- }, {
1232
- workflowTypeId: 6,
1233
- workflowTypeCode: "DOC_VERIFY",
1234
- workflowTypeName: "Document Verification",
1235
- description: "Verification of identity documents",
1236
- isActive: true,
1237
- createdOn: "2026-01-05",
1238
- createdBy: "2",
1239
- updatedOn: "2026-01-10",
1240
- updatedBy: "Admin"
1241
- }, {
1242
- workflowTypeId: 7,
1243
- workflowTypeCode: "WATER_CONN",
1244
- workflowTypeName: "Water Connection Approval",
1245
- description: "New water connection requests",
1246
- isActive: true,
1247
- createdOn: "2026-01-05",
1248
- createdBy: "1",
1249
- updatedOn: "2026-01-11",
1250
- updatedBy: "Admin"
1251
- }, {
1252
- workflowTypeId: 8,
1253
- workflowTypeCode: "TAX_ASSESS",
1254
- workflowTypeName: "Property Tax Assessment",
1255
- description: "Annual property tax assessment",
1256
- isActive: false,
1257
- createdOn: "2026-01-06",
1258
- createdBy: "4",
1259
- updatedOn: "2026-01-12",
1260
- updatedBy: "Officer"
1261
- }, {
1262
- workflowTypeId: 9,
1263
- workflowTypeCode: "VENDOR_REG",
1264
- workflowTypeName: "Vendor Registration",
1265
- description: "Registration of new suppliers",
1266
- isActive: true,
1267
- createdOn: "2026-01-07",
1268
- createdBy: "3",
1269
- updatedOn: "2026-01-13",
1270
- updatedBy: "Manager"
1271
- }, {
1272
- workflowTypeId: 10,
1273
- workflowTypeCode: "BIRTH_CERT",
1274
- workflowTypeName: "Birth Certificate Request",
1275
- description: "Issuance of birth certificate",
1276
- isActive: true,
1277
- createdOn: "2026-01-08",
1278
- createdBy: "1",
1279
- updatedOn: "2026-01-14",
1280
- updatedBy: "Admin"
1281
- }, {
1282
- workflowTypeId: 11,
1283
- workflowTypeCode: "DEATH_CERT",
1284
- workflowTypeName: "Death Certificate Request",
1285
- description: "Issuance of death certificate",
1286
- isActive: true,
1287
- createdOn: "2026-01-08",
1288
- createdBy: "1",
1289
- updatedOn: "2026-01-15",
1290
- updatedBy: "Admin"
1291
- }, {
1292
- workflowTypeId: 12,
1293
- workflowTypeCode: "ROAD_REPAIR",
1294
- workflowTypeName: "Road Repair Request",
1295
- description: "PWD road maintenance flow",
1296
- isActive: true,
1297
- createdOn: "2026-01-09",
1298
- createdBy: "5",
1299
- updatedOn: "2026-01-16",
1300
- updatedBy: "Engineer"
1301
- }, {
1302
- workflowTypeId: 13,
1303
- workflowTypeCode: "WASTE_MGMT",
1304
- workflowTypeName: "Waste Collection Issue",
1305
- description: "Sanitation complaint tracking",
1306
- isActive: false,
1307
- createdOn: "2026-01-10",
1308
- createdBy: "2",
1309
- updatedOn: "2026-01-17",
1310
- updatedBy: "Officer"
1311
- }, {
1312
- workflowTypeId: 14,
1313
- workflowTypeCode: "FIRE_NOC",
1314
- workflowTypeName: "Fire NOC Approval",
1315
- description: "Safety clearance certificate",
1316
- isActive: true,
1317
- createdOn: "2026-01-11",
1318
- createdBy: "1",
1319
- updatedOn: "2026-01-18",
1320
- updatedBy: "Admin"
1321
- }, {
1322
- workflowTypeId: 15,
1323
- workflowTypeCode: "HEALTH_LIC",
1324
- workflowTypeName: "Health License Approval",
1325
- description: "Commercial health license",
1326
- isActive: true,
1327
- createdOn: "2026-01-12",
1328
- createdBy: "3",
1329
- updatedOn: "2026-01-19",
1330
- updatedBy: "Manager"
1331
- }, {
1332
- workflowTypeId: 16,
1333
- workflowTypeCode: "ADV_PERMIT",
1334
- workflowTypeName: "Advertisement Board Perm",
1335
- description: "Hoarding and billboard permit",
1336
- isActive: true,
1337
- createdOn: "2026-01-13",
1338
- createdBy: "4",
1339
- updatedOn: "2026-01-20",
1340
- updatedBy: "Officer"
1341
- }, {
1342
- workflowTypeId: 17,
1343
- workflowTypeCode: "MARRIAGE_REG",
1344
- workflowTypeName: "Marriage Registration",
1345
- description: "Legal marriage certificate flow",
1346
- isActive: true,
1347
- createdOn: "2026-01-14",
1348
- createdBy: "1",
1349
- updatedOn: "2026-01-21",
1350
- updatedBy: "Admin"
1351
- }, {
1352
- workflowTypeId: 18,
1353
- workflowTypeCode: "RTI_APP",
1354
- workflowTypeName: "RTI Application Flow",
1355
- description: "Right to information processing",
1356
- isActive: true,
1357
- createdOn: "2026-01-15",
1358
- createdBy: "2",
1359
- updatedOn: "2026-01-22",
1360
- updatedBy: "Officer"
1361
- }, {
1362
- workflowTypeId: 19,
1363
- workflowTypeCode: "CONTRACTOR",
1364
- workflowTypeName: "Contractor Empanelment",
1365
- description: "Procurement contractor onboarding",
1366
- isActive: true,
1367
- createdOn: "2026-01-16",
1368
- createdBy: "3",
1369
- updatedOn: "2026-01-23",
1370
- updatedBy: "Manager"
1371
- }, {
1372
- workflowTypeId: 20,
1373
- workflowTypeCode: "STREET_LIGHT",
1374
- workflowTypeName: "Streetlight Maintenance",
1375
- description: "Electrical infrastructure issue",
1376
- isActive: true,
1377
- createdOn: "2026-01-17",
1378
- createdBy: "5",
1379
- updatedOn: "2026-01-24",
1380
- updatedBy: "Engineer"
1381
- }, {
1382
- workflowTypeId: 21,
1383
- workflowTypeCode: "PARK_BOOKING",
1384
- workflowTypeName: "Park Booking Approval",
1385
- description: "Public event park reservation",
1386
- isActive: false,
1387
- createdOn: "2026-01-18",
1388
- createdBy: "2",
1389
- updatedOn: "2026-01-25",
1390
- updatedBy: "Admin"
1391
- }, {
1392
- workflowTypeId: 22,
1393
- workflowTypeCode: "DRAINAGE",
1394
- workflowTypeName: "Drainage Issue Escalation",
1395
- description: "Sewerage maintenance request",
1396
- isActive: true,
1397
- createdOn: "2026-01-19",
1398
- createdBy: "5",
1399
- updatedOn: "2026-01-26",
1400
- updatedBy: "Engineer"
1401
- }, {
1402
- workflowTypeId: 23,
1403
- workflowTypeCode: "COMM_HALL",
1404
- workflowTypeName: "Community Hall Booking",
1405
- description: "Civic facility reservation",
1406
- isActive: true,
1407
- createdOn: "2026-01-20",
1408
- createdBy: "1",
1409
- updatedOn: "2026-01-27",
1410
- updatedBy: "Admin"
1411
- }, {
1412
- workflowTypeId: 24,
1413
- workflowTypeCode: "SEISMIC_CLR",
1414
- workflowTypeName: "Seismic Clearance Flow",
1415
- description: "Environmental safety check",
1416
- isActive: false,
1417
- createdOn: "2026-01-21",
1418
- createdBy: "4",
1419
- updatedOn: "2026-01-28",
1420
- updatedBy: "Officer"
1421
- }, {
1422
- workflowTypeId: 25,
1423
- workflowTypeCode: "TREE_CUTTING",
1424
- workflowTypeName: "Tree Cutting Permission",
1425
- description: "Greenery regulation permit",
1426
- isActive: true,
1427
- createdOn: "2026-01-22",
1428
- createdBy: "2",
1429
- updatedOn: "2026-01-29",
1430
- updatedBy: "Officer"
1431
- }];
1432
- const [data, setData] = useState7(initialData);
1433
- const [sortOrder, setSortOrder] = useState7("asc");
1434
- const [sortKey, setSortKey] = useState7("workflowTypeId");
1435
- const [selectedItem, setSelectedItem] = useState7(null);
1436
- const [isEditOpen, setIsEditOpen] = useState7(false);
1437
- const [isDeleteOpen, setIsDeleteOpen] = useState7(false);
1438
- const handleSort = (columnKey) => {
1439
- const isAsc = sortKey === columnKey && sortOrder === "asc";
1440
- setSortOrder(isAsc ? "desc" : "asc");
1441
- setSortKey(columnKey);
1442
- const sortedData = [...data].sort((a, b) => {
1443
- if (a[columnKey] < b[columnKey]) return isAsc ? -1 : 1;
1444
- if (a[columnKey] > b[columnKey]) return isAsc ? 1 : -1;
1445
- return 0;
1446
- });
1447
- setData(sortedData);
1448
- };
1449
- const filteredData = data.filter((item) => {
1450
- const query = (searchQuery || "").toLowerCase();
1451
- return item.workflowTypeName.toLowerCase().includes(query) || item.workflowTypeCode.toLowerCase().includes(query) || item.description.toLowerCase().includes(query);
1452
- });
1453
- useEffect4(() => {
1454
- if (setTotalEntries) setTotalEntries(filteredData.length);
1455
- }, [filteredData.length, setTotalEntries]);
1456
- const totalPages = Math.ceil(filteredData.length / pageSize) || 1;
1457
- const startIndex = (currentPage - 1) * pageSize;
1458
- const visibleData = filteredData.slice(startIndex, startIndex + pageSize);
1459
- const pageNumbers = Array.from({
1460
- length: totalPages
1461
- }, (_, i) => i + 1);
1462
- const handleEdit = (item) => {
1463
- setSelectedItem(item);
1464
- setIsEditOpen(true);
1465
- };
1466
- const handleDelete = (item) => {
1467
- setSelectedItem(item);
1468
- setIsDeleteOpen(false);
1469
- setIsDeleteOpen(true);
1470
- };
1471
- const handleConfirmDelete = (itemToDelete) => {
1472
- setData((prevData) => prevData.filter((i) => i.workflowTypeId !== itemToDelete.workflowTypeId));
1473
- };
1474
- const handleSaveEdit = (updatedItem) => {
1475
- setData((prevData) => prevData.map((item) => item.workflowTypeId === updatedItem.workflowTypeId ? updatedItem : item));
1476
- };
1477
- return /* @__PURE__ */ jsxs12("div", { className: "fc:space-y-5", children: [
1478
- /* @__PURE__ */ jsx13("div", { className: "fc:w-full fc:overflow-x-hidden fc:border fc:border-slate-200 fc:rounded-2xl fc:shadow-sm fc:max-h-[420px] fc:overflow-y-auto", children: /* @__PURE__ */ jsxs12("table", { className: "fc:w-full fc:text-left fc:border-collapse fc:bg-white fc:table-fixed", children: [
1479
- /* @__PURE__ */ jsx13("thead", { className: "fc:sticky fc:top-0 fc:z-10 fc:bg-slate-50 fc:shadow-[0_1px_0_0_rgba(226,232,240,1)]", children: /* @__PURE__ */ jsxs12("tr", { className: "fc:text-xs fc:font-bold fc:tracking-wider fc:text-slate-500", children: [
1480
- /* @__PURE__ */ jsxs12("th", { onClick: () => handleSort("workflowTypeId"), className: "fc:py-3 fc:px-2 fc:text-sm fc:text-center fc:bg-slate-50 fc:cursor-pointer fc:select-none fc:w-[6%]", children: [
1481
- "ID ",
1482
- sortKey === "workflowTypeId" ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25B2"
1483
- ] }),
1484
- /* @__PURE__ */ jsxs12("th", { onClick: () => handleSort("workflowTypeCode"), className: "fc:py-3 fc:px-3 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:w-[16%]", children: [
1485
- "Code ",
1486
- sortKey === "workflowTypeCode" ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25B2"
1487
- ] }),
1488
- /* @__PURE__ */ jsxs12("th", { onClick: () => handleSort("workflowTypeName"), className: "fc:py-3 fc:px-3 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:w-[20%]", children: [
1489
- "Name ",
1490
- sortKey === "workflowTypeName" ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25B2"
1491
- ] }),
1492
- /* @__PURE__ */ jsxs12("th", { onClick: () => handleSort("description"), className: "fc:py-3 fc:px-3 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:w-[22%]", children: [
1493
- "Description ",
1494
- sortKey === "description" ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25B2"
1495
- ] }),
1496
- /* @__PURE__ */ jsx13("th", { className: "fc:py-3 fc:px-2 fc:text-sm fc:bg-slate-50 fc:text-center fc:w-[12%]", children: "Status" }),
1497
- /* @__PURE__ */ jsxs12("th", { onClick: () => handleSort("createdOn"), className: "fc:py-3 fc:px-2 fc:text-sm fc:cursor-pointer fc:select-none hover:fc:fc:text-slate-900 fc:bg-slate-50 fc:text-center fc:w-[12%]", children: [
1498
- "Created On ",
1499
- sortKey === "createdOn" ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25B2"
1500
- ] }),
1501
- /* @__PURE__ */ jsx13("th", { className: "fc:py-3 fc:px-2 fc:text-sm fc:bg-slate-50 fc:text-center fc:w-[12%]", children: "Action" })
1502
- ] }) }),
1503
- /* @__PURE__ */ jsx13("tbody", { className: "fc:divide-y fc:divide-slate-100 fc:text-xs fc:text-slate-600", children: visibleData.map((item, index) => /* @__PURE__ */ jsxs12("tr", { className: "hover:fc:fc:bg-slate-50/50 fc:transition-colors", children: [
1504
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-2 fc:text-center fc:text-sm fc:font-medium fc:text-slate-700", children: startIndex + index + 1 }),
1505
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-3 fc:font-mono fc:text-sm fc:text-slate-700 fc:font-medium fc:break-words", children: item.workflowTypeCode }),
1506
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-3 fc:font-medium fc:text-slate-700 fc:text-sm fc:break-words", children: item.workflowTypeName }),
1507
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-3 fc:text-slate-700 fc:text-sm fc:break-words", children: item.description }),
1508
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-2 fc:text-center", children: /* @__PURE__ */ jsx13("span", { className: `fc:px-2 fc:py-1 fc:text-[13px] fc:font-semibold fc:rounded-full fc:inline-block ${item.isActive ? "fc:bg-emerald-100 fc:text-emerald-700 fc:border fc:border-emerald-200" : "fc:bg-rose-100 fc:text-rose-700 fc:border fc:border-rose-200"}`, children: item.isActive ? "Active" : "Inactive" }) }),
1509
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-2 fc:text-center fc:text-slate-700 fc:text-[13px] fc:font-mono", children: item.createdOn }),
1510
- /* @__PURE__ */ jsx13("td", { className: "fc:py-3 fc:px-2 fc:text-center", children: /* @__PURE__ */ jsxs12("div", { className: "fc:flex fc:items-center fc:justify-center fc:gap-2", children: [
1511
- /* @__PURE__ */ jsx13("button", { onClick: () => handleEdit(item), className: "fc:px-3 fc:py-1 fc:bg-blue-100/70 hover:fc:fc:bg-blue-200/80 fc:text-blue-600 fc:font-semibold fc:text-xs fc:rounded-full fc:transition-all fc:duration-150 fc:cursor-pointer", children: "Edit" }),
1512
- /* @__PURE__ */ jsx13("button", { onClick: () => handleDelete(item), className: "fc:px-3 fc:py-1 fc:bg-rose-100/70 hover:fc:fc:bg-rose-200/80 fc:text-rose-600 fc:font-semibold fc:text-xs fc:rounded-full fc:transition-all fc:duration-150 fc:cursor-pointer", children: "Delete" })
1513
- ] }) })
1514
- ] }, item.workflowTypeId)) })
1515
- ] }) }),
1516
- /* @__PURE__ */ jsxs12("div", { className: "fc:flex fc:items-center fc:justify-end fc:gap-1 fc:text-[13px] fc:text-slate-700 fc:font-normal fc:mt-4 fc:bg-slate-50/50 fc:p-3 fc:rounded-xl fc:border fc:border-slate-100", children: [
1517
- /* @__PURE__ */ jsx13("button", { onClick: () => setCurrentPage((prev) => Math.max(prev - 1, 1)), disabled: currentPage === 1, className: "fc:px-2 fc:py-1 fc:text-[15px] fc:border fc:border-slate-200 fc:rounded-lg fc:bg-white fc:text-slate-600 fc:shadow-sm fc:transition-all fc:duration-200 fc:hover:bg-blue-600 fc:hover:text-white fc:hover:border-blue-600", children: "\u2039 Prev" }),
1518
- pageNumbers.map((pageNumber) => /* @__PURE__ */ jsx13("button", { onClick: () => setCurrentPage(pageNumber), className: `fc:px-2 fc:py-1 fc:text-[15px] fc:border fc:border-slate-200 fc:rounded-lg fc:bg-white fc:text-slate-600 fc:shadow-sm fc:transition-all fc:duration-200 fc:hover:bg-blue-600 fc:hover:text-white fc:hover:border-blue-600${currentPage === pageNumber ? "bg-blue-600 text-white font-medium shadow-sm" : "text-slate-600 hover:bg-slate-100"}`, children: pageNumber }, pageNumber)),
1519
- /* @__PURE__ */ jsx13("button", { onClick: () => setCurrentPage((prev) => Math.min(prev + 1, totalPages)), disabled: currentPage === totalPages, className: "fc:px-2 fc:py-1 fc:text-[15px] fc:border fc:border-slate-200 fc:rounded-lg fc:bg-white fc:text-slate-600 fc:shadow-sm fc:transition-all fc:duration-200 fc:hover:bg-blue-600 fc:hover:text-white fc:hover:border-blue-600", children: "Next \u203A" })
1520
- ] }),
1521
- /* @__PURE__ */ jsx13(EditWorkflowType_default, { isOpen: isEditOpen, onClose: () => setIsEditOpen(false), selectedData: selectedItem, onSave: handleSaveEdit }),
1522
- /* @__PURE__ */ jsx13(DeleteWorkflowType_default, { isOpen: isDeleteOpen, onClose: () => setIsDeleteOpen(false), itemData: selectedItem, onConfirm: handleConfirmDelete })
1523
- ] });
1524
- }
1525
-
1526
- // src/components/workflow-type/AddWorkflowTypeModal.jsx
1527
- import React14, { useState as useState8, useEffect as useEffect5 } from "react";
1367
+ // src/components/workflow-type/DeleteWorkflowType.jsx
1368
+ import React14 from "react";
1528
1369
  import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
1529
- var AddWorkflowTypeModal = ({
1370
+ var DeleteWorkflowType = ({
1530
1371
  isOpen,
1531
1372
  onClose,
1532
- onSave
1373
+ onConfirm,
1374
+ itemData
1533
1375
  }) => {
1534
- const [formData, setFormData] = useState8({
1535
- workflowTypeId: "",
1536
- workflowCode: "",
1537
- workflowName: "",
1538
- version: 1,
1539
- isPublished: "No",
1540
- description: "",
1541
- isActive: true
1542
- });
1543
- const [workflowTypeOptions, setWorkflowTypeOptions] = useState8([]);
1544
- const [errors, setErrors] = useState8({});
1545
- useEffect5(() => {
1546
- const options = [{
1547
- workflowTypeId: 1,
1548
- workflowTypeName: "Citizen Petition",
1549
- workflowTypeCode: "PETITION"
1550
- }, {
1551
- workflowTypeId: 2,
1552
- workflowTypeName: "Building Permission",
1553
- workflowTypeCode: "BUILDING"
1554
- }, {
1555
- workflowTypeId: 3,
1556
- workflowTypeName: "Leave Application",
1557
- workflowTypeCode: "LEAVE"
1558
- }];
1559
- setWorkflowTypeOptions(options);
1560
- }, []);
1561
- const handleChange = (e) => {
1562
- const {
1563
- name,
1564
- value,
1565
- type,
1566
- checked
1567
- } = e.target;
1568
- if (name === "description" && value.length > 500) return;
1569
- setFormData((prev) => __spreadProps(__spreadValues({}, prev), {
1570
- [name]: type === "checkbox" ? checked : value
1571
- }));
1572
- if (errors[name]) {
1573
- setErrors((prev) => __spreadProps(__spreadValues({}, prev), {
1574
- [name]: ""
1575
- }));
1576
- }
1577
- };
1578
- const validateForm = () => {
1579
- let newErrors = {};
1580
- if (!formData.workflowTypeId) newErrors.workflowTypeId = "Workflow Type is required";
1581
- if (!formData.workflowCode.trim()) newErrors.workflowCode = "Workflow Code is required";
1582
- if (!formData.workflowName.trim()) newErrors.workflowName = "Workflow Name is required";
1583
- setErrors(newErrors);
1584
- return Object.keys(newErrors).length === 0;
1585
- };
1586
- const handleSubmit = (e) => {
1587
- e.preventDefault();
1588
- if (!validateForm()) return;
1589
- const payload = {
1590
- workflowTypeId: parseInt(formData.workflowTypeId, 10),
1591
- workflowCode: formData.workflowCode.toUpperCase().trim(),
1592
- workflowName: formData.workflowName.trim(),
1593
- version: parseInt(formData.version, 10),
1594
- isPublished: formData.isPublished === "Yes",
1595
- isActive: formData.isActive,
1596
- description: formData.description.trim()
1597
- };
1598
- onSave(payload);
1599
- handleReset();
1600
- onClose();
1601
- };
1602
- const handleReset = () => {
1603
- setFormData({
1604
- workflowTypeId: "",
1605
- workflowCode: "",
1606
- workflowName: "",
1607
- version: 1,
1608
- isPublished: "No",
1609
- description: "",
1610
- isActive: true
1611
- });
1612
- setErrors({});
1613
- };
1614
1376
  if (!isOpen) return null;
1615
- return (
1616
- /* Completely Light Overlay (No Pitch Black Backdrop) */
1617
- /* @__PURE__ */ jsx14("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:bg-black/20 fc:p-4 fc:backdrop-blur-sm", children: /* @__PURE__ */ jsxs13("div", { className: "fc:bg-white fc:rounded-2xl fc:shadow-2xl fc:border fc:border-gray-100 fc:w-full fc:max-w-3xl fc:max-h-[80vh] fc:overflow-hidden fc:transition-all", children: [
1618
- /* @__PURE__ */ jsxs13("div", { className: "fc:flex fc:justify-between fc:items-center fc:px-6 fc:py-3 fc:border-b fc:border-gray-100", children: [
1619
- /* @__PURE__ */ jsxs13("div", { className: "fc:flex fc:items-center fc:gap-3", children: [
1620
- /* @__PURE__ */ jsx14("div", { className: "fc:w-10 fc:h-10 fc:rounded-xl fc:bg-blue-50 fc:text-[#2563eb] fc:flex fc:items-center fc:justify-center fc:font-bold", children: /* @__PURE__ */ jsx14("svg", { className: "fc:w-5 fc:h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx14("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" }) }) }),
1621
- /* @__PURE__ */ jsxs13("div", { children: [
1622
- /* @__PURE__ */ jsx14("h2", { className: "fc:text-xl fc:font-bold fc:text-gray-800", children: "Add Workflow" }),
1623
- /* @__PURE__ */ jsx14("p", { className: "fc:text-xs fc:text-gray-400", children: "Create a new workflow and configure its details" })
1624
- ] })
1377
+ return /* @__PURE__ */ jsx14("div", { className: "fc:fixed fc:inset-0 fc:z-50 fc:flex fc:items-center fc:justify-center fc:bg-black/40 fc:backdrop-blur-sm fc:p-4 fc:animate-in fc:fade-in fc:duration-200", children: /* @__PURE__ */ jsxs13("div", { className: "fc:relative fc:w-full fc:max-w-md fc:bg-white fc:rounded-3xl fc:shadow-2xl fc:border fc:border-gray-100 fc:overflow-hidden", children: [
1378
+ /* @__PURE__ */ jsx14("button", { type: "button", onClick: onClose, className: "fc:absolute fc:top-4 fc:right-4 fc:z-10 fc:flex fc:items-center fc:justify-center fc:w-8 fc:h-8 fc:rounded-full fc:text-gray-400 hover:fc:fc:text-gray-600 hover:fc:fc:bg-gray-100 fc:transition", children: "\u2715" }),
1379
+ /* @__PURE__ */ jsxs13("div", { className: "fc:p-8 fc:text-center", children: [
1380
+ /* @__PURE__ */ jsx14("div", { className: "fc:mx-auto fc:mb-4 fc:flex fc:h-14 fc:w-14 fc:items-center fc:justify-center fc:rounded-2xl fc:bg-red-50 fc:border fc:border-red-100 fc:text-red-500 fc:shadow-inner", children: /* @__PURE__ */ jsx14("span", { className: "fc:text-2xl", children: "\u26A0\uFE0F" }) }),
1381
+ /* @__PURE__ */ jsx14("h3", { className: "fc:text-xl fc:font-bold fc:text-gray-900 fc:tracking-tight fc:mb-2", children: "Delete Configuration" }),
1382
+ /* @__PURE__ */ jsxs13("p", { className: "fc:text-sm fc:text-gray-500 fc:leading-relaxed fc:px-2 fc:mb-6", children: [
1383
+ "Are you sure you want to delete",
1384
+ " ",
1385
+ /* @__PURE__ */ jsxs13("span", { className: "fc:font-semibold fc:text-gray-900 fc:bg-gray-100 fc:px-2 fc:py-0.5 fc:rounded-md", children: [
1386
+ '"',
1387
+ (itemData == null ? void 0 : itemData.workflowTypeName) || (itemData == null ? void 0 : itemData.WorkflowTypeName) || "this item",
1388
+ '"'
1625
1389
  ] }),
1626
- /* @__PURE__ */ jsx14("button", { onClick: onClose, className: "fc:text-gray-400 hover:fc:fc:text-gray-600 fc:transition fc:text-xl fc:font-medium", children: "\u2715" })
1390
+ "? This action cannot be undone."
1627
1391
  ] }),
1628
- /* @__PURE__ */ jsxs13("form", { onSubmit: handleSubmit, className: "fc:p-4 fc:space-y-3 fc:overflow-y-auto fc:max-h-[70vh]", children: [
1629
- /* @__PURE__ */ jsxs13("div", { className: "fc:bg-gray-50/70 fc:rounded-xl fc:p-5 fc:border fc:border-gray-100", children: [
1630
- /* @__PURE__ */ jsxs13("h3", { className: "fc:text-sm fc:font-semibold fc:text-[#2563eb] fc:mb-4 fc:flex fc:items-center fc:gap-2", children: [
1631
- /* @__PURE__ */ jsx14("span", { children: "\u{1F4CB}" }),
1632
- " Workflow Information"
1633
- ] }),
1634
- /* @__PURE__ */ jsxs13("div", { className: "fc:grid fc:grid-cols-2 fc:gap-5", children: [
1635
- /* @__PURE__ */ jsxs13("div", { children: [
1636
- /* @__PURE__ */ jsxs13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:mb-1.5", children: [
1637
- "Workflow Type ",
1638
- /* @__PURE__ */ jsx14("span", { className: "fc:text-red-500", children: "*" })
1639
- ] }),
1640
- /* @__PURE__ */ jsxs13("select", { name: "workflowTypeId", value: formData.workflowTypeId, onChange: handleChange, className: `fc:w-full fc:border fc:p-2.5 fc:pl-9 fc:rounded-xl fc:text-xs fc:bg-white fc:focus:outline-none fc:focus:ring-2 fc:focus:ring-indigo-500/10 fc:focus:border-indigo-500 ${errors.workflowTypeId ? "fc:border-red-500" : "fc:border-slate-200 fc:text-slate-700"}`, children: [
1641
- /* @__PURE__ */ jsx14("option", { value: "", children: "Select workflow type" }),
1642
- workflowTypeOptions.map((item) => /* @__PURE__ */ jsx14("option", { value: item.workflowTypeId, children: item.workflowTypeName }, item.workflowTypeId))
1643
- ] }),
1644
- errors.workflowTypeId && /* @__PURE__ */ jsx14("span", { className: "fc:text-xs fc:text-red-500", children: errors.workflowTypeId })
1645
- ] }),
1646
- /* @__PURE__ */ jsxs13("div", { children: [
1647
- /* @__PURE__ */ jsxs13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:mb-1.5", children: [
1648
- "Workflow Code ",
1649
- /* @__PURE__ */ jsx14("span", { className: "fc:text-red-500", children: "*" })
1650
- ] }),
1651
- /* @__PURE__ */ jsx14("input", { type: "text", name: "workflowCode", placeholder: "Enter workflow code", value: formData.workflowCode, onChange: handleChange, className: `fc:w-full fc:border fc:p-2.5 fc:pl-9 fc:rounded-xl fc:text-xs fc:bg-white fc:focus:outline-none fc:focus:ring-2 fc:focus:ring-indigo-500/10 fc:focus:border-indigo-500 ${errors.workflowCode ? "fc:border-red-500" : "fc:border-slate-200 fc:text-slate-700"}` }),
1652
- errors.workflowCode && /* @__PURE__ */ jsx14("span", { className: "fc:text-xs fc:text-red-500", children: errors.workflowCode })
1653
- ] }),
1654
- /* @__PURE__ */ jsxs13("div", { className: "fc:col-span-2", children: [
1655
- /* @__PURE__ */ jsxs13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:mb-1.5", children: [
1656
- "Workflow Name ",
1657
- /* @__PURE__ */ jsx14("span", { className: "fc:text-red-500", children: "*" })
1658
- ] }),
1659
- /* @__PURE__ */ jsx14("input", { type: "text", name: "workflowName", placeholder: "Enter workflow name", value: formData.workflowName, onChange: handleChange, className: `fc:w-full fc:border fc:p-2.5 fc:pl-9 fc:rounded-xl fc:text-xs fc:bg-white fc:focus:outline-none fc:focus:ring-2 fc:focus:ring-indigo-500/10 fc:focus:border-indigo-500 ${errors.workflowName ? "fc:border-red-500" : "fc:border-slate-200 fc:text-slate-700"}` }),
1660
- errors.workflowName && /* @__PURE__ */ jsx14("span", { className: "fc:text-xs fc:text-red-500", children: errors.workflowName })
1661
- ] }),
1662
- /* @__PURE__ */ jsxs13("div", { children: [
1663
- /* @__PURE__ */ jsxs13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:mb-1.5", children: [
1664
- "Version ",
1665
- /* @__PURE__ */ jsx14("span", { className: "fc:text-red-500", children: "*" })
1666
- ] }),
1667
- /* @__PURE__ */ jsx14("input", { type: "number", name: "version", value: formData.version, onChange: handleChange, className: "fc:w-full fc:border fc:p-2.5 fc:pl-9 fc:rounded-xl fc:text-xs fc:bg-white fc:focus:outline-none fc:focus:ring-2 fc:focus:ring-indigo-500/10 fc:focus:border-indigo-500 fc:border-slate-200 fc:text-slate-700", readOnly: true })
1668
- ] }),
1669
- /* @__PURE__ */ jsxs13("div", { children: [
1670
- /* @__PURE__ */ jsxs13("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700 fc:mb-1.5", children: [
1671
- "Published ",
1672
- /* @__PURE__ */ jsx14("span", { className: "fc:text-red-500", children: "*" })
1673
- ] }),
1674
- /* @__PURE__ */ jsxs13("select", { name: "isPublished", value: formData.isPublished, onChange: handleChange, className: "fc:w-full fc:border fc:p-2.5 fc:pl-9 fc:rounded-xl fc:text-xs fc:bg-white fc:focus:outline-none fc:focus:ring-2 fc:focus:ring-indigo-500/10 fc:focus:border-indigo-500 fc:border-slate-200 fc:text-slate-700", children: [
1675
- /* @__PURE__ */ jsx14("option", { value: "No", children: "No" }),
1676
- /* @__PURE__ */ jsx14("option", { value: "Yes", children: "Yes" })
1677
- ] })
1678
- ] }),
1679
- /* @__PURE__ */ jsxs13("div", { className: "fc:col-span-2", children: [
1680
- /* @__PURE__ */ jsxs13("div", { className: "fc:flex fc:justify-between fc:items-center fc:mb-1.5", children: [
1681
- /* @__PURE__ */ jsx14("label", { className: "fc:block fc:text-xs fc:font-semibold fc:text-gray-700", children: "Description" }),
1682
- /* @__PURE__ */ jsxs13("span", { className: "fc:text-[11px] fc:text-gray-400", children: [
1683
- formData.description.length,
1684
- " / 500"
1685
- ] })
1686
- ] }),
1687
- /* @__PURE__ */ jsx14("textarea", { name: "description", rows: "3", placeholder: "Enter detailed description...", value: formData.description, onChange: handleChange, className: "fc:w-full fc:px-3 fc:py-2.5 fc:text-sm fc:bg-white fc:border fc:border-gray-200 fc:rounded-lg focus:fc:fc:ring-2 focus:fc:fc:ring-blue-500/20 focus:fc:fc:border-[#2563eb] fc:outline-none fc:resize-none fc:transition" })
1688
- ] })
1689
- ] })
1690
- ] }),
1691
- /* @__PURE__ */ jsxs13("div", { className: "fc:flex fc:justify-end fc:items-center fc:gap-3 fc:pt-2", children: [
1692
- /* @__PURE__ */ jsx14("button", { type: "button", onClick: onClose, className: "fc:px-5 fc:py-2.5 fc:text-sm fc:font-medium fc:text-gray-600 fc:bg-gray-100 hover:fc:fc:bg-gray-200 fc:rounded-xl fc:transition", children: "\u2715 Cancel" }),
1693
- /* @__PURE__ */ jsx14("button", { type: "submit", className: "fc:px-6 fc:py-2.5 fc:text-sm fc:font-semibold fc:text-white fc:bg-[#2563eb] hover:fc:fc:bg-[#1d4ed8] active:fc:fc:scale-95 fc:rounded-xl fc:shadow-md fc:transition-all fc:flex fc:items-center fc:gap-2", children: "Save Workflow" })
1694
- ] })
1392
+ /* @__PURE__ */ jsxs13("div", { className: "fc:flex fc:items-center fc:gap-3", children: [
1393
+ /* @__PURE__ */ jsx14("button", { type: "button", onClick: onClose, className: "fc:w-1/2 fc:py-2.5 fc:px-4 fc:text-sm fc:font-semibold fc:text-gray-700 fc:bg-gray-100 hover:fc:fc:bg-gray-200 fc:rounded-xl fc:transition", children: "Cancel" }),
1394
+ /* @__PURE__ */ jsx14("button", { type: "button", onClick: () => {
1395
+ onConfirm(itemData);
1396
+ }, className: "fc:w-1/2 fc:py-2.5 fc:px-4 fc:text-sm fc:font-semibold fc:text-white fc:bg-red-600 hover:fc:fc:bg-red-700 fc:rounded-xl fc:shadow-md fc:shadow-red-500/20 fc:transition", children: "Delete" })
1695
1397
  ] })
1696
- ] }) })
1697
- );
1398
+ ] })
1399
+ ] }) });
1698
1400
  };
1699
- var AddWorkflowTypeModal_default = AddWorkflowTypeModal;
1401
+ var DeleteWorkflowType_default = DeleteWorkflowType;
1700
1402
 
1701
1403
  // src/components/workflow-type/WorkflowTypeMains.js
1702
1404
  import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
1405
+ var getErrorMessage = (error, fallback) => {
1406
+ var _a, _b, _c, _d;
1407
+ return ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || ((_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.title) || (error == null ? void 0 : error.message) || fallback;
1408
+ };
1409
+ var getResponseData = (response) => {
1410
+ var _a;
1411
+ return (_a = response == null ? void 0 : response.data) != null ? _a : response;
1412
+ };
1413
+ var getWorkflowTypes = (response) => {
1414
+ const result = getResponseData(response);
1415
+ const payload = Array.isArray(result) ? result : (result == null ? void 0 : result.data) || (result == null ? void 0 : result.result) || result;
1416
+ const items = Array.isArray(payload) ? payload : (payload == null ? void 0 : payload.items) || (payload == null ? void 0 : payload.records) || (payload == null ? void 0 : payload.data) || (payload == null ? void 0 : payload.result) || [];
1417
+ return Array.isArray(items) ? items : [];
1418
+ };
1419
+ var normalizeWorkflowType = (item) => {
1420
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1421
+ return __spreadProps(__spreadValues({}, item), {
1422
+ workflowTypeId: (_a = item == null ? void 0 : item.workflowTypeId) != null ? _a : item == null ? void 0 : item.WorkflowTypeId,
1423
+ workflowTypeCode: (_c = (_b = item == null ? void 0 : item.workflowTypeCode) != null ? _b : item == null ? void 0 : item.WorkflowTypeCode) != null ? _c : "",
1424
+ workflowTypeName: (_e = (_d = item == null ? void 0 : item.workflowTypeName) != null ? _d : item == null ? void 0 : item.WorkflowTypeName) != null ? _e : "",
1425
+ description: (_g = (_f = item == null ? void 0 : item.description) != null ? _f : item == null ? void 0 : item.Description) != null ? _g : "",
1426
+ isActive: (_i = (_h = item == null ? void 0 : item.isActive) != null ? _h : item == null ? void 0 : item.IsActive) != null ? _i : true,
1427
+ createdOn: (_k = (_j = item == null ? void 0 : item.createdOn) != null ? _j : item == null ? void 0 : item.CreatedOn) != null ? _k : "",
1428
+ createdBy: (_m = (_l = item == null ? void 0 : item.createdBy) != null ? _l : item == null ? void 0 : item.CreatedBy) != null ? _m : "",
1429
+ updatedBy: (_o = (_n = item == null ? void 0 : item.updatedBy) != null ? _n : item == null ? void 0 : item.UpdatedBy) != null ? _o : ""
1430
+ });
1431
+ };
1703
1432
  function WorkflowTypeMains() {
1704
1433
  const [refreshkey, setRefreshKey] = useState9(0);
1705
- const handleRefresh = () => {
1706
- console.log("Table data refreshed!");
1707
- setRefreshKey((prev) => prev + 1);
1708
- };
1709
1434
  const tableRef = useRef3(null);
1710
1435
  const [modalOpen, setModalOpen] = useState9(false);
1711
1436
  const [pageSize, setPageSize] = useState9(10);
1712
1437
  const [searchQuery, setSearchQuery] = useState9("");
1713
1438
  const [currentPage, setCurrentPage] = useState9(1);
1714
- const [totalEntries, setTotalEntries] = useState9(0);
1439
+ const [, setTotalEntries] = useState9(0);
1440
+ const [data, setData] = useState9([]);
1441
+ const [isLoading, setIsLoading] = useState9(false);
1715
1442
  const [isEditOpen, setIsEditOpen] = useState9(false);
1716
1443
  const [isDeleteOpen, setIsDeleteOpen] = useState9(false);
1717
1444
  const [selectedItem, setSelectedItem] = useState9(null);
1718
- const handlePageSizeChange = (e) => {
1719
- setPageSize(Number(e.target.value));
1445
+ const loadWorkflowTypes = useCallback(async (showError = true) => {
1446
+ var _a, _b;
1447
+ try {
1448
+ setIsLoading(true);
1449
+ const endpoints = getApiEndpoints();
1450
+ const endpoint = (_b = (_a = endpoints == null ? void 0 : endpoints.flowCore) == null ? void 0 : _a.workflowType) == null ? void 0 : _b.getList;
1451
+ if (!endpoint) throw new Error("Workflow type list endpoint is not configured.");
1452
+ const response = await getApiService().get(endpoint);
1453
+ setData(getWorkflowTypes(response).map(normalizeWorkflowType));
1454
+ } catch (error) {
1455
+ setData([]);
1456
+ if (showError) {
1457
+ await Swal2.fire("Error", getErrorMessage(error, "Unable to load workflow types."), "error");
1458
+ }
1459
+ } finally {
1460
+ setIsLoading(false);
1461
+ }
1462
+ }, []);
1463
+ useEffect5(() => {
1464
+ loadWorkflowTypes();
1465
+ }, [loadWorkflowTypes, refreshkey]);
1466
+ const handleRefresh = () => setRefreshKey((previous) => previous + 1);
1467
+ const handlePageSizeChange = (event) => {
1468
+ setPageSize(Number(event.target.value));
1720
1469
  setCurrentPage(1);
1721
1470
  };
1722
- const handleEdit = (item) => {
1723
- setSelectedItem(item);
1724
- setIsEditOpen(true);
1471
+ const handleEdit = async (item) => {
1472
+ var _a, _b, _c, _d;
1473
+ try {
1474
+ const endpoints = getApiEndpoints();
1475
+ const id = (_a = item == null ? void 0 : item.workflowTypeId) != null ? _a : item == null ? void 0 : item.WorkflowTypeId;
1476
+ const endpoint = (_d = (_c = (_b = endpoints == null ? void 0 : endpoints.flowCore) == null ? void 0 : _b.workflowType) == null ? void 0 : _c.getById) == null ? void 0 : _d.call(_c, id);
1477
+ if (!id || !endpoint) throw new Error("Workflow type details endpoint is not configured.");
1478
+ const response = await getApiService().get(endpoint);
1479
+ const result = getResponseData(response);
1480
+ const record = (result == null ? void 0 : result.data) || (result == null ? void 0 : result.result) || result;
1481
+ setSelectedItem(normalizeWorkflowType(record));
1482
+ setIsEditOpen(true);
1483
+ } catch (error) {
1484
+ await Swal2.fire("Error", getErrorMessage(error, "Unable to load workflow type details."), "error");
1485
+ }
1725
1486
  };
1726
- const handleSaveEdit = (updatedData) => {
1727
- console.log("Updated Data:", updatedData);
1487
+ const handleSaveEdit = async (updatedData) => {
1488
+ var _a, _b, _c;
1489
+ try {
1490
+ const endpoints = getApiEndpoints();
1491
+ const endpoint = (_b = (_a = endpoints == null ? void 0 : endpoints.flowCore) == null ? void 0 : _a.workflowType) == null ? void 0 : _b.update;
1492
+ if (!endpoint) throw new Error("Workflow type update endpoint is not configured.");
1493
+ const payload = {
1494
+ workflowTypeId: (_c = updatedData.workflowTypeId) != null ? _c : updatedData.WorkflowTypeId,
1495
+ workflowTypeCode: updatedData.workflowTypeCode.trim().toUpperCase(),
1496
+ workflowTypeName: updatedData.workflowTypeName.trim(),
1497
+ description: updatedData.description.trim(),
1498
+ isActive: Boolean(updatedData.isActive),
1499
+ updatedBy: updatedData.updatedBy || updatedData.createdBy || "System"
1500
+ };
1501
+ await getApiService().put(endpoint, payload);
1502
+ await Swal2.fire("Success", "Workflow type updated successfully.", "success");
1503
+ setIsEditOpen(false);
1504
+ handleRefresh();
1505
+ return true;
1506
+ } catch (error) {
1507
+ await Swal2.fire("Error", getErrorMessage(error, "Unable to update workflow type."), "error");
1508
+ return false;
1509
+ }
1728
1510
  };
1729
1511
  const handleDelete = (item) => {
1730
1512
  setSelectedItem(item);
1731
1513
  setIsDeleteOpen(true);
1732
1514
  };
1733
- const handleConfirmDelete = (itemToDelete) => {
1734
- console.log("Deleted Item:", itemToDelete);
1515
+ const handleConfirmDelete = async (item) => {
1516
+ var _a, _b, _c;
1517
+ try {
1518
+ const endpoints = getApiEndpoints();
1519
+ const endpoint = (_b = (_a = endpoints == null ? void 0 : endpoints.flowCore) == null ? void 0 : _a.workflowType) == null ? void 0 : _b.update;
1520
+ if (!endpoint) throw new Error("Workflow type update endpoint is not configured.");
1521
+ await getApiService().put(endpoint, {
1522
+ workflowTypeId: (_c = item.workflowTypeId) != null ? _c : item.WorkflowTypeId,
1523
+ workflowTypeCode: item.workflowTypeCode,
1524
+ workflowTypeName: item.workflowTypeName,
1525
+ description: item.description || "",
1526
+ isActive: false,
1527
+ updatedBy: item.updatedBy || item.createdBy || "System"
1528
+ });
1529
+ await Swal2.fire("Success", "Workflow type has been deactivated successfully.", "success");
1530
+ setIsDeleteOpen(false);
1531
+ handleRefresh();
1532
+ return true;
1533
+ } catch (error) {
1534
+ await Swal2.fire("Error", getErrorMessage(error, "Unable to deactivate workflow type."), "error");
1535
+ return false;
1536
+ }
1537
+ };
1538
+ const handleCreateSuccess = async () => {
1539
+ await Swal2.fire("Success", "Workflow type created successfully.", "success");
1540
+ setModalOpen(false);
1541
+ handleRefresh();
1735
1542
  };
1736
1543
  return /* @__PURE__ */ jsxs14("div", { className: "fc:h-screen fc:overflow-hidden fc:bg-slate-50 fc:p-4 md:fc:fc:p-6", children: [
1737
- /* @__PURE__ */ jsx15(CommonHeader, { title: "Workflow Type", breadcrumbs: [{
1738
- label: "Dashboard",
1739
- href: "/dashboard"
1740
- }, {
1741
- label: "Masters",
1742
- href: "/masters"
1743
- }, {
1744
- label: "Workflow Type",
1745
- href: "/WorkflowType"
1746
- }], buttonText: "Add Workflow Type", onButtonClick: () => setModalOpen(true) }),
1544
+ /* @__PURE__ */ jsx15(CommonHeader, { title: "Workflow Type", breadcrumbs: [{ label: "Dashboard", href: "/dashboard" }, { label: "Masters", href: "/masters" }, { label: "Workflow Type", href: "/WorkflowType" }], buttonText: "Add Workflow Type", onButtonClick: () => setModalOpen(true) }),
1747
1545
  /* @__PURE__ */ jsx15("div", { className: "fc:w-full fc:space-y-5", children: /* @__PURE__ */ jsxs14("div", { className: "fc:bg-white fc:p-6 fc:rounded-2xl fc:border fc:border-slate-200/80 fc:shadow-sm fc:space-y-5", children: [
1748
1546
  /* @__PURE__ */ jsxs14("div", { className: "fc:flex fc:justify-between fc:items-center fc:w-full fc:gap-4", children: [
1749
1547
  /* @__PURE__ */ jsx15("div", { className: "fc:w-full fc:max-w-xs", children: /* @__PURE__ */ jsx15(SearchBar2, { searchQuery, setSearchQuery, setCurrentPage }) }),
@@ -1758,12 +1556,9 @@ function WorkflowTypeMains() {
1758
1556
  ] })
1759
1557
  ] })
1760
1558
  ] }),
1761
- /* @__PURE__ */ jsxs14("div", { ref: tableRef, children: [
1762
- /* @__PURE__ */ jsx15(WorkflowTypeTable, { pageSize, searchQuery, currentPage, setCurrentPage, setTotalEntries, onEdit: handleEdit, onDelete: handleDelete }, refreshkey),
1763
- " "
1764
- ] })
1559
+ /* @__PURE__ */ jsx15("div", { ref: tableRef, children: /* @__PURE__ */ jsx15(WorkflowTypeTable, { data, isLoading, pageSize, searchQuery, currentPage, setCurrentPage, setTotalEntries, onEdit: handleEdit, onDelete: handleDelete }) })
1765
1560
  ] }) }),
1766
- /* @__PURE__ */ jsx15(AddWorkflowTypeModal_default, { isOpen: modalOpen, onClose: () => setModalOpen(false) }),
1561
+ /* @__PURE__ */ jsx15(AddWorkflowTypeModal_default, { isOpen: modalOpen, onClose: () => setModalOpen(false), onSave: handleCreateSuccess }),
1767
1562
  /* @__PURE__ */ jsx15(EditWorkflowType_default, { isOpen: isEditOpen, onClose: () => setIsEditOpen(false), onSave: handleSaveEdit, selectedData: selectedItem }),
1768
1563
  /* @__PURE__ */ jsx15(DeleteWorkflowType_default, { isOpen: isDeleteOpen, onClose: () => setIsDeleteOpen(false), onConfirm: handleConfirmDelete, itemData: selectedItem })
1769
1564
  ] });
@@ -11739,7 +11534,7 @@ function Sidebar({
11739
11534
  const Icon = item.icon;
11740
11535
  const handleClick = () => {
11741
11536
  if (item.component) {
11742
- router.push("/", void 0, {
11537
+ router.push("/flowCore", void 0, {
11743
11538
  shallow: true
11744
11539
  });
11745
11540
  setActiveComponent(item.component);
@@ -11867,31 +11662,6 @@ var Layout = ({ children }) => {
11867
11662
  ) });
11868
11663
  };
11869
11664
  var Layout_default = Layout;
11870
-
11871
- // src/components/Service/ApiEndpointsProvider.js
11872
- var STORAGE_KEY = "FLOWCORE_API_ENDPOINTS";
11873
- var apiEndpoints = null;
11874
- var ApiEndpointsProvider = ({ apiEndpoints: endpoints }) => {
11875
- if (typeof window !== "undefined" && endpoints) {
11876
- apiEndpoints = endpoints;
11877
- sessionStorage.setItem(
11878
- STORAGE_KEY,
11879
- JSON.stringify(endpoints)
11880
- );
11881
- }
11882
- return null;
11883
- };
11884
- var ApiEndpointsProvider_default = ApiEndpointsProvider;
11885
-
11886
- // src/components/Service/ApiServicepackage.js
11887
- var apiService = null;
11888
- var ApiServicepackage = ({ apiService: service }) => {
11889
- if (service) {
11890
- apiService = service;
11891
- }
11892
- return null;
11893
- };
11894
- var ApiServicepackage_default = ApiServicepackage;
11895
11665
  export {
11896
11666
  ApiEndpointsProvider_default as ApiEndpointsProvider,
11897
11667
  ApiServicepackage_default as ApiServicepackage,