@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,190 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useForm } from "react-hook-form";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { Form, Row, Col } from "react-bootstrap";
|
|
5
|
+
import { toast } from "react-toastify";
|
|
6
|
+
import { useCreateProfileMutation } from "../../api/mapping-api";
|
|
7
|
+
import { generateClient } from "aws-amplify/api";
|
|
8
|
+
import { useProfileSchema } from "./profileSchema";
|
|
9
|
+
import '../Mappings/MappingForm/MappingForm.css';
|
|
10
|
+
import { logger } from "../../util/Logger";
|
|
11
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
12
|
+
import { useUpdateProfileMutation } from "../../api/mapping-api";
|
|
13
|
+
import { Status } from "../../domain/type/StatusEnum";
|
|
14
|
+
import { useEffect, useState } from "react";
|
|
15
|
+
import { useGetImageURL, useImageMutation } from "../../api/image-api";
|
|
16
|
+
import { SyzyDate } from "../../util/SyzyDate";
|
|
17
|
+
import { DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM } from "../../util/dateUtils";
|
|
18
|
+
import LoadingSpinner from "../Loader/Loader";
|
|
19
|
+
const ProfileForm = () => {
|
|
20
|
+
const { profileSchema, initiateProfile } = useProfileSchema();
|
|
21
|
+
const createProfileMutation = useCreateProfileMutation();
|
|
22
|
+
const location = useLocation();
|
|
23
|
+
const navigate = useNavigate();
|
|
24
|
+
const editProfile = location.state;
|
|
25
|
+
const isEditMode = !!editProfile;
|
|
26
|
+
const [imgInfo, setImgInfo] = useState();
|
|
27
|
+
const imageMutation = useImageMutation(imgInfo);
|
|
28
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (isEditMode && editProfile) {
|
|
31
|
+
reset(mapProfileToFormValues(editProfile));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
reset(initiateProfile);
|
|
35
|
+
}
|
|
36
|
+
}, [editProfile]);
|
|
37
|
+
const mapProfileToFormValues = (profile) => ({
|
|
38
|
+
pk: profile.pk ?? "",
|
|
39
|
+
customId: profile.sk ?? "",
|
|
40
|
+
name: profile.name ?? "",
|
|
41
|
+
email: profile.email ?? "",
|
|
42
|
+
phoneNumber: profile.phoneNumber ?? "",
|
|
43
|
+
address: profile.address ?? "",
|
|
44
|
+
dob: profile.dob ?? "",
|
|
45
|
+
contactRelation: profile.contactRelation ?? "",
|
|
46
|
+
contactPersonName: profile.contactPersonName ?? "",
|
|
47
|
+
contactPersonNumber: profile.contactPersonNumber ?? "",
|
|
48
|
+
aadhaarNumber: profile.aadhaarNumber ?? "",
|
|
49
|
+
aadhaarFile: undefined,
|
|
50
|
+
status: profile.status ?? Status.Active,
|
|
51
|
+
});
|
|
52
|
+
const defaultValues = isEditMode
|
|
53
|
+
? mapProfileToFormValues(editProfile)
|
|
54
|
+
: initiateProfile;
|
|
55
|
+
const updateProfileMutation = useUpdateProfileMutation();
|
|
56
|
+
const { register, handleSubmit, formState: { errors }, reset, } = useForm({
|
|
57
|
+
resolver: zodResolver(profileSchema),
|
|
58
|
+
defaultValues,
|
|
59
|
+
mode: "onChange",
|
|
60
|
+
});
|
|
61
|
+
const handleAadhaarUploadAndNavigate = (file, customId) => {
|
|
62
|
+
if (file) {
|
|
63
|
+
const imageKey = `${customId}/profile-documents/${file.name}`;
|
|
64
|
+
const imgDto = { imageKey, file, };
|
|
65
|
+
imageMutation.mutate(imgDto);
|
|
66
|
+
setImgInfo(imgDto);
|
|
67
|
+
}
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
setIsSubmitting(false);
|
|
70
|
+
navigate("/profile-list");
|
|
71
|
+
}, 1200);
|
|
72
|
+
};
|
|
73
|
+
const aadhaarKey = isEditMode && editProfile?.aadhaarFile
|
|
74
|
+
? `${encodeURIComponent(editProfile.sk)}/profile-documents/${editProfile.aadhaarFile}`
|
|
75
|
+
: undefined;
|
|
76
|
+
const { fetchedImg } = useGetImageURL(aadhaarKey);
|
|
77
|
+
const onSubmit = async (data) => {
|
|
78
|
+
try {
|
|
79
|
+
const client = generateClient();
|
|
80
|
+
const file = data.aadhaarFile && data.aadhaarFile.length > 0 ? data.aadhaarFile[0] : null;
|
|
81
|
+
// Validate filename
|
|
82
|
+
const forbiddenCharsRegex = /[%#?&+\\/:*"<>|]/;
|
|
83
|
+
if (file && forbiddenCharsRegex.test(file.name)) {
|
|
84
|
+
toast.error("Filename contains unsupported characters.");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
setIsSubmitting(true);
|
|
88
|
+
const aadhaarFileName = file?.name ?? editProfile?.aadhaarFile ?? "";
|
|
89
|
+
// UPDATE PROFILE
|
|
90
|
+
if (editProfile) {
|
|
91
|
+
const updatePayload = {
|
|
92
|
+
pk: editProfile.pk,
|
|
93
|
+
sk: editProfile.sk,
|
|
94
|
+
customId: editProfile.customId,
|
|
95
|
+
name: data.name,
|
|
96
|
+
email: data.email,
|
|
97
|
+
phoneNumber: data.phoneNumber,
|
|
98
|
+
address: data.address,
|
|
99
|
+
dob: data.dob,
|
|
100
|
+
contactRelation: data.contactRelation,
|
|
101
|
+
contactPersonName: data.contactPersonName,
|
|
102
|
+
contactPersonNumber: data.contactPersonNumber,
|
|
103
|
+
aadhaarNumber: data.aadhaarNumber,
|
|
104
|
+
aadhaarFile: aadhaarFileName,
|
|
105
|
+
isAdmin: editProfile.isAdmin,
|
|
106
|
+
status: data.status ?? Status.Active,
|
|
107
|
+
createdDt: editProfile.createdDt,
|
|
108
|
+
createdBy: editProfile.createdBy,
|
|
109
|
+
};
|
|
110
|
+
updateProfileMutation.mutate(updatePayload, {
|
|
111
|
+
onSuccess: () => {
|
|
112
|
+
toast.success("Profile updated successfully!");
|
|
113
|
+
handleAadhaarUploadAndNavigate(file, editProfile.sk);
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// CREATE PROFILE
|
|
118
|
+
else {
|
|
119
|
+
const userId = `PROFILE#${Date.now()}`;
|
|
120
|
+
// Create Cognito User
|
|
121
|
+
await client.graphql({
|
|
122
|
+
query: `mutation CreateUserAccount($input: createUserAccountInput!) {
|
|
123
|
+
createUserAccount(input: $input) {
|
|
124
|
+
username
|
|
125
|
+
email
|
|
126
|
+
userId
|
|
127
|
+
response
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
`,
|
|
131
|
+
variables: {
|
|
132
|
+
input: {
|
|
133
|
+
username: data.customId,
|
|
134
|
+
email: data.email,
|
|
135
|
+
userId: userId,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
// Create Profile
|
|
140
|
+
await createProfileMutation.mutateAsync({
|
|
141
|
+
pk: userId,
|
|
142
|
+
sk: data.customId,
|
|
143
|
+
customId: data.customId,
|
|
144
|
+
name: data.name,
|
|
145
|
+
email: data.email,
|
|
146
|
+
phoneNumber: data.phoneNumber,
|
|
147
|
+
address: data.address,
|
|
148
|
+
dob: data.dob,
|
|
149
|
+
contactRelation: data.contactRelation,
|
|
150
|
+
contactPersonName: data.contactPersonName,
|
|
151
|
+
contactPersonNumber: data.contactPersonNumber,
|
|
152
|
+
aadhaarNumber: data.aadhaarNumber,
|
|
153
|
+
aadhaarFile: aadhaarFileName,
|
|
154
|
+
isAdmin: data.isAdmin ?? false,
|
|
155
|
+
status: data.status ?? Status.Active,
|
|
156
|
+
createdDt: new SyzyDate().toDateFormatString(DATE_FORMAT_ISO_YYYY_MM_DD_HH_MM),
|
|
157
|
+
createdBy: userId,
|
|
158
|
+
});
|
|
159
|
+
toast.success("Profile created successfully!");
|
|
160
|
+
handleAadhaarUploadAndNavigate(file, data.customId);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
setIsSubmitting(false);
|
|
165
|
+
const msg = err?.errors?.[0]?.message;
|
|
166
|
+
let errorMessage = "Failed to create profile!";
|
|
167
|
+
if (msg) {
|
|
168
|
+
if (msg === "Error creating user: UsernameExistsException: User account already exists") {
|
|
169
|
+
errorMessage = "Email ID already exists";
|
|
170
|
+
}
|
|
171
|
+
else if (msg === "Error creating user: UsernameExistsException: User account already exists and is expired. Please call with action RESEND to reset user account") {
|
|
172
|
+
errorMessage = "Employee ID already exists";
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const splitMsg = msg.split(":").slice(1).join(":").trim();
|
|
176
|
+
errorMessage = splitMsg || "Failed to create profile!";
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
toast.error(errorMessage);
|
|
180
|
+
logger.error("Profile created error", err);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
if (isSubmitting) {
|
|
184
|
+
return _jsx(LoadingSpinner, {});
|
|
185
|
+
}
|
|
186
|
+
return (_jsxs(Form, { onSubmit: handleSubmit(onSubmit), className: "mapping-form mx-auto col-12 col-md-10 col-xl-10 shadow-lg py-3 mt-sm-4 py-sm-4 container", children: [_jsxs(Row, { className: "px-lg-5 px-2 align-items-center justify-content-around", children: [_jsx("h5", { className: "text-center font-title", children: "Employee Registration" }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Employee ID" }), _jsx(Form.Control, { type: "text", ...register("customId"), placeholder: "Enter Employee ID", isInvalid: !!errors.customId, disabled: isEditMode }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.customId?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Name" }), _jsx(Form.Control, { type: "text", placeholder: "Enter Employee Name", ...register("name"), isInvalid: !!errors.name }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.name?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Email" }), _jsx(Form.Control, { type: "email", placeholder: "Enter Employee Email address", ...register("email"), isInvalid: !!errors.email }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.email?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Phone" }), _jsx(Form.Control, { type: "tel", placeholder: "Enter Employee Phone Number", ...register("phoneNumber"), isInvalid: !!errors.phoneNumber }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.phoneNumber?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Address" }), _jsx(Form.Control, { type: "text", placeholder: "Enter Employee Address", ...register("address"), isInvalid: !!errors.address }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.address?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Date of Birth" }), _jsx(Form.Control, { type: "date", ...register("dob"), isInvalid: !!errors.dob }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.dob?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Contact Person Relation" }), _jsxs(Form.Control, { as: "select", ...register("contactRelation"), isInvalid: !!errors.contactRelation, children: [_jsx("option", { value: "", children: "Select Relation" }), _jsx("option", { value: "Mother", children: "Mother" }), _jsx("option", { value: "Father", children: "Father" }), _jsx("option", { value: "Sister", children: "Sister" }), _jsx("option", { value: "Brother", children: "Brother" }), _jsx("option", { value: "Spouse", children: "Spouse" }), _jsx("option", { value: "Other", children: "Other" })] }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.contactRelation?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Contact Person Name" }), _jsx(Form.Control, { type: "text", placeholder: "Enter Employee Contact Person Name", ...register("contactPersonName"), isInvalid: !!errors.contactPersonName }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.contactPersonName?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Contact Person Number" }), _jsx(Form.Control, { type: "tel", placeholder: "Enter Employee Contact Person Number", ...register("contactPersonNumber"), isInvalid: !!errors.contactPersonNumber }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.contactPersonNumber?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Aadhaar Number" }), _jsx(Form.Control, { type: "text", placeholder: "Enter Employee Aadhaar Number", ...register("aadhaarNumber"), isInvalid: !!errors.aadhaarNumber }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.aadhaarNumber?.message })] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Upload Aadhaar" }), _jsx(Form.Control, { type: "file", accept: "image/*,application/pdf", ...register("aadhaarFile"), isInvalid: !!errors.aadhaarFile }), _jsx(Form.Control.Feedback, { type: "invalid", children: typeof errors.aadhaarFile?.message === "string"
|
|
187
|
+
? errors.aadhaarFile?.message
|
|
188
|
+
: "" }), isEditMode && fetchedImg && (_jsxs("div", { className: "mt-2", children: [_jsx("small", { children: "Existing Aadhaar:" }), _jsx("br", {}), _jsx("a", { href: fetchedImg, target: "_blank", rel: "noopener noreferrer", children: editProfile.aadhaarFile })] }))] }), _jsxs(Col, { xs: 12, md: 8, lg: 5, className: "mb-2 px-2 px-sm-auto", children: [_jsx(Form.Label, { className: "mt-2 mb-1 form-label", children: "Status" }), _jsxs(Form.Select, { ...register("status"), isInvalid: !!errors.status, children: [_jsx("option", { value: Status.Active, children: "Active" }), _jsx("option", { value: Status.Inactive, children: "Inactive" })] }), _jsx(Form.Control.Feedback, { type: "invalid", children: errors.status?.message })] })] }), _jsx(Row, { className: "justify-content-center mt-3", children: _jsxs(Col, { xs: 12, md: 8, lg: 4, className: "d-flex gap-2", children: [_jsx("button", { className: "btn-primary-global w-100 py-2", type: "submit", disabled: isSubmitting, children: isEditMode ? "Update" : "Submit" }), _jsx("button", { className: "btn-secondary-global w-100 py-2", type: "button", onClick: () => reset(), children: "Clear" })] }) })] }));
|
|
189
|
+
};
|
|
190
|
+
export default ProfileForm;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useNavigate } from "react-router-dom";
|
|
4
|
+
import { fetchUserRoleMappings, useListProfiles } from "../../api/mapping-api";
|
|
5
|
+
import ListHeader from "../common/ListTable/ListHeader";
|
|
6
|
+
import ListTable from "../common/ListTable/ListTable";
|
|
7
|
+
import { profileColumns } from "./profileColumns";
|
|
8
|
+
const ProfileList = () => {
|
|
9
|
+
const { data: profiles = [], isLoading } = useListProfiles();
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
const [roleMap, setRoleMap] = useState({});
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const loadRoles = async () => {
|
|
14
|
+
const mappings = await fetchUserRoleMappings();
|
|
15
|
+
const map = {};
|
|
16
|
+
mappings.forEach((m) => {
|
|
17
|
+
map[m.userId] = m.roleName;
|
|
18
|
+
});
|
|
19
|
+
setRoleMap(map);
|
|
20
|
+
};
|
|
21
|
+
loadRoles();
|
|
22
|
+
}, []);
|
|
23
|
+
const handleEdit = (row) => {
|
|
24
|
+
navigate("/profile-form", {
|
|
25
|
+
state: row,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const handleAdd = () => {
|
|
29
|
+
navigate("/profile-form");
|
|
30
|
+
};
|
|
31
|
+
return (_jsxs("div", { className: "container", children: [_jsx(ListHeader, { title: "Employees List", buttonLabel: "Add Employee", onButtonClick: handleAdd }), _jsx(ListTable, { columns: profileColumns(roleMap), data: profiles, loading: isLoading, emptyMessage: "No employees found", onEdit: handleEdit })] }));
|
|
32
|
+
};
|
|
33
|
+
export default ProfileList;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Badge } from "react-bootstrap";
|
|
3
|
+
import { Status } from "../../domain/type/StatusEnum";
|
|
4
|
+
export const profileColumns = (roleMap) => [
|
|
5
|
+
{
|
|
6
|
+
header: "S.No",
|
|
7
|
+
accessor: (_row, index) => index + 1,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
header: "HMS ID",
|
|
11
|
+
accessor: "sk",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
header: "Name",
|
|
15
|
+
accessor: "name",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
header: "Email",
|
|
19
|
+
accessor: "email",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
header: "Phone",
|
|
23
|
+
accessor: "phoneNumber",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
header: "Address",
|
|
27
|
+
accessor: "address",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
header: "DOB",
|
|
31
|
+
accessor: (row) => row.dob ? new Date(row.dob).toLocaleDateString() : "-",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
header: "Relation",
|
|
35
|
+
accessor: "contactRelation",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
header: "Contact Name",
|
|
39
|
+
accessor: "contactPersonName",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
header: "Contact Phone",
|
|
43
|
+
accessor: "contactPersonNumber",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
header: "Aadhaar No",
|
|
47
|
+
accessor: "aadhaarNumber",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
header: "Admin",
|
|
51
|
+
accessor: (row) => roleMap[row.sk] ?? "NO ROLE",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
header: "Status",
|
|
55
|
+
accessor: (row) => (_jsx(Badge, { bg: row.status === Status.Active ? "success" : "danger", children: row.status })),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
header: "Created Date",
|
|
59
|
+
accessor: (row) => row.createdDt
|
|
60
|
+
? new Date(row.createdDt).toLocaleString()
|
|
61
|
+
: "-",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
header: "Created By",
|
|
65
|
+
accessor: "createdBy",
|
|
66
|
+
},
|
|
67
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Status } from "../../domain/type/StatusEnum";
|
|
3
|
+
export declare const profileSchema: z.ZodObject<{
|
|
4
|
+
pk: z.ZodCatch<z.ZodString>;
|
|
5
|
+
customId: z.ZodString;
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
email: z.ZodString;
|
|
8
|
+
phoneNumber: z.ZodString;
|
|
9
|
+
address: z.ZodString;
|
|
10
|
+
dob: z.ZodString;
|
|
11
|
+
contactRelation: z.ZodString;
|
|
12
|
+
contactPersonName: z.ZodString;
|
|
13
|
+
contactPersonNumber: z.ZodString;
|
|
14
|
+
aadhaarNumber: z.ZodString;
|
|
15
|
+
aadhaarFile: z.ZodOptional<z.ZodAny>;
|
|
16
|
+
status: z.ZodOptional<z.ZodEnum<typeof Status>>;
|
|
17
|
+
isAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ProfileFormInputs = z.infer<typeof profileSchema>;
|
|
20
|
+
export declare const useProfileSchema: () => {
|
|
21
|
+
profileSchema: z.ZodObject<{
|
|
22
|
+
pk: z.ZodCatch<z.ZodString>;
|
|
23
|
+
customId: z.ZodString;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
email: z.ZodString;
|
|
26
|
+
phoneNumber: z.ZodString;
|
|
27
|
+
address: z.ZodString;
|
|
28
|
+
dob: z.ZodString;
|
|
29
|
+
contactRelation: z.ZodString;
|
|
30
|
+
contactPersonName: z.ZodString;
|
|
31
|
+
contactPersonNumber: z.ZodString;
|
|
32
|
+
aadhaarNumber: z.ZodString;
|
|
33
|
+
aadhaarFile: z.ZodOptional<z.ZodAny>;
|
|
34
|
+
status: z.ZodOptional<z.ZodEnum<typeof Status>>;
|
|
35
|
+
isAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
initiateProfile: {
|
|
38
|
+
pk: string;
|
|
39
|
+
customId: string;
|
|
40
|
+
name: string;
|
|
41
|
+
email: string;
|
|
42
|
+
phoneNumber: string;
|
|
43
|
+
address: string;
|
|
44
|
+
dob: string;
|
|
45
|
+
contactRelation: string;
|
|
46
|
+
contactPersonName: string;
|
|
47
|
+
contactPersonNumber: string;
|
|
48
|
+
aadhaarNumber: string;
|
|
49
|
+
aadhaarFile: undefined;
|
|
50
|
+
status: Status;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Status } from "../../domain/type/StatusEnum";
|
|
3
|
+
export const profileSchema = z.object({
|
|
4
|
+
pk: z.string().catch(""), // required output, never undefined
|
|
5
|
+
customId: z.string()
|
|
6
|
+
.min(5, "ID must be at least 5 characters"),
|
|
7
|
+
name: z.string()
|
|
8
|
+
.min(3, "Name must be at least 3 characters")
|
|
9
|
+
.regex(/^[A-Za-z\s]+$/, "Name should contain only letters"),
|
|
10
|
+
email: z.string()
|
|
11
|
+
.email("Invalid email address"),
|
|
12
|
+
phoneNumber: z.string()
|
|
13
|
+
.regex(/^[0-9]{10}$/, "Phone number must be 10 digits"),
|
|
14
|
+
address: z.string()
|
|
15
|
+
.min(5, "Address must be at least 5 characters"),
|
|
16
|
+
dob: z.string()
|
|
17
|
+
.min(1, "Date of Birth is required"),
|
|
18
|
+
contactRelation: z.string()
|
|
19
|
+
.min(1, "Contact person relation is required"),
|
|
20
|
+
contactPersonName: z.string()
|
|
21
|
+
.min(3, "Contact person name must be at least 3 characters")
|
|
22
|
+
.regex(/^[A-Za-z\s]+$/, "Contact person name must contain only letters"),
|
|
23
|
+
contactPersonNumber: z.string()
|
|
24
|
+
.regex(/^[0-9]{10}$/, "Contact person number must be 10 digits"),
|
|
25
|
+
aadhaarNumber: z.string()
|
|
26
|
+
.regex(/^[0-9]{12}$/, "Aadhaar number must be 12 digits"),
|
|
27
|
+
aadhaarFile: z
|
|
28
|
+
.any()
|
|
29
|
+
.optional(), // File input (image/pdf)
|
|
30
|
+
status: z.enum(Status).optional(),
|
|
31
|
+
isAdmin: z.boolean().optional(),
|
|
32
|
+
});
|
|
33
|
+
export const useProfileSchema = () => ({
|
|
34
|
+
profileSchema,
|
|
35
|
+
initiateProfile: {
|
|
36
|
+
pk: "",
|
|
37
|
+
customId: "",
|
|
38
|
+
name: "",
|
|
39
|
+
email: "",
|
|
40
|
+
phoneNumber: "",
|
|
41
|
+
address: "",
|
|
42
|
+
dob: "",
|
|
43
|
+
contactRelation: "",
|
|
44
|
+
contactPersonName: "",
|
|
45
|
+
contactPersonNumber: "",
|
|
46
|
+
aadhaarNumber: "",
|
|
47
|
+
aadhaarFile: undefined,
|
|
48
|
+
status: Status.Active,
|
|
49
|
+
}
|
|
50
|
+
});
|