flowcore-fn 10.1.1 → 10.1.3

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
@@ -3956,6 +3956,16 @@ function AddUserHierarchyNodeMappingModal({
3956
3956
  };
3957
3957
  loadData();
3958
3958
  }, [isOpen]);
3959
+ const toApiDateTime = (value) => {
3960
+ if (!value) return null;
3961
+ if (typeof value === "string" && value.includes("T")) {
3962
+ const parsed = new Date(value);
3963
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
3964
+ }
3965
+ const [year, month, day] = value.split("-").map(Number);
3966
+ if (!year || !month || !day) return null;
3967
+ return new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0)).toISOString();
3968
+ };
3959
3969
  const handleChange = (event) => setFormData((previous) => __spreadProps(__spreadValues({}, previous), { [event.target.name]: event.target.value }));
3960
3970
  const handleSave = async () => {
3961
3971
  if (!onSave) return;
@@ -3964,7 +3974,16 @@ function AddUserHierarchyNodeMappingModal({
3964
3974
  return;
3965
3975
  }
3966
3976
  setIsSubmitting(true);
3967
- const success = await onSave({ externalUserId: Number(formData.externalUserId), workflowStepId: Number(formData.workflowStepId), hierarchyNodeId: Number(formData.hierarchyNodeId), roleCode: formData.roleCode, isPrimary: formData.isPrimary === "true", effectiveFrom: formData.effectiveFrom, effectiveTo: formData.effectiveTo || null, createdBy: "System" });
3977
+ const success = await onSave({
3978
+ externalUserId: Number(formData.externalUserId),
3979
+ workflowStepId: Number(formData.workflowStepId),
3980
+ hierarchyNodeId: Number(formData.hierarchyNodeId),
3981
+ roleCode: formData.roleCode,
3982
+ isPrimary: formData.isPrimary === "true",
3983
+ effectiveFrom: toApiDateTime(formData.effectiveFrom),
3984
+ effectiveTo: toApiDateTime(formData.effectiveTo),
3985
+ createdBy: "System"
3986
+ });
3968
3987
  setIsSubmitting(false);
3969
3988
  if (success) onClose();
3970
3989
  };
@@ -4187,8 +4206,18 @@ function EditUserHierarchyNodeMappingModal({
4187
4206
  [name]: value
4188
4207
  }));
4189
4208
  };
4209
+ const toApiDateTime = (value) => {
4210
+ if (!value) return null;
4211
+ if (typeof value === "string" && value.includes("T")) {
4212
+ const parsed = new Date(value);
4213
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
4214
+ }
4215
+ const [year, month, day] = value.split("-").map(Number);
4216
+ if (!year || !month || !day) return null;
4217
+ return new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0)).toISOString();
4218
+ };
4190
4219
  const handleSubmit = async (event) => {
4191
- var _a, _b, _c;
4220
+ var _a, _b, _c, _d, _e;
4192
4221
  event.preventDefault();
4193
4222
  if (!formData.workflowStepId) {
4194
4223
  alert("Please select a workflow step.");
@@ -4196,15 +4225,15 @@ function EditUserHierarchyNodeMappingModal({
4196
4225
  }
4197
4226
  if (onSave) {
4198
4227
  const success = await onSave({
4199
- mappingId: Number((_a = selectedMapping.mappingId) != null ? _a : selectedMapping.id),
4228
+ workflowStepUserMappingId: Number(
4229
+ (_c = (_b = (_a = selectedMapping.workflowStepUserMappingId) != null ? _a : selectedMapping.WorkFlowStepUserMappingId) != null ? _b : selectedMapping.mappingId) != null ? _c : selectedMapping.id
4230
+ ),
4200
4231
  externalUserId: Number(selectedMapping.externalUserId),
4201
4232
  workflowStepId: Number(formData.workflowStepId),
4202
- hierarchyNodeId: Number(formData.hierarchyNodeId),
4203
- roleCode: formData.roleCode,
4204
4233
  isPrimary: formData.isPrimary === "true",
4205
- effectiveFrom: formData.effectiveFrom,
4206
- effectiveTo: formData.effectiveTo || null,
4207
- isActive: (_c = (_b = selectedMapping.isActive) != null ? _b : selectedMapping.status) != null ? _c : true,
4234
+ effectiveFrom: toApiDateTime(formData.effectiveFrom),
4235
+ effectiveTo: toApiDateTime(formData.effectiveTo),
4236
+ isActive: (_e = (_d = selectedMapping.isActive) != null ? _d : selectedMapping.status) != null ? _e : true,
4208
4237
  updatedBy: selectedMapping.updatedBy || selectedMapping.createdBy || "System"
4209
4238
  });
4210
4239
  if (success) onClose();
@@ -4437,6 +4466,17 @@ function DeleteUserHierarchyNodeMappingModal({
4437
4466
 
4438
4467
  // src/components/user-hierarchy-node-mapping/userhierarchynodetable.jsx
4439
4468
  var import_jsx_runtime26 = require("react/jsx-runtime");
4469
+ var formatDateOnly = (value) => {
4470
+ if (!value) return "-";
4471
+ const date = new Date(value);
4472
+ if (Number.isNaN(date.getTime())) {
4473
+ return String(value).split("T")[0] || "-";
4474
+ }
4475
+ const year = date.getUTCFullYear();
4476
+ const month = String(date.getUTCMonth() + 1).padStart(2, "0");
4477
+ const day = String(date.getUTCDate()).padStart(2, "0");
4478
+ return `${year}-${month}-${day}`;
4479
+ };
4440
4480
  function UserHierarchyNodeMappingTable({
4441
4481
  apiData,
4442
4482
  pageSize,
@@ -4546,8 +4586,8 @@ function UserHierarchyNodeMappingTable({
4546
4586
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-slate-600 fc:whitespace-nowrap", children: item.hierarchyNodeId }),
4547
4587
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-slate-600 fc:whitespace-nowrap", children: item.roleCode }),
4548
4588
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: `fc:px-2 fc:py-0.5 fc:text-xs fc:font-semibold fc:rounded${item.isPrimary ? "bg-emerald-50 text-emerald-600 border border-emerald-200" : "bg-rose-50 text-rose-600 border border-rose-200"}`, children: item.isPrimary ? "\u2713 Yes" : "\u2715 No" }) }),
4549
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: item.effectiveFrom }),
4550
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: item.effectiveTo }),
4589
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: formatDateOnly(item.effectiveFrom) }),
4590
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: formatDateOnly(item.effectiveTo) }),
4551
4591
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("button", { onClick: () => {
4552
4592
  var _a2;
4553
4593
  return toggleStatus((_a2 = item.mappingId) != null ? _a2 : item.id);
@@ -4626,16 +4666,28 @@ function User_hierarchy_mapping_main() {
4626
4666
  setCurrentPage(1);
4627
4667
  };
4628
4668
  const saveMapping = async (payload, isEdit = false) => {
4629
- var _a, _b, _c, _d, _e;
4669
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4630
4670
  try {
4631
4671
  const endpoint = (_c = (_b = (_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) == null ? void 0 : _b.WorkflowStepUserMapping) == null ? void 0 : _c[isEdit ? "update" : "create"];
4632
4672
  if (!endpoint) throw new Error(`Workflow Step Hierarchy Mapping ${isEdit ? "update" : "create"} endpoint is not configured.`);
4633
- await getApiService()[isEdit ? "put" : "post"](endpoint, payload);
4673
+ const requestPayload = isEdit ? {
4674
+ workflowStepUserMappingId: Number(
4675
+ (_f = (_e = (_d = payload.workflowStepUserMappingId) != null ? _d : payload.WorkFlowStepUserMappingId) != null ? _e : payload.mappingId) != null ? _f : payload.id
4676
+ ),
4677
+ externalUserId: Number(payload.externalUserId),
4678
+ workflowStepId: Number(payload.workflowStepId),
4679
+ isPrimary: Boolean(payload.isPrimary),
4680
+ effectiveFrom: payload.effectiveFrom,
4681
+ effectiveTo: payload.effectiveTo || null,
4682
+ isActive: (_g = payload.isActive) != null ? _g : true,
4683
+ updatedBy: payload.updatedBy || "System"
4684
+ } : payload;
4685
+ await getApiService()[isEdit ? "put" : "post"](endpoint, requestPayload);
4634
4686
  await import_sweetalert210.default.fire("Success", `Workflow Step Hierarchy Mapping ${isEdit ? "updated" : "created"} successfully.`, "success");
4635
4687
  handleRefresh();
4636
4688
  return true;
4637
4689
  } catch (error) {
4638
- await import_sweetalert210.default.fire("Error", ((_e = (_d = error == null ? void 0 : error.response) == null ? void 0 : _d.data) == null ? void 0 : _e.message) || (error == null ? void 0 : error.message) || `Unable to ${isEdit ? "update" : "create"} Workflow Step Hierarchy Mapping.`, "error");
4690
+ await import_sweetalert210.default.fire("Error", ((_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 ${isEdit ? "update" : "create"} Workflow Step Hierarchy Mapping.`, "error");
4639
4691
  return false;
4640
4692
  }
4641
4693
  };
@@ -3822,6 +3822,16 @@ function AddUserHierarchyNodeMappingModal({
3822
3822
  };
3823
3823
  loadData();
3824
3824
  }, [isOpen]);
3825
+ const toApiDateTime = (value) => {
3826
+ if (!value) return null;
3827
+ if (typeof value === "string" && value.includes("T")) {
3828
+ const parsed = new Date(value);
3829
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
3830
+ }
3831
+ const [year, month, day] = value.split("-").map(Number);
3832
+ if (!year || !month || !day) return null;
3833
+ return new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0)).toISOString();
3834
+ };
3825
3835
  const handleChange = (event) => setFormData((previous) => __spreadProps(__spreadValues({}, previous), { [event.target.name]: event.target.value }));
3826
3836
  const handleSave = async () => {
3827
3837
  if (!onSave) return;
@@ -3830,7 +3840,16 @@ function AddUserHierarchyNodeMappingModal({
3830
3840
  return;
3831
3841
  }
3832
3842
  setIsSubmitting(true);
3833
- const success = await onSave({ externalUserId: Number(formData.externalUserId), workflowStepId: Number(formData.workflowStepId), hierarchyNodeId: Number(formData.hierarchyNodeId), roleCode: formData.roleCode, isPrimary: formData.isPrimary === "true", effectiveFrom: formData.effectiveFrom, effectiveTo: formData.effectiveTo || null, createdBy: "System" });
3843
+ const success = await onSave({
3844
+ externalUserId: Number(formData.externalUserId),
3845
+ workflowStepId: Number(formData.workflowStepId),
3846
+ hierarchyNodeId: Number(formData.hierarchyNodeId),
3847
+ roleCode: formData.roleCode,
3848
+ isPrimary: formData.isPrimary === "true",
3849
+ effectiveFrom: toApiDateTime(formData.effectiveFrom),
3850
+ effectiveTo: toApiDateTime(formData.effectiveTo),
3851
+ createdBy: "System"
3852
+ });
3834
3853
  setIsSubmitting(false);
3835
3854
  if (success) onClose();
3836
3855
  };
@@ -4051,8 +4070,18 @@ function EditUserHierarchyNodeMappingModal({
4051
4070
  [name]: value
4052
4071
  }));
4053
4072
  };
4073
+ const toApiDateTime = (value) => {
4074
+ if (!value) return null;
4075
+ if (typeof value === "string" && value.includes("T")) {
4076
+ const parsed = new Date(value);
4077
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
4078
+ }
4079
+ const [year, month, day] = value.split("-").map(Number);
4080
+ if (!year || !month || !day) return null;
4081
+ return new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0)).toISOString();
4082
+ };
4054
4083
  const handleSubmit = async (event) => {
4055
- var _a, _b, _c;
4084
+ var _a, _b, _c, _d, _e;
4056
4085
  event.preventDefault();
4057
4086
  if (!formData.workflowStepId) {
4058
4087
  alert("Please select a workflow step.");
@@ -4060,15 +4089,15 @@ function EditUserHierarchyNodeMappingModal({
4060
4089
  }
4061
4090
  if (onSave) {
4062
4091
  const success = await onSave({
4063
- mappingId: Number((_a = selectedMapping.mappingId) != null ? _a : selectedMapping.id),
4092
+ workflowStepUserMappingId: Number(
4093
+ (_c = (_b = (_a = selectedMapping.workflowStepUserMappingId) != null ? _a : selectedMapping.WorkFlowStepUserMappingId) != null ? _b : selectedMapping.mappingId) != null ? _c : selectedMapping.id
4094
+ ),
4064
4095
  externalUserId: Number(selectedMapping.externalUserId),
4065
4096
  workflowStepId: Number(formData.workflowStepId),
4066
- hierarchyNodeId: Number(formData.hierarchyNodeId),
4067
- roleCode: formData.roleCode,
4068
4097
  isPrimary: formData.isPrimary === "true",
4069
- effectiveFrom: formData.effectiveFrom,
4070
- effectiveTo: formData.effectiveTo || null,
4071
- isActive: (_c = (_b = selectedMapping.isActive) != null ? _b : selectedMapping.status) != null ? _c : true,
4098
+ effectiveFrom: toApiDateTime(formData.effectiveFrom),
4099
+ effectiveTo: toApiDateTime(formData.effectiveTo),
4100
+ isActive: (_e = (_d = selectedMapping.isActive) != null ? _d : selectedMapping.status) != null ? _e : true,
4072
4101
  updatedBy: selectedMapping.updatedBy || selectedMapping.createdBy || "System"
4073
4102
  });
4074
4103
  if (success) onClose();
@@ -4301,6 +4330,17 @@ function DeleteUserHierarchyNodeMappingModal({
4301
4330
 
4302
4331
  // src/components/user-hierarchy-node-mapping/userhierarchynodetable.jsx
4303
4332
  import { jsx as jsx26, jsxs as jsxs25 } from "react/jsx-runtime";
4333
+ var formatDateOnly = (value) => {
4334
+ if (!value) return "-";
4335
+ const date = new Date(value);
4336
+ if (Number.isNaN(date.getTime())) {
4337
+ return String(value).split("T")[0] || "-";
4338
+ }
4339
+ const year = date.getUTCFullYear();
4340
+ const month = String(date.getUTCMonth() + 1).padStart(2, "0");
4341
+ const day = String(date.getUTCDate()).padStart(2, "0");
4342
+ return `${year}-${month}-${day}`;
4343
+ };
4304
4344
  function UserHierarchyNodeMappingTable({
4305
4345
  apiData,
4306
4346
  pageSize,
@@ -4410,8 +4450,8 @@ function UserHierarchyNodeMappingTable({
4410
4450
  /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-slate-600 fc:whitespace-nowrap", children: item.hierarchyNodeId }),
4411
4451
  /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-slate-600 fc:whitespace-nowrap", children: item.roleCode }),
4412
4452
  /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: /* @__PURE__ */ jsx26("span", { className: `fc:px-2 fc:py-0.5 fc:text-xs fc:font-semibold fc:rounded${item.isPrimary ? "bg-emerald-50 text-emerald-600 border border-emerald-200" : "bg-rose-50 text-rose-600 border border-rose-200"}`, children: item.isPrimary ? "\u2713 Yes" : "\u2715 No" }) }),
4413
- /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: item.effectiveFrom }),
4414
- /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: item.effectiveTo }),
4453
+ /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: formatDateOnly(item.effectiveFrom) }),
4454
+ /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: formatDateOnly(item.effectiveTo) }),
4415
4455
  /* @__PURE__ */ jsx26("td", { className: "fc:py-4 fc:px-5 fc:text-center fc:whitespace-nowrap", children: /* @__PURE__ */ jsx26("button", { onClick: () => {
4416
4456
  var _a2;
4417
4457
  return toggleStatus((_a2 = item.mappingId) != null ? _a2 : item.id);
@@ -4490,16 +4530,28 @@ function User_hierarchy_mapping_main() {
4490
4530
  setCurrentPage(1);
4491
4531
  };
4492
4532
  const saveMapping = async (payload, isEdit = false) => {
4493
- var _a, _b, _c, _d, _e;
4533
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4494
4534
  try {
4495
4535
  const endpoint = (_c = (_b = (_a = getApiEndpoints()) == null ? void 0 : _a.flowCore) == null ? void 0 : _b.WorkflowStepUserMapping) == null ? void 0 : _c[isEdit ? "update" : "create"];
4496
4536
  if (!endpoint) throw new Error(`Workflow Step Hierarchy Mapping ${isEdit ? "update" : "create"} endpoint is not configured.`);
4497
- await getApiService()[isEdit ? "put" : "post"](endpoint, payload);
4537
+ const requestPayload = isEdit ? {
4538
+ workflowStepUserMappingId: Number(
4539
+ (_f = (_e = (_d = payload.workflowStepUserMappingId) != null ? _d : payload.WorkFlowStepUserMappingId) != null ? _e : payload.mappingId) != null ? _f : payload.id
4540
+ ),
4541
+ externalUserId: Number(payload.externalUserId),
4542
+ workflowStepId: Number(payload.workflowStepId),
4543
+ isPrimary: Boolean(payload.isPrimary),
4544
+ effectiveFrom: payload.effectiveFrom,
4545
+ effectiveTo: payload.effectiveTo || null,
4546
+ isActive: (_g = payload.isActive) != null ? _g : true,
4547
+ updatedBy: payload.updatedBy || "System"
4548
+ } : payload;
4549
+ await getApiService()[isEdit ? "put" : "post"](endpoint, requestPayload);
4498
4550
  await Swal10.fire("Success", `Workflow Step Hierarchy Mapping ${isEdit ? "updated" : "created"} successfully.`, "success");
4499
4551
  handleRefresh();
4500
4552
  return true;
4501
4553
  } catch (error) {
4502
- await Swal10.fire("Error", ((_e = (_d = error == null ? void 0 : error.response) == null ? void 0 : _d.data) == null ? void 0 : _e.message) || (error == null ? void 0 : error.message) || `Unable to ${isEdit ? "update" : "create"} Workflow Step Hierarchy Mapping.`, "error");
4554
+ await Swal10.fire("Error", ((_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 ${isEdit ? "update" : "create"} Workflow Step Hierarchy Mapping.`, "error");
4503
4555
  return false;
4504
4556
  }
4505
4557
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowcore-fn",
3
- "version": "10.1.1",
3
+ "version": "10.1.3",
4
4
  "main": "dist/pkg-index.js",
5
5
  "module": "dist/pkg-index.mjs",
6
6
  "files": [