@syzy/apphost 1.0.1 → 1.0.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/App.d.ts +4 -0
- package/dist/App.js +83 -0
- package/dist/AppHostProvider.d.ts +6 -0
- package/dist/AppHostProvider.js +4 -0
- package/dist/AppHostRoutes.d.ts +1 -0
- package/dist/AppHostRoutes.js +7 -0
- package/dist/api/image-api.d.ts +8 -0
- package/dist/api/image-api.js +45 -0
- package/dist/api/mapping-api.d.ts +80 -0
- package/dist/api/mapping-api.js +427 -0
- package/dist/bookingModule/components/AmenityForm.d.ts +3 -0
- package/dist/bookingModule/components/AmenityForm.js +19 -0
- package/dist/bookingModule/components/BillingManagement.d.ts +3 -0
- package/dist/bookingModule/components/BillingManagement.js +17 -0
- package/dist/bookingModule/components/CreateRoomForm.d.ts +3 -0
- package/dist/bookingModule/components/CreateRoomForm.js +19 -0
- package/dist/bookingModule/components/ExtraRequirementForm.d.ts +3 -0
- package/dist/bookingModule/components/ExtraRequirementForm.js +19 -0
- package/dist/bookingModule/components/ReservationForm.d.ts +3 -0
- package/dist/bookingModule/components/ReservationForm.js +18 -0
- package/dist/bookingModule/components/RoomCategoryForm.d.ts +3 -0
- package/dist/bookingModule/components/RoomCategoryForm.js +19 -0
- package/dist/bookingModule/components/RoomCategoryPriceForm.d.ts +3 -0
- package/dist/bookingModule/components/RoomCategoryPriceForm.js +20 -0
- package/dist/bookingModule/components/RoomExtraRequirementCapture.d.ts +3 -0
- package/dist/bookingModule/components/RoomExtraRequirementCapture.js +18 -0
- package/dist/bookingModule/components/RoomFacilityForm.d.ts +3 -0
- package/dist/bookingModule/components/RoomFacilityForm.js +19 -0
- package/dist/bookingModule/components/RoomReservationAction.d.ts +3 -0
- package/dist/bookingModule/components/RoomReservationAction.js +18 -0
- package/dist/components/Home/Home.d.ts +3 -0
- package/dist/components/Home/Home.js +14 -0
- package/dist/components/Loader/Loader.d.ts +2 -0
- package/dist/components/Loader/Loader.js +5 -0
- package/dist/components/Login/Login.d.ts +7 -0
- package/dist/components/Login/Login.js +149 -0
- package/dist/components/Login/loginSchema.d.ts +27 -0
- package/dist/components/Login/loginSchema.js +41 -0
- package/dist/components/Mappings/BranchMapping/Branch.d.ts +5 -0
- package/dist/components/Mappings/BranchMapping/Branch.js +135 -0
- package/dist/components/Mappings/BranchMapping/BranchTableColumns.d.ts +10 -0
- package/dist/components/Mappings/BranchMapping/BranchTableColumns.js +21 -0
- package/dist/components/Mappings/BranchMapping/MappingFormBranchUser.d.ts +3 -0
- package/dist/components/Mappings/BranchMapping/MappingFormBranchUser.js +150 -0
- package/dist/components/Mappings/BranchMapping/MappingTableColumns.d.ts +14 -0
- package/dist/components/Mappings/BranchMapping/MappingTableColumns.js +29 -0
- package/dist/components/Mappings/BranchMapping/branchSchema.d.ts +37 -0
- package/dist/components/Mappings/BranchMapping/branchSchema.js +34 -0
- package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.d.ts +3 -0
- package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.js +98 -0
- package/dist/components/Mappings/ComponentMapping/componentRoleColumns.d.ts +3 -0
- package/dist/components/Mappings/ComponentMapping/componentRoleColumns.js +29 -0
- package/dist/components/Mappings/MappingForm/MappingForm.d.ts +35 -0
- package/dist/components/Mappings/MappingForm/MappingForm.js +142 -0
- package/dist/components/Mappings/MappingForm/mappingSchema.d.ts +23 -0
- package/dist/components/Mappings/MappingForm/mappingSchema.js +32 -0
- package/dist/components/Mappings/RoleMapping/MappingFormUserRole.d.ts +5 -0
- package/dist/components/Mappings/RoleMapping/MappingFormUserRole.js +194 -0
- package/dist/components/Mappings/RoleMapping/UserRoleTableColumns.d.ts +3 -0
- package/dist/components/Mappings/RoleMapping/UserRoleTableColumns.js +33 -0
- package/dist/components/NavBar/Sidebar.d.ts +4 -0
- package/dist/components/NavBar/Sidebar.js +56 -0
- package/dist/components/ProfileForm/ProfileForm.d.ts +3 -0
- package/dist/components/ProfileForm/ProfileForm.js +190 -0
- package/dist/components/ProfileForm/ProfileList.d.ts +3 -0
- package/dist/components/ProfileForm/ProfileList.js +33 -0
- package/dist/components/ProfileForm/profileColumns.d.ts +3 -0
- package/dist/components/ProfileForm/profileColumns.js +67 -0
- package/dist/components/ProfileForm/profileSchema.d.ts +52 -0
- package/dist/components/ProfileForm/profileSchema.js +50 -0
- package/dist/components/SettingsPage/SettingsPage.d.ts +3 -0
- package/dist/components/SettingsPage/SettingsPage.js +240 -0
- package/dist/components/api/settings-api.d.ts +26 -0
- package/dist/components/api/settings-api.js +131 -0
- package/dist/components/common/Form/FormActionButtons.d.ts +11 -0
- package/dist/components/common/Form/FormActionButtons.js +6 -0
- package/dist/components/common/Form/FormLabel.d.ts +8 -0
- package/dist/components/common/Form/FormLabel.js +6 -0
- package/dist/components/common/ListTable/ListHeader.d.ts +8 -0
- package/dist/components/common/ListTable/ListHeader.js +5 -0
- package/dist/components/common/ListTable/ListTable.d.ts +17 -0
- package/dist/components/common/ListTable/ListTable.js +31 -0
- package/dist/components/common/Modal/Modal.d.ts +11 -0
- package/dist/components/common/Modal/Modal.js +6 -0
- package/dist/config/EnvConfig.d.ts +13 -0
- package/dist/config/EnvConfig.js +13 -0
- package/dist/config/amplifyConfig.d.ts +1 -0
- package/dist/config/amplifyConfig.js +45 -0
- package/dist/configureAppHost.d.ts +6 -0
- package/dist/configureAppHost.js +5 -0
- package/dist/customGraphQL/customMutations.d.ts +3 -0
- package/dist/customGraphQL/customMutations.js +53 -0
- package/dist/customGraphQL/customQueries.d.ts +7 -0
- package/dist/customGraphQL/customQueries.js +104 -0
- package/dist/domain/input/input-types.d.ts +47 -0
- package/dist/domain/input/input-types.js +1 -0
- package/dist/domain/model/BranchDto.d.ts +9 -0
- package/dist/domain/model/BranchDto.js +8 -0
- package/dist/domain/model/ComponentMappingDto.d.ts +24 -0
- package/dist/domain/model/ComponentMappingDto.js +19 -0
- package/dist/domain/model/MappingDto.d.ts +30 -0
- package/dist/domain/model/MappingDto.js +16 -0
- package/dist/domain/model/PrefixDescriptionDto.d.ts +16 -0
- package/dist/domain/model/PrefixDescriptionDto.js +13 -0
- package/dist/domain/model/ProfileDto.d.ts +21 -0
- package/dist/domain/model/ProfileDto.js +20 -0
- package/dist/domain/model/RoleMappingDto.d.ts +14 -0
- package/dist/domain/model/RoleMappingDto.js +19 -0
- package/dist/domain/model/SettingsDto.d.ts +8 -0
- package/dist/domain/model/SettingsDto.js +7 -0
- package/dist/domain/model/UserMappingDto.d.ts +14 -0
- package/dist/domain/model/UserMappingDto.js +28 -0
- package/dist/domain/model/imageDto.d.ts +4 -0
- package/dist/domain/model/imageDto.js +1 -0
- package/dist/domain/type/EntityTypes.d.ts +5 -0
- package/dist/domain/type/EntityTypes.js +6 -0
- package/dist/domain/type/MappingOptions.d.ts +5 -0
- package/dist/domain/type/MappingOptions.js +1 -0
- package/dist/domain/type/MappingTypes.d.ts +6 -0
- package/dist/domain/type/MappingTypes.js +7 -0
- package/dist/domain/type/Nullable.d.ts +13 -0
- package/dist/domain/type/Nullable.js +1 -0
- package/dist/domain/type/ResettingPeriodOptions.d.ts +2 -0
- package/dist/domain/type/ResettingPeriodOptions.js +8 -0
- package/dist/domain/type/RolesEnum.d.ts +6 -0
- package/dist/domain/type/RolesEnum.js +7 -0
- package/dist/domain/type/SelectType.d.ts +16 -0
- package/dist/domain/type/SelectType.js +1 -0
- package/dist/domain/type/StatusEnum.d.ts +5 -0
- package/dist/domain/type/StatusEnum.js +6 -0
- package/dist/domain/type/signUpOptions.d.ts +2 -0
- package/dist/domain/type/signUpOptions.js +4 -0
- package/dist/domain/type/statusOptions.d.ts +2 -0
- package/dist/domain/type/statusOptions.js +4 -0
- package/dist/graphql/profileQueries.d.ts +4 -0
- package/dist/graphql/profileQueries.js +89 -0
- package/dist/hoc/withSyzyAuth.d.ts +2 -0
- package/dist/hoc/withSyzyAuth.js +87 -0
- package/dist/hooks/useCurrentUser.d.ts +3 -0
- package/dist/hooks/useCurrentUser.js +6 -0
- package/dist/hooks/useDispatch.d.ts +3 -0
- package/dist/hooks/useDispatch.js +7 -0
- package/dist/hooks/usePermission.d.ts +1 -0
- package/dist/hooks/usePermission.js +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -15
- package/dist/main.d.ts +4 -0
- package/dist/main.js +60 -0
- package/dist/services/Client.Service.d.ts +12 -0
- package/dist/services/Client.Service.js +96 -0
- package/dist/services/Storage-service.d.ts +2 -0
- package/dist/services/Storage-service.js +26 -0
- package/dist/services/navigationMenu.d.ts +1 -0
- package/dist/services/navigationMenu.js +9 -0
- package/dist/static/constants.d.ts +34 -0
- package/dist/static/constants.js +34 -0
- package/dist/store/AppAction.d.ts +11 -0
- package/dist/store/AppAction.js +5 -0
- package/dist/store/AppContext.d.ts +3 -0
- package/dist/store/AppContext.js +3 -0
- package/dist/store/AppContextType.d.ts +12 -0
- package/dist/store/AppContextType.js +6 -0
- package/dist/store/AppProvider.d.ts +7 -0
- package/dist/store/AppProvider.js +32 -0
- package/dist/store/HostedInContainerContext.d.ts +5 -0
- package/dist/store/HostedInContainerContext.js +11 -0
- package/dist/store/SesssionReducer.d.ts +4 -0
- package/dist/store/SesssionReducer.js +16 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.js +14 -0
- package/dist/util/AuthUtils.d.ts +1 -0
- package/dist/util/AuthUtils.js +10 -0
- package/dist/util/LogEnum.d.ts +6 -0
- package/dist/util/LogEnum.js +7 -0
- package/dist/util/Logger.d.ts +6 -0
- package/dist/util/Logger.js +18 -0
- package/dist/util/SyzyDate.d.ts +69 -0
- package/dist/util/SyzyDate.js +265 -0
- package/dist/util/dateUtils.d.ts +10 -0
- package/dist/util/dateUtils.js +24 -0
- package/dist/util/hostedinContainer.d.ts +1 -0
- package/dist/util/hostedinContainer.js +9 -0
- package/dist/util/model-types.d.ts +96 -0
- package/dist/util/model-types.js +18 -0
- package/dist/util/prefixAndResettingValidation.d.ts +9 -0
- package/dist/util/prefixAndResettingValidation.js +54 -0
- package/dist/util/transformToData.d.ts +1 -0
- package/dist/util/transformToData.js +9 -0
- package/package.json +14 -9
- package/dist/__federation_shared_@tanstack/react-query-DHuUsaNz.js +0 -2517
- package/dist/__federation_shared_react-CikWE6qG.js +0 -7
- package/dist/__federation_shared_react-bootstrap-BKlZRvMR.js +0 -7516
- package/dist/__federation_shared_react-dom-vrQ70Ay8.js +0 -372
- package/dist/__federation_shared_react-router-dom-BKminmS4.js +0 -10448
- package/dist/__federation_shared_react-select-B6kehBDI.js +0 -4056
- package/dist/__federation_shared_react-toastify-B0S0UGr3.js +0 -412
- package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
- package/dist/_virtual___federation_fn_import-XZCKozko.js +0 -217
- package/dist/favicon.ico +0 -0
- package/dist/index-DgtWMtjZ.js +0 -184
- package/dist/index-eZknuYwc.js +0 -1219
- package/dist/jsx-runtime-D_t4bG-_.js +0 -264
- package/dist/manifest.webmanifest +0 -1
- package/dist/pwa/Hotel-icon.jpg +0 -0
- package/dist/pwa/apple-touch-icon-180x180.png +0 -0
- package/dist/pwa/favicon.ico +0 -0
- package/dist/pwa/maskable-icon-512x512.png +0 -0
- package/dist/pwa/pwa-192x192.png +0 -0
- package/dist/pwa/pwa-512x512.png +0 -0
- package/dist/pwa/pwa-64x64.png +0 -0
- package/dist/registerSW.js +0 -1
- package/dist/sw.js +0 -1
- package/dist/workbox-1ef09536.js +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
5
|
+
import { Form, Col } from "react-bootstrap";
|
|
6
|
+
import { toast, ToastContainer } from "react-toastify";
|
|
7
|
+
import { useBranchSchema } from "./branchSchema";
|
|
8
|
+
import { useCreateBranchMutation, useUpdateBranchMutation, useListBranches } from "../../../api/mapping-api";
|
|
9
|
+
import { logger } from "../../../util/Logger";
|
|
10
|
+
import "../../../styles/button.css";
|
|
11
|
+
import "../../Mappings/MappingForm/MappingForm.css";
|
|
12
|
+
import { SyzyDate } from "../../../util/SyzyDate";
|
|
13
|
+
import { DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM } from "../../../util/dateUtils";
|
|
14
|
+
import FormModal from "../../common/Modal/Modal";
|
|
15
|
+
import ListTable from "../../common/ListTable/ListTable";
|
|
16
|
+
import { BranchTableColumns } from "./BranchTableColumns";
|
|
17
|
+
import FormLabel from "../../common/Form/FormLabel";
|
|
18
|
+
import FormActionButtons from "../../common/Form/FormActionButtons";
|
|
19
|
+
import ListHeader from "../../common/ListTable/ListHeader";
|
|
20
|
+
const BranchMapping = () => {
|
|
21
|
+
const { branchSchema, initiateBranch } = useBranchSchema();
|
|
22
|
+
const createBranchMutation = useCreateBranchMutation();
|
|
23
|
+
const updateBranchMutation = useUpdateBranchMutation();
|
|
24
|
+
const { data: branches, isLoading } = useListBranches();
|
|
25
|
+
// Modal and form states
|
|
26
|
+
const [showModal, setShowModal] = useState(false);
|
|
27
|
+
const [editingBranch, setEditingBranch] = useState(null);
|
|
28
|
+
const isEditMode = Boolean(editingBranch && editingBranch.pk);
|
|
29
|
+
const loading = isEditMode ? updateBranchMutation.isPending : createBranchMutation.isPending;
|
|
30
|
+
const tableLoading = isLoading || createBranchMutation.isPending || updateBranchMutation.isPending;
|
|
31
|
+
const { register, handleSubmit, reset, formState: { errors }, } = useForm({
|
|
32
|
+
resolver: zodResolver(branchSchema),
|
|
33
|
+
defaultValues: initiateBranch,
|
|
34
|
+
mode: "onChange",
|
|
35
|
+
});
|
|
36
|
+
// Reset form values when editing
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (isEditMode && editingBranch) {
|
|
39
|
+
reset({
|
|
40
|
+
...editingBranch,
|
|
41
|
+
branchName: editingBranch.sk,
|
|
42
|
+
status: editingBranch.status ?? "ACTIVE",
|
|
43
|
+
createdDt: editingBranch.createdDt ?? new SyzyDate().toDateFormatString(DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
reset(initiateBranch);
|
|
48
|
+
}
|
|
49
|
+
}, [editingBranch, isEditMode, reset]);
|
|
50
|
+
// Open modal for editing
|
|
51
|
+
const handleEdit = (branch) => {
|
|
52
|
+
setEditingBranch(branch);
|
|
53
|
+
setShowModal(true);
|
|
54
|
+
reset({
|
|
55
|
+
...branch,
|
|
56
|
+
branchName: branch.sk,
|
|
57
|
+
status: branch.status ?? "ACTIVE",
|
|
58
|
+
createdDt: branch.createdDt ?? new SyzyDate().toDateFormatString(DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM),
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
// Form submit handler
|
|
62
|
+
const onSubmit = async (data) => {
|
|
63
|
+
try {
|
|
64
|
+
// EDIT MODE
|
|
65
|
+
if (isEditMode && editingBranch?.pk) {
|
|
66
|
+
const skChanged = data.branchName !== editingBranch.sk;
|
|
67
|
+
if (skChanged) {
|
|
68
|
+
// Step 1: mark old row as INACTIVE
|
|
69
|
+
await updateBranchMutation.mutateAsync({
|
|
70
|
+
pk: editingBranch.pk,
|
|
71
|
+
sk: editingBranch.sk,
|
|
72
|
+
branchAddress: editingBranch.branchAddress,
|
|
73
|
+
branchContactNumber: editingBranch.branchContactNumber,
|
|
74
|
+
status: "INACTIVE",
|
|
75
|
+
createdDt: editingBranch.createdDt,
|
|
76
|
+
});
|
|
77
|
+
// Step 2: create new row with new SK
|
|
78
|
+
await updateBranchMutation.mutateAsync({
|
|
79
|
+
pk: editingBranch.pk,
|
|
80
|
+
sk: data.branchName,
|
|
81
|
+
branchAddress: data.branchAddress,
|
|
82
|
+
branchContactNumber: data.branchContactNumber,
|
|
83
|
+
status: "ACTIVE",
|
|
84
|
+
createdDt: new SyzyDate().toDateFormatString(DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM),
|
|
85
|
+
});
|
|
86
|
+
toast.success("Branch renamed and updated successfully!");
|
|
87
|
+
setShowModal(false);
|
|
88
|
+
setEditingBranch(null);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// NORMAL update (no rename)
|
|
92
|
+
await updateBranchMutation.mutateAsync({
|
|
93
|
+
pk: editingBranch.pk,
|
|
94
|
+
sk: data.branchName,
|
|
95
|
+
branchAddress: data.branchAddress,
|
|
96
|
+
branchContactNumber: data.branchContactNumber,
|
|
97
|
+
status: data.status ?? "ACTIVE",
|
|
98
|
+
createdDt: editingBranch.createdDt ?? new Date().toISOString(),
|
|
99
|
+
});
|
|
100
|
+
toast.success("Branch updated successfully!");
|
|
101
|
+
setShowModal(false);
|
|
102
|
+
setEditingBranch(null);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// CREATE MODE
|
|
106
|
+
await createBranchMutation.mutateAsync({
|
|
107
|
+
branchName: data.branchName,
|
|
108
|
+
branchAddress: data.branchAddress,
|
|
109
|
+
branchContactNumber: data.branchContactNumber,
|
|
110
|
+
status: data.status ?? "ACTIVE",
|
|
111
|
+
});
|
|
112
|
+
toast.success("Branch created successfully!");
|
|
113
|
+
setShowModal(false);
|
|
114
|
+
reset(initiateBranch);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
logger.error("Branch operation error", err);
|
|
118
|
+
toast.error("Branch operation failed");
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, {}), _jsxs("div", { className: "container", children: [_jsx(ListHeader, { title: "Branches List", buttonLabel: "Add Branch", onButtonClick: () => {
|
|
122
|
+
reset(initiateBranch);
|
|
123
|
+
setEditingBranch(null);
|
|
124
|
+
setShowModal(true);
|
|
125
|
+
} }), isLoading ? null : (_jsx(ListTable, { columns: BranchTableColumns, data: branches ?? [], emptyMessage: "No branches found", onEdit: handleEdit, loading: tableLoading }))] }), _jsx(FormModal, { show: showModal, title: isEditMode ? "Edit Branch" : "Create Branch", onClose: () => {
|
|
126
|
+
setShowModal(false);
|
|
127
|
+
setEditingBranch(null);
|
|
128
|
+
reset(initiateBranch);
|
|
129
|
+
}, children: _jsxs(Form, { className: "branch-form", onSubmit: handleSubmit(onSubmit), children: [_jsxs(Col, { children: [_jsx(FormLabel, { label: "Branch Name", required: true }), _jsx(Form.Control, { ...register("branchName"), isInvalid: !!errors.branchName, placeholder: "Enter branch name" }), _jsx(Form.Text, { className: "text-danger", children: errors.branchName?.message })] }), _jsxs(Col, { children: [_jsx(FormLabel, { label: "Branch Address", required: true }), _jsx(Form.Control, { ...register("branchAddress"), isInvalid: !!errors.branchAddress, placeholder: "Enter branch address" }), _jsx(Form.Text, { className: "text-danger", children: errors.branchAddress?.message })] }), _jsxs(Col, { children: [_jsx(FormLabel, { label: "Contact Number", required: true }), _jsx(Form.Control, { ...register("branchContactNumber"), isInvalid: !!errors.branchContactNumber, placeholder: "Enter branch contact number" }), _jsx(Form.Text, { className: "text-danger", children: errors.branchContactNumber?.message })] }), _jsxs(Col, { children: [_jsx(FormLabel, { label: "Status" }), _jsxs(Form.Select, { ...register("status"), children: [_jsx("option", { value: "ACTIVE", children: "ACTIVE" }), _jsx("option", { value: "INACTIVE", children: "INACTIVE" })] })] }), _jsx(FormActionButtons, { isEditMode: isEditMode, loading: loading, onClear: () => {
|
|
130
|
+
setShowModal(false);
|
|
131
|
+
setEditingBranch(null);
|
|
132
|
+
reset(initiateBranch);
|
|
133
|
+
} })] }) })] }));
|
|
134
|
+
};
|
|
135
|
+
export default BranchMapping;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TableColumn } from "../../common/ListTable/ListTable";
|
|
2
|
+
export interface BranchRow {
|
|
3
|
+
pk: string;
|
|
4
|
+
sk: string;
|
|
5
|
+
branchAddress: string;
|
|
6
|
+
branchContactNumber: string;
|
|
7
|
+
createdDt: string;
|
|
8
|
+
status: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const BranchTableColumns: TableColumn<BranchRow>[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
3
|
+
export const BranchTableColumns = [
|
|
4
|
+
{
|
|
5
|
+
header: "Branch Name",
|
|
6
|
+
accessor: (row) => row.sk,
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
header: "Address",
|
|
10
|
+
accessor: "branchAddress",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
header: "Contact Number",
|
|
14
|
+
accessor: "branchContactNumber",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
header: "Status",
|
|
18
|
+
accessor: (row) => (_jsx("span", { className: `status-message ${row.status === Status.Active ? "text-success" : "text-danger"}`, children: row.status })),
|
|
19
|
+
align: "center",
|
|
20
|
+
},
|
|
21
|
+
];
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import MappingForm from "../MappingForm/MappingForm";
|
|
4
|
+
import FormModal from "../../common/Modal/Modal";
|
|
5
|
+
import ListTable from "../../common/ListTable/ListTable";
|
|
6
|
+
import { toast, ToastContainer } from "react-toastify";
|
|
7
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
8
|
+
import { useListBranches, useListProfiles, useCreateMappingMutation, useUpdateMappingMutation, getRoleMappingByUserIdAndRoleNameFun, fetchBranchUserMappings } from "../../../api/mapping-api";
|
|
9
|
+
import { EntityTypes } from "../../../domain/type/EntityTypes";
|
|
10
|
+
import { SyzyDate } from "../../../util/SyzyDate";
|
|
11
|
+
import { DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM_SS } from "../../../util/dateUtils";
|
|
12
|
+
import { logger } from "../../../util/Logger";
|
|
13
|
+
import { BranchUserTableColumns } from "./MappingTableColumns";
|
|
14
|
+
import ListHeader from "../../common/ListTable/ListHeader";
|
|
15
|
+
const MappingFormBranchUser = () => {
|
|
16
|
+
const [showModal, setShowModal] = useState(false);
|
|
17
|
+
const [editingRow, setEditingRow] = useState();
|
|
18
|
+
const [branches, setBranches] = useState([]);
|
|
19
|
+
const [users, setUsers] = useState([]);
|
|
20
|
+
const [mappings, setMappings] = useState([]);
|
|
21
|
+
const [loading, setLoading] = useState(true);
|
|
22
|
+
const currentISODate = new SyzyDate().toDateFormatString(DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM_SS);
|
|
23
|
+
const { data: branchList, isLoading } = useListBranches();
|
|
24
|
+
const { data: profiles, isLoading: isProfilesLoading } = useListProfiles();
|
|
25
|
+
const createMappingMutation = useCreateMappingMutation();
|
|
26
|
+
const updateMappingMutation = useUpdateMappingMutation();
|
|
27
|
+
const tableLoading = isLoading || isProfilesLoading || createMappingMutation.isPending || updateMappingMutation.isPending;
|
|
28
|
+
/** Load branches */
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (branchList) {
|
|
31
|
+
setBranches(branchList.map((b) => ({ id: b.pk, name: b.sk })));
|
|
32
|
+
}
|
|
33
|
+
}, [branchList]);
|
|
34
|
+
/** Load users */
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (profiles) {
|
|
37
|
+
setUsers(profiles.map((p) => ({ id: p.sk, name: p.name })));
|
|
38
|
+
}
|
|
39
|
+
}, [profiles]);
|
|
40
|
+
/* ---------------- Load Mappings ---------------- */
|
|
41
|
+
const loadMappings = async () => {
|
|
42
|
+
try {
|
|
43
|
+
if (!branchList)
|
|
44
|
+
return;
|
|
45
|
+
const branchMap = {};
|
|
46
|
+
branchList.forEach((b) => {
|
|
47
|
+
branchMap[b.pk.replace("BRANCH#", "")] = b.sk;
|
|
48
|
+
});
|
|
49
|
+
const result = await fetchBranchUserMappings(branchMap);
|
|
50
|
+
const enriched = result.map((m) => {
|
|
51
|
+
const branchId = m.pk.replace("BRANCH#", "");
|
|
52
|
+
return {
|
|
53
|
+
...m,
|
|
54
|
+
branchId,
|
|
55
|
+
branchName: branchMap[branchId] ?? "Unknown Branch",
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
setMappings(enriched);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
toast.error("Failed to load mappings");
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
setLoading(false);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
loadMappings();
|
|
69
|
+
}, [branchList]);
|
|
70
|
+
/* ---------------- Edit / Add ---------------- */
|
|
71
|
+
const handleEdit = (row) => {
|
|
72
|
+
setEditingRow(row);
|
|
73
|
+
setShowModal(true);
|
|
74
|
+
};
|
|
75
|
+
const handleAdd = () => {
|
|
76
|
+
setEditingRow(undefined);
|
|
77
|
+
setShowModal(true);
|
|
78
|
+
};
|
|
79
|
+
/* ---------------- Submit ---------------- */
|
|
80
|
+
const handleSubmit = async (data) => {
|
|
81
|
+
try {
|
|
82
|
+
for (const map of data) {
|
|
83
|
+
const user = users.find(u => u.id === map.sourceId);
|
|
84
|
+
const branch = branches.find(b => b.id === map.branchId);
|
|
85
|
+
if (!user || !branch)
|
|
86
|
+
continue;
|
|
87
|
+
const payload = {
|
|
88
|
+
pk: `BRANCH#${map.branchId}`,
|
|
89
|
+
sk: `USER#${user.id}`,
|
|
90
|
+
branchName: branch.name,
|
|
91
|
+
entity: EntityTypes.USER,
|
|
92
|
+
userId: user.id,
|
|
93
|
+
userName: user.name,
|
|
94
|
+
roleId: "null",
|
|
95
|
+
roleName: "null",
|
|
96
|
+
componentId: "null",
|
|
97
|
+
componentTitle: "null",
|
|
98
|
+
status: map.status,
|
|
99
|
+
createdDt: editingRow?.createdDt || currentISODate,
|
|
100
|
+
createdBy: `${user.id}#${user.name}`,
|
|
101
|
+
disabledDt: map.status === Status.Inactive ? currentISODate : "",
|
|
102
|
+
};
|
|
103
|
+
const isBranchChanged = editingRow && editingRow.branchId !== map.branchId;
|
|
104
|
+
const isUserChanged = editingRow && editingRow.userId !== user.id;
|
|
105
|
+
if (editingRow && (isBranchChanged || isUserChanged)) {
|
|
106
|
+
await updateMappingMutation.mutateAsync({
|
|
107
|
+
pk: editingRow.pk,
|
|
108
|
+
sk: `USER#${editingRow.userId}`,
|
|
109
|
+
branchName: editingRow.branchName,
|
|
110
|
+
entity: EntityTypes.USER,
|
|
111
|
+
userId: editingRow.userId,
|
|
112
|
+
userName: editingRow.userName,
|
|
113
|
+
roleId: "null",
|
|
114
|
+
roleName: "null",
|
|
115
|
+
componentId: "null",
|
|
116
|
+
componentTitle: "null",
|
|
117
|
+
status: Status.Inactive,
|
|
118
|
+
createdDt: editingRow.createdDt,
|
|
119
|
+
createdBy: `${user.id}#${user.name}`,
|
|
120
|
+
disabledDt: currentISODate,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const existing = await getRoleMappingByUserIdAndRoleNameFun(payload.pk, payload.sk);
|
|
124
|
+
if (existing) {
|
|
125
|
+
await updateMappingMutation.mutateAsync(payload);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
await createMappingMutation.mutateAsync(payload);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
toast.success("Branch-User mapping saved successfully");
|
|
132
|
+
setShowModal(false);
|
|
133
|
+
loadMappings();
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
logger.error(err);
|
|
137
|
+
toast.error("Mapping failed");
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/* ---------------- Render ---------------- */
|
|
141
|
+
return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, {}), _jsxs("div", { className: "container", children: [_jsx(ListHeader, { title: "Branch & User Mappings List", buttonLabel: "Add Mapping", onButtonClick: handleAdd }), loading ? null : (_jsx(ListTable, { columns: BranchUserTableColumns, data: mappings, emptyMessage: "No branch-user mappings found", onEdit: handleEdit, loading: tableLoading })), _jsx(FormModal, { show: showModal, title: editingRow ? "Edit Branch-User Mapping" : "Assign Branch to User", onClose: () => setShowModal(false), size: "lg", children: _jsx(MappingForm, { mode: "branch-user", hideBranch: false, hideTarget: true, branchOptions: branches, sourceLabel: "User", targetLabel: "", sourceOptions: users, targetOptions: [], onSubmit: handleSubmit, initialMapping: editingRow
|
|
142
|
+
? {
|
|
143
|
+
branchId: editingRow.branchId,
|
|
144
|
+
sourceId: editingRow.userId,
|
|
145
|
+
sourceName: editingRow.userName,
|
|
146
|
+
status: editingRow.status,
|
|
147
|
+
}
|
|
148
|
+
: undefined }) })] })] }));
|
|
149
|
+
};
|
|
150
|
+
export default MappingFormBranchUser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableColumn } from "../../common/ListTable/ListTable";
|
|
2
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
3
|
+
export interface BranchUserRow {
|
|
4
|
+
pk: string;
|
|
5
|
+
sk: string;
|
|
6
|
+
branchId: string;
|
|
7
|
+
branchName: string;
|
|
8
|
+
userId: string;
|
|
9
|
+
userName: string;
|
|
10
|
+
status: Status;
|
|
11
|
+
createdDt: string;
|
|
12
|
+
disabledDt?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const BranchUserTableColumns: TableColumn<BranchUserRow>[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
3
|
+
export const BranchUserTableColumns = [
|
|
4
|
+
{
|
|
5
|
+
header: "ID",
|
|
6
|
+
accessor: "userId",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
header: "User",
|
|
10
|
+
accessor: "userName",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
header: "Branch",
|
|
14
|
+
accessor: "branchName",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
header: "Created",
|
|
18
|
+
accessor: "createdDt",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
header: "Disabled",
|
|
22
|
+
accessor: (row) => row.disabledDt ? new Date(row.disabledDt).toLocaleString() : "-",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
header: "Status",
|
|
26
|
+
accessor: (row) => (_jsx("span", { className: `status-message ${row.status === Status.Active ? "text-success" : "text-danger"}`, children: row.status })),
|
|
27
|
+
align: "center",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const branchSchema: z.ZodObject<{
|
|
3
|
+
branchName: z.ZodString;
|
|
4
|
+
branchAddress: z.ZodString;
|
|
5
|
+
branchContactNumber: z.ZodString;
|
|
6
|
+
pk: z.ZodOptional<z.ZodString>;
|
|
7
|
+
sk: z.ZodOptional<z.ZodString>;
|
|
8
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
ACTIVE: "ACTIVE";
|
|
10
|
+
INACTIVE: "INACTIVE";
|
|
11
|
+
}>>;
|
|
12
|
+
createdDt: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type BranchFormInputs = z.infer<typeof branchSchema>;
|
|
15
|
+
export declare const useBranchSchema: () => {
|
|
16
|
+
branchSchema: z.ZodObject<{
|
|
17
|
+
branchName: z.ZodString;
|
|
18
|
+
branchAddress: z.ZodString;
|
|
19
|
+
branchContactNumber: z.ZodString;
|
|
20
|
+
pk: z.ZodOptional<z.ZodString>;
|
|
21
|
+
sk: z.ZodOptional<z.ZodString>;
|
|
22
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
ACTIVE: "ACTIVE";
|
|
24
|
+
INACTIVE: "INACTIVE";
|
|
25
|
+
}>>;
|
|
26
|
+
createdDt: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
initiateBranch: {
|
|
29
|
+
branchName: string;
|
|
30
|
+
branchAddress: string;
|
|
31
|
+
branchContactNumber: string;
|
|
32
|
+
pk?: string | undefined;
|
|
33
|
+
sk?: string | undefined;
|
|
34
|
+
status?: "ACTIVE" | "INACTIVE" | undefined;
|
|
35
|
+
createdDt?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/components/validation/branchSchema.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const branchSchema = z.object({
|
|
4
|
+
branchName: z
|
|
5
|
+
.string()
|
|
6
|
+
.min(1, "Branch name is required")
|
|
7
|
+
.min(3, "Branch name must be at least 3 characters"),
|
|
8
|
+
branchAddress: z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1, "Branch address is required")
|
|
11
|
+
.min(5, "Branch address must be at least 5 characters"),
|
|
12
|
+
branchContactNumber: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(10, "Contact number must be 10 digits")
|
|
15
|
+
.max(10, "Contact number must be 10 digits")
|
|
16
|
+
.regex(/^\d{10}$/, "Enter a valid 10-digit phone number"),
|
|
17
|
+
// Required for API inputs
|
|
18
|
+
pk: z.string().optional(),
|
|
19
|
+
sk: z.string().optional(),
|
|
20
|
+
status: z.enum(["ACTIVE", "INACTIVE"]).optional(),
|
|
21
|
+
createdDt: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
export const useBranchSchema = () => {
|
|
24
|
+
const initiateBranch = {
|
|
25
|
+
branchName: "",
|
|
26
|
+
branchAddress: "",
|
|
27
|
+
branchContactNumber: "",
|
|
28
|
+
pk: "",
|
|
29
|
+
sk: "",
|
|
30
|
+
status: "ACTIVE",
|
|
31
|
+
createdDt: "",
|
|
32
|
+
};
|
|
33
|
+
return { branchSchema, initiateBranch };
|
|
34
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useMemo, useState } from "react";
|
|
3
|
+
import MappingForm from "../MappingForm/MappingForm";
|
|
4
|
+
import FormModal from "../../common/Modal/Modal";
|
|
5
|
+
import ListTable from "../../common/ListTable/ListTable";
|
|
6
|
+
import { toast } from "react-toastify";
|
|
7
|
+
import { MappingTypes } from "../../../domain/type/MappingTypes";
|
|
8
|
+
import { getCompoMappingByRoleIdAndCompoIdFun, useCreateMappingMutation, useListComponentRoleMappings, useUpdateMappingMutation, } from "../../../api/mapping-api";
|
|
9
|
+
import { EntityTypes } from "../../../domain/type/EntityTypes";
|
|
10
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
11
|
+
import { SyzyDate } from "../../../util/SyzyDate";
|
|
12
|
+
import { DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM_SS } from "../../../util/dateUtils";
|
|
13
|
+
import AppContext from "../../../store/AppContext";
|
|
14
|
+
import { logger } from "../../../util/Logger";
|
|
15
|
+
import { componentMap } from "../../../App";
|
|
16
|
+
import { roles } from "../RoleMapping/MappingFormUserRole";
|
|
17
|
+
import { ComponentRoleTableColumns } from "./componentRoleColumns";
|
|
18
|
+
import ListHeader from "../../common/ListTable/ListHeader";
|
|
19
|
+
import { ToastContainer } from "react-toastify";
|
|
20
|
+
/* ---------------- Component Role Mapping ---------------- */
|
|
21
|
+
const ComponentRoleMappingPage = () => {
|
|
22
|
+
const { user } = useContext(AppContext) || {};
|
|
23
|
+
const loggedInUserName = user?.userName;
|
|
24
|
+
const [showModal, setShowModal] = useState(false);
|
|
25
|
+
const [editingRow, setEditingRow] = useState();
|
|
26
|
+
const currentISODate = new SyzyDate().toDateFormatString(DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM_SS);
|
|
27
|
+
const { data = [], isLoading, refetch } = useListComponentRoleMappings();
|
|
28
|
+
const createMappingMutation = useCreateMappingMutation();
|
|
29
|
+
const updateMappingMutation = useUpdateMappingMutation();
|
|
30
|
+
const tableLoading = isLoading || createMappingMutation.isPending || updateMappingMutation.isPending;
|
|
31
|
+
/* ---------------- Component Options ---------------- */
|
|
32
|
+
const components = useMemo(() => Object.keys(componentMap).map((key, index) => ({
|
|
33
|
+
id: `Component#${String(index + 1).padStart(2, "0")}`,
|
|
34
|
+
name: key,
|
|
35
|
+
})), []);
|
|
36
|
+
/* ---------------- Add / Edit ---------------- */
|
|
37
|
+
const handleAdd = () => {
|
|
38
|
+
setEditingRow(undefined);
|
|
39
|
+
setShowModal(true);
|
|
40
|
+
};
|
|
41
|
+
const handleEdit = (row) => {
|
|
42
|
+
setEditingRow(row);
|
|
43
|
+
setShowModal(true);
|
|
44
|
+
};
|
|
45
|
+
/* ---------------- Submit ---------------- */
|
|
46
|
+
const handleSubmit = async (mappings) => {
|
|
47
|
+
try {
|
|
48
|
+
for (const map of mappings) {
|
|
49
|
+
const role = roles.find(r => r.id === map.targetId);
|
|
50
|
+
const component = components.find(c => c.id === map.sourceId);
|
|
51
|
+
if (!role || !component || !loggedInUserName)
|
|
52
|
+
continue;
|
|
53
|
+
const payload = {
|
|
54
|
+
pk: role.id,
|
|
55
|
+
sk: `COMPId#${component.id}`,
|
|
56
|
+
entity: EntityTypes.COMPONENT,
|
|
57
|
+
userId: "",
|
|
58
|
+
userName: "",
|
|
59
|
+
roleId: role.id,
|
|
60
|
+
roleName: role.name,
|
|
61
|
+
componentId: component.id,
|
|
62
|
+
componentTitle: component.name,
|
|
63
|
+
status: map.status,
|
|
64
|
+
createdDt: editingRow?.createdDt || currentISODate,
|
|
65
|
+
createdBy: loggedInUserName,
|
|
66
|
+
disabledDt: map.status === Status.Inactive ? currentISODate : "",
|
|
67
|
+
};
|
|
68
|
+
const existing = await getCompoMappingByRoleIdAndCompoIdFun(payload.pk, payload.sk);
|
|
69
|
+
if (existing) {
|
|
70
|
+
await updateMappingMutation.mutateAsync(payload);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
await createMappingMutation.mutateAsync(payload);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
toast.success("Component-Role mapping saved successfully");
|
|
77
|
+
setShowModal(false);
|
|
78
|
+
refetch();
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
logger.error(err);
|
|
82
|
+
toast.error("Component-Role mapping failed");
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/* ---------------- Render ---------------- */
|
|
86
|
+
return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, {}), _jsxs("div", { className: "container", children: [_jsx(ListHeader, { title: "Users List", buttonLabel: "Add Mapping", onButtonClick: handleAdd }), isLoading ? null : (_jsx(ListTable, { columns: ComponentRoleTableColumns, data: data, emptyMessage: "No component-role mappings found", onEdit: handleEdit, loading: tableLoading })), _jsx(FormModal, { show: showModal, title: editingRow
|
|
87
|
+
? "Edit Component-Role Mapping"
|
|
88
|
+
: "Assign Role to Component", onClose: () => setShowModal(false), size: "lg", children: _jsx(MappingForm, { mode: "default", hideBranch: true, hideTarget: false, sourceLabel: MappingTypes.Components, targetLabel: MappingTypes.Roles, sourceOptions: components, targetOptions: roles, onSubmit: handleSubmit, initialMapping: editingRow
|
|
89
|
+
? {
|
|
90
|
+
branchId: "DEFAULT_BRANCH",
|
|
91
|
+
sourceId: editingRow.sk.replace("COMPId#", ""),
|
|
92
|
+
sourceName: editingRow.componentTitle,
|
|
93
|
+
targetId: editingRow.pk,
|
|
94
|
+
status: editingRow.status,
|
|
95
|
+
}
|
|
96
|
+
: undefined }) })] })] }));
|
|
97
|
+
};
|
|
98
|
+
export default ComponentRoleMappingPage;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
3
|
+
export const ComponentRoleTableColumns = [
|
|
4
|
+
{
|
|
5
|
+
header: "Role",
|
|
6
|
+
accessor: "roleName",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
header: "Component",
|
|
10
|
+
accessor: "componentTitle",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
header: "Created Date",
|
|
14
|
+
accessor: (row) => row.createdDt
|
|
15
|
+
? new Date(row.createdDt).toLocaleString()
|
|
16
|
+
: "-",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
header: "Disabled Date",
|
|
20
|
+
accessor: (row) => row.disabledDt
|
|
21
|
+
? new Date(row.disabledDt).toLocaleString()
|
|
22
|
+
: "-",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
header: "Status",
|
|
26
|
+
accessor: (row) => (_jsx("span", { className: `status-message ${row.status === Status.Active ? "text-success" : "text-danger"}`, children: row.status })),
|
|
27
|
+
align: "center",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import './MappingForm.css';
|
|
3
|
+
import type { MappingOptions } from "../../../domain/type/MappingOptions";
|
|
4
|
+
import { Status } from "../../../domain/type/StatusEnum";
|
|
5
|
+
import '../../../styles/button.css';
|
|
6
|
+
interface MappingFormProps {
|
|
7
|
+
branchOptions?: MappingOptions[];
|
|
8
|
+
sourceLabel: string;
|
|
9
|
+
targetLabel: string;
|
|
10
|
+
sourceOptions: MappingOptions[];
|
|
11
|
+
targetOptions: MappingOptions[];
|
|
12
|
+
onSubmit: (mappings: {
|
|
13
|
+
branchId: string;
|
|
14
|
+
sourceId: string;
|
|
15
|
+
targetId: string;
|
|
16
|
+
status: string;
|
|
17
|
+
}[]) => void;
|
|
18
|
+
mode?: "default" | "branch-user";
|
|
19
|
+
hideBranch?: boolean;
|
|
20
|
+
hideTarget?: boolean;
|
|
21
|
+
onSourceChange?: (selected: MappingOptions[]) => void;
|
|
22
|
+
selectedUserBranch?: string[];
|
|
23
|
+
userHasNoBranch?: boolean;
|
|
24
|
+
/** Used when editing */
|
|
25
|
+
initialMapping?: {
|
|
26
|
+
branchId?: string;
|
|
27
|
+
sourceId: string;
|
|
28
|
+
sourceName: string;
|
|
29
|
+
branchName?: string;
|
|
30
|
+
targetId?: string;
|
|
31
|
+
status: Status;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
declare const MappingForm: React.FC<MappingFormProps>;
|
|
35
|
+
export default MappingForm;
|