@syzy/apphost 1.0.15 → 1.0.16
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 +2 -2
- package/dist/App.js +6 -69
- package/dist/api/mapping-api.js +4 -4
- package/dist/components/Home/Home.js +9 -10
- package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.js +12 -7
- package/dist/components/Mappings/MappingForm/MappingForm.js +0 -1
- package/dist/components/api/settings-api.d.ts +1 -1
- package/dist/components/api/settings-api.js +0 -2
- package/dist/config/EnvConfig.d.ts +6 -4
- package/dist/config/EnvConfig.js +6 -4
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/package.json +1 -1
- package/dist/AppHostProvider.d.ts +0 -6
- package/dist/AppHostProvider.js +0 -4
- package/dist/components/NavBar/Sidebar.d.ts +0 -4
- package/dist/components/NavBar/Sidebar.js +0 -56
- package/dist/components/ProfileForm/ProfileForm.d.ts +0 -3
- package/dist/components/ProfileForm/ProfileForm.js +0 -190
- package/dist/components/ProfileForm/ProfileList.d.ts +0 -3
- package/dist/components/ProfileForm/ProfileList.js +0 -33
- package/dist/components/ProfileForm/profileColumns.d.ts +0 -3
- package/dist/components/ProfileForm/profileColumns.js +0 -67
- package/dist/components/ProfileForm/profileSchema.d.ts +0 -52
- package/dist/components/ProfileForm/profileSchema.js +0 -50
- package/dist/components/SettingsPage/SettingsPage.d.ts +0 -3
- package/dist/components/SettingsPage/SettingsPage.js +0 -240
- package/dist/config/amplifyConfig.d.ts +0 -1
- package/dist/config/amplifyConfig.js +0 -45
- package/dist/configureAppHost.d.ts +0 -6
- package/dist/configureAppHost.js +0 -5
- package/dist/hoc/withSyzyAuth.d.ts +0 -2
- package/dist/hoc/withSyzyAuth.js +0 -87
- package/dist/hooks/useCurrentUser.d.ts +0 -3
- package/dist/hooks/useCurrentUser.js +0 -6
- package/dist/hooks/useDispatch.d.ts +0 -3
- package/dist/hooks/useDispatch.js +0 -7
- package/dist/hooks/usePermission.d.ts +0 -1
- package/dist/hooks/usePermission.js +0 -7
- package/dist/services/navigationMenu.d.ts +0 -1
- package/dist/services/navigationMenu.js +0 -9
- package/dist/store/AppAction.d.ts +0 -11
- package/dist/store/AppAction.js +0 -5
- package/dist/store/AppContext.d.ts +0 -3
- package/dist/store/AppContext.js +0 -3
- package/dist/store/AppContextType.d.ts +0 -12
- package/dist/store/AppContextType.js +0 -6
- package/dist/store/AppProvider.d.ts +0 -7
- package/dist/store/AppProvider.js +0 -32
- package/dist/store/HostedInContainerContext.d.ts +0 -5
- package/dist/store/HostedInContainerContext.js +0 -11
- package/dist/store/SesssionReducer.d.ts +0 -4
- package/dist/store/SesssionReducer.js +0 -16
- package/dist/types.d.ts +0 -26
- package/dist/types.js +0 -14
|
@@ -1,190 +0,0 @@
|
|
|
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;
|
|
@@ -1,33 +0,0 @@
|
|
|
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;
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
];
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
});
|