@appcorp/fusion-storybook 0.5.34 → 0.5.37
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/base-modules/admission/context/use-admission-module.d.ts +10 -1
- package/base-modules/admission/context/use-admission-module.js +140 -37
- package/base-modules/admission/context.d.ts +45 -0
- package/base-modules/admission/context.js +9 -0
- package/base-modules/admission/form.js +119 -13
- package/base-modules/admission/validate.d.ts +12 -3
- package/base-modules/admission/validate.js +52 -4
- package/base-modules/admission/view.js +18 -3
- package/base-modules/family-member/context.d.ts +12 -0
- package/base-modules/family-member/context.js +15 -3
- package/base-modules/family-member/form.js +3 -2
- package/base-modules/family-member/validate.d.ts +3 -0
- package/base-modules/family-member/validate.js +35 -2
- package/base-modules/family-member/view.js +12 -3
- package/components/government-id-type-select.d.ts +18 -0
- package/components/government-id-type-select.js +16 -0
- package/package.json +1 -1
- package/pdf-templates/admission-form-template.d.ts +3 -0
- package/pdf-templates/admission-form-template.js +20 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/academics.d.ts +3 -1
- package/types/admission.d.ts +7 -1
- package/types/enums.d.ts +14 -0
- package/types/enums.js +15 -0
- package/utils/government-id.d.ts +51 -0
- package/utils/government-id.js +71 -0
- package/utils/id-number.d.ts +10 -1
- package/utils/id-number.js +12 -1
|
@@ -28,6 +28,7 @@ import { createGenericModule } from "@react-pakistan/util-functions/factory/gene
|
|
|
28
28
|
import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
|
|
29
29
|
import { pageLimit } from "./constants";
|
|
30
30
|
import { normalizeIdNumber } from "../../utils/id-number";
|
|
31
|
+
import { isGovernmentIdType } from "../../utils/government-id";
|
|
31
32
|
import { FAMILY_MEMBER_API_ROUTES } from "../../constants";
|
|
32
33
|
import { familyMemberFormValidation } from "./validate";
|
|
33
34
|
import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
|
|
@@ -80,7 +81,9 @@ const familyMemberConfig = {
|
|
|
80
81
|
gender: "",
|
|
81
82
|
id: "",
|
|
82
83
|
hasStudentProfile: false,
|
|
84
|
+
idType: "",
|
|
83
85
|
idNumber: "",
|
|
86
|
+
idImages: [],
|
|
84
87
|
isPrimary: false,
|
|
85
88
|
lastName: "",
|
|
86
89
|
occupation: "",
|
|
@@ -141,7 +144,9 @@ export const useFamilyMemberModule = () => {
|
|
|
141
144
|
relationship: state.relationship,
|
|
142
145
|
occupation: state.occupation,
|
|
143
146
|
emergencyPhone: toE164Phone(state.emergencyPhone, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country),
|
|
147
|
+
idType: state.idType,
|
|
144
148
|
idNumber: state.idNumber,
|
|
149
|
+
idImages: state.idImages,
|
|
145
150
|
avatar: state.avatar,
|
|
146
151
|
isPrimary: state.isPrimary,
|
|
147
152
|
enabled: state.enabled,
|
|
@@ -159,7 +164,9 @@ export const useFamilyMemberModule = () => {
|
|
|
159
164
|
state.firstName,
|
|
160
165
|
state.gender,
|
|
161
166
|
state.id,
|
|
167
|
+
state.idImages,
|
|
162
168
|
state.idNumber,
|
|
169
|
+
state.idType,
|
|
163
170
|
state.isPrimary,
|
|
164
171
|
state.lastName,
|
|
165
172
|
state.occupation,
|
|
@@ -240,7 +247,7 @@ export const useFamilyMemberModule = () => {
|
|
|
240
247
|
}
|
|
241
248
|
}, [showToast, t, resetFormAndCloseDrawer]);
|
|
242
249
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
243
|
-
var _a, _b, _c, _d;
|
|
250
|
+
var _a, _b, _c, _d, _e, _f;
|
|
244
251
|
if (error) {
|
|
245
252
|
showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
|
|
246
253
|
return;
|
|
@@ -262,10 +269,12 @@ export const useFamilyMemberModule = () => {
|
|
|
262
269
|
gender: member.gender,
|
|
263
270
|
hasStudentProfile: Boolean(member.studentProfile),
|
|
264
271
|
id: member.id,
|
|
272
|
+
idType: (_d = member.idType) !== null && _d !== void 0 ? _d : "",
|
|
265
273
|
idNumber: member.idNumber,
|
|
274
|
+
idImages: (_e = member.idImages) !== null && _e !== void 0 ? _e : [],
|
|
266
275
|
isPrimary: member.isPrimary,
|
|
267
276
|
lastName: member.lastName,
|
|
268
|
-
occupation: (
|
|
277
|
+
occupation: (_f = member.occupation) !== null && _f !== void 0 ? _f : "",
|
|
269
278
|
phone: member.phone || "",
|
|
270
279
|
relationship: member.relationship,
|
|
271
280
|
role: member.role,
|
|
@@ -414,8 +423,11 @@ export const useFamilyMemberModule = () => {
|
|
|
414
423
|
params: updateParams,
|
|
415
424
|
schema: familyMemberFormValidation,
|
|
416
425
|
successCallback: () => {
|
|
426
|
+
const idType = isGovernmentIdType(updateParams.idType)
|
|
427
|
+
? updateParams.idType
|
|
428
|
+
: undefined;
|
|
417
429
|
updateFetchNow(undefined, {
|
|
418
|
-
body: JSON.stringify(Object.assign(Object.assign({}, updateParams), { idNumber: normalizeIdNumber(updateParams.idNumber) })),
|
|
430
|
+
body: JSON.stringify(Object.assign(Object.assign({}, updateParams), { idType: idType !== null && idType !== void 0 ? idType : null, idNumber: normalizeIdNumber(updateParams.idNumber, idType) })),
|
|
419
431
|
});
|
|
420
432
|
},
|
|
421
433
|
errorCallback: (errors) => {
|
|
@@ -11,6 +11,7 @@ import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
|
11
11
|
import { useFamilyMemberModule } from "./context";
|
|
12
12
|
import { useTranslations } from "next-intl";
|
|
13
13
|
import { PhoneInput } from "../../components/phone-input";
|
|
14
|
+
import { GovernmentIdTypeSelect } from "../../components/government-id-type-select";
|
|
14
15
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
15
16
|
import { getTranslatedError } from "../../utils/get-translated-error";
|
|
16
17
|
import { FAMILY_MEMBER_ROLE_OPTIONS, GENDER_OPTIONS } from "./constants";
|
|
@@ -18,7 +19,7 @@ import { toDateInput } from "./date";
|
|
|
18
19
|
export const FamilyMemberForm = () => {
|
|
19
20
|
var _a, _b;
|
|
20
21
|
const { handleChange, state } = useFamilyMemberModule();
|
|
21
|
-
const { bloodGroup, dateOfBirth, email, emergencyPhone, enabled, errors, firstName, gender, hasStudentProfile, idNumber, isPrimary, lastName, occupation, phone, relationship, role, } = state;
|
|
22
|
+
const { bloodGroup, dateOfBirth, email, emergencyPhone, enabled, errors, firstName, gender, hasStudentProfile, idType, idNumber, isPrimary, lastName, occupation, phone, relationship, role, } = state;
|
|
22
23
|
const t = useTranslations("familyMember");
|
|
23
24
|
const workspace = getCachedWorkspaceSync();
|
|
24
25
|
const roleLabelMap = {
|
|
@@ -41,5 +42,5 @@ export const FamilyMemberForm = () => {
|
|
|
41
42
|
})), placeholder: t("formRolePlaceholder"), required: true, searchPlaceholder: t("formRolePlaceholder"), value: role }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dateOfBirth", t }), id: "dateOfBirth", info: t("formDateOfBirthInfo"), label: t("formDateOfBirthLabel"), onChange: (e) => handleChange("dateOfBirth", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: "YYYY-MM-DD", type: "date", value: toDateInput(dateOfBirth) })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedCombobox, { emptyText: t("formNoGenderEmpty"), error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onValueChange: (value) => handleChange("gender", value), options: GENDER_OPTIONS.map((opt) => ({
|
|
42
43
|
value: opt.value,
|
|
43
44
|
label: genderLabelMap[opt.value] || opt.label,
|
|
44
|
-
})), placeholder: t("formGenderPlaceholder"), searchPlaceholder: t("formGenderPlaceholder"), value: gender }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "bloodGroup", t }), id: "bloodGroup", info: t("formBloodGroupInfo"), label: t("formBloodGroupLabel"), onChange: (e) => handleChange("bloodGroup", e.target.value), placeholder: t("formBloodGroupPlaceholder"), value: bloodGroup })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "idNumber", t }), id: "idNumber", info: t("formIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("idNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), value: idNumber })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionContactInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(PhoneInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (value) => handleChange("phone", value), placeholder: t("formPhonePlaceholder"), value: phone || "", defaultCountry: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country) || "PK" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "email", t }), id: "email", info: t("formEmailInfo"), label: t("formEmailLabel"), onChange: (e) => handleChange("email", e.target.value), placeholder: t("formEmailPlaceholder"), type: "email", value: email })] }), _jsx(PhoneInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (value) => handleChange("emergencyPhone", value), placeholder: t("formEmergencyPhonePlaceholder"), value: emergencyPhone || "", defaultCountry: ((_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country) || "PK" })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionAdditionalInformation") }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "relationship", t }), id: "relationship", info: t("formRelationshipInfo"), label: t("formRelationshipLabel"), onChange: (e) => handleChange("relationship", e.target.value), placeholder: t("formRelationshipPlaceholder"), value: relationship }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "occupation", t }), id: "occupation", info: t("formOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("occupation", e.target.value), placeholder: t("formOccupationPlaceholder"), value: occupation })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionStatus") }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(EnhancedCheckbox, { checked: isPrimary, id: "isPrimary", label: t("formPrimaryContactLabel"), onCheckedChange: (checked) => handleChange("isPrimary", checked === true) }), _jsx(EnhancedCheckbox, { checked: enabled, id: "enabled", label: t("badgeActive"), onCheckedChange: (checked) => handleChange("enabled", checked === true) })] })] })] }));
|
|
45
|
+
})), placeholder: t("formGenderPlaceholder"), searchPlaceholder: t("formGenderPlaceholder"), value: gender }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "bloodGroup", t }), id: "bloodGroup", info: t("formBloodGroupInfo"), label: t("formBloodGroupLabel"), onChange: (e) => handleChange("bloodGroup", e.target.value), placeholder: t("formBloodGroupPlaceholder"), value: bloodGroup })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(GovernmentIdTypeSelect, { error: getTranslatedError({ errors, key: "idType", t }), id: "idType", onChange: (value) => handleChange("idType", value), required: Boolean(idNumber), value: idType }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "idNumber", t }), id: "idNumber", info: t("formIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("idNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), value: idNumber })] })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionContactInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(PhoneInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (value) => handleChange("phone", value), placeholder: t("formPhonePlaceholder"), value: phone || "", defaultCountry: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country) || "PK" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "email", t }), id: "email", info: t("formEmailInfo"), label: t("formEmailLabel"), onChange: (e) => handleChange("email", e.target.value), placeholder: t("formEmailPlaceholder"), type: "email", value: email })] }), _jsx(PhoneInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (value) => handleChange("emergencyPhone", value), placeholder: t("formEmergencyPhonePlaceholder"), value: emergencyPhone || "", defaultCountry: ((_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country) || "PK" })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionAdditionalInformation") }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "relationship", t }), id: "relationship", info: t("formRelationshipInfo"), label: t("formRelationshipLabel"), onChange: (e) => handleChange("relationship", e.target.value), placeholder: t("formRelationshipPlaceholder"), value: relationship }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "occupation", t }), id: "occupation", info: t("formOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("occupation", e.target.value), placeholder: t("formOccupationPlaceholder"), value: occupation })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionStatus") }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(EnhancedCheckbox, { checked: isPrimary, id: "isPrimary", label: t("formPrimaryContactLabel"), onCheckedChange: (checked) => handleChange("isPrimary", checked === true) }), _jsx(EnhancedCheckbox, { checked: enabled, id: "enabled", label: t("badgeActive"), onCheckedChange: (checked) => handleChange("enabled", checked === true) })] })] })] }));
|
|
45
46
|
};
|
|
@@ -12,6 +12,8 @@ export declare const VALIDATION_KEYS: {
|
|
|
12
12
|
readonly emailInvalid: "validationFamilyMemberEmailInvalid";
|
|
13
13
|
readonly idForUpdate: "validationFamilyMemberIdForUpdateRequired";
|
|
14
14
|
readonly phoneInvalid: "validationFamilyMemberPhoneInvalid";
|
|
15
|
+
readonly idTypeRequired: "validationFamilyMemberIdTypeRequired";
|
|
16
|
+
readonly idNumberInvalid: "validationFamilyMemberIdNumberInvalid";
|
|
15
17
|
};
|
|
16
18
|
export declare const familyMemberFormValidation: z.ZodObject<{
|
|
17
19
|
familyId: z.ZodString;
|
|
@@ -26,6 +28,7 @@ export declare const familyMemberFormValidation: z.ZodObject<{
|
|
|
26
28
|
relationship: z.ZodOptional<z.ZodString>;
|
|
27
29
|
occupation: z.ZodOptional<z.ZodString>;
|
|
28
30
|
emergencyPhone: z.ZodPreprocess<z.ZodPipe<z.ZodNullable<z.ZodOptional<z.ZodString>>, z.ZodTransform<string | null | undefined, string | null | undefined>>, unknown>;
|
|
31
|
+
idType: z.ZodOptional<z.ZodString>;
|
|
29
32
|
idNumber: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | null | undefined, string | undefined>>;
|
|
30
33
|
avatar: z.ZodOptional<z.ZodString>;
|
|
31
34
|
isPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { normalizeIdNumber } from "../../utils/id-number";
|
|
8
|
+
import { isGovernmentIdType, isValidIdNumberForType, } from "../../utils/government-id";
|
|
8
9
|
import { phoneSchema } from "../../utils/phone-validation";
|
|
9
10
|
// ============================================================================
|
|
10
11
|
// VALIDATION KEYS (used as Zod error messages, translated via getTranslatedError)
|
|
@@ -17,11 +18,14 @@ export const VALIDATION_KEYS = {
|
|
|
17
18
|
emailInvalid: "validationFamilyMemberEmailInvalid",
|
|
18
19
|
idForUpdate: "validationFamilyMemberIdForUpdateRequired",
|
|
19
20
|
phoneInvalid: "validationFamilyMemberPhoneInvalid",
|
|
21
|
+
idTypeRequired: "validationFamilyMemberIdTypeRequired",
|
|
22
|
+
idNumberInvalid: "validationFamilyMemberIdNumberInvalid",
|
|
20
23
|
};
|
|
21
24
|
// ============================================================================
|
|
22
25
|
// VALIDATION SCHEMA
|
|
23
26
|
// ============================================================================
|
|
24
|
-
export const familyMemberFormValidation = z
|
|
27
|
+
export const familyMemberFormValidation = z
|
|
28
|
+
.object({
|
|
25
29
|
familyId: z.string().min(1, VALIDATION_KEYS.familyId),
|
|
26
30
|
firstName: z.string().min(1, VALIDATION_KEYS.firstName),
|
|
27
31
|
lastName: z.string().min(1, VALIDATION_KEYS.lastName),
|
|
@@ -38,8 +42,37 @@ export const familyMemberFormValidation = z.object({
|
|
|
38
42
|
relationship: z.string().optional(),
|
|
39
43
|
occupation: z.string().optional(),
|
|
40
44
|
emergencyPhone: phoneSchema(VALIDATION_KEYS.phoneInvalid),
|
|
41
|
-
|
|
45
|
+
idType: z
|
|
46
|
+
.string()
|
|
47
|
+
.optional()
|
|
48
|
+
.refine((value) => !value || isGovernmentIdType(value), VALIDATION_KEYS.idTypeRequired),
|
|
49
|
+
idNumber: z
|
|
50
|
+
.string()
|
|
51
|
+
.optional()
|
|
52
|
+
.transform((val) => (val ? normalizeIdNumber(val) : val)),
|
|
42
53
|
avatar: z.string().optional(),
|
|
43
54
|
isPrimary: z.boolean().optional(),
|
|
44
55
|
enabled: z.boolean().optional(),
|
|
56
|
+
})
|
|
57
|
+
.superRefine((data, ctx) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const hasIdNumber = Boolean((_a = data.idNumber) === null || _a === void 0 ? void 0 : _a.trim());
|
|
60
|
+
if (hasIdNumber && !data.idType) {
|
|
61
|
+
ctx.addIssue({
|
|
62
|
+
code: z.ZodIssueCode.custom,
|
|
63
|
+
path: ["idType"],
|
|
64
|
+
message: VALIDATION_KEYS.idTypeRequired,
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (hasIdNumber &&
|
|
69
|
+
data.idType &&
|
|
70
|
+
isGovernmentIdType(data.idType) &&
|
|
71
|
+
!isValidIdNumberForType((_b = data.idNumber) !== null && _b !== void 0 ? _b : "", data.idType)) {
|
|
72
|
+
ctx.addIssue({
|
|
73
|
+
code: z.ZodIssueCode.custom,
|
|
74
|
+
path: ["idNumber"],
|
|
75
|
+
message: VALIDATION_KEYS.idNumberInvalid,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
45
78
|
});
|
|
@@ -10,15 +10,21 @@ import { Badge } from "@appcorp/shadcn/components/ui/badge";
|
|
|
10
10
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@appcorp/shadcn/components/ui/card";
|
|
11
11
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
12
12
|
import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
|
|
13
|
-
import { Briefcase, Calendar, CheckCircle2, Heart, Mail, Phone, ShieldCheck, User, Users, XCircle, } from "lucide-react";
|
|
13
|
+
import { Briefcase, Calendar, CheckCircle2, ExternalLink, Heart, Mail, Phone, ShieldCheck, User, Users, XCircle, } from "lucide-react";
|
|
14
14
|
import { useFamilyMemberModule } from "./context";
|
|
15
15
|
import { useTranslations } from "next-intl";
|
|
16
16
|
import { formatValue } from "@react-pakistan/util-functions/general/format-value";
|
|
17
17
|
import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
|
|
18
|
+
import { governmentIdTypeLabelKey } from "../../utils/government-id";
|
|
18
19
|
export const FamilyMemberView = () => {
|
|
19
20
|
const { state } = useFamilyMemberModule();
|
|
20
|
-
const { avatar, bloodGroup, dateOfBirth, email, emergencyPhone, enabled, firstName, gender, idNumber, isPrimary, lastName, occupation, phone, relationship, role, } = state;
|
|
21
|
+
const { avatar, bloodGroup, dateOfBirth, email, emergencyPhone, enabled, firstName, gender, idType, idNumber, idImages, isPrimary, lastName, occupation, phone, relationship, role, } = state;
|
|
21
22
|
const t = useTranslations("familyMember");
|
|
23
|
+
const governmentIdT = useTranslations("governmentId");
|
|
24
|
+
const formatIdType = (value) => {
|
|
25
|
+
const key = governmentIdTypeLabelKey(value);
|
|
26
|
+
return key ? governmentIdT(key) : "—";
|
|
27
|
+
};
|
|
22
28
|
const fullName = [firstName, lastName].filter(Boolean).join(" ") ||
|
|
23
29
|
t("viewFieldFamilyMember");
|
|
24
30
|
const initials = `${(firstName === null || firstName === void 0 ? void 0 : firstName[0]) || ""}${(lastName === null || lastName === void 0 ? void 0 : lastName[0]) || ""}`
|
|
@@ -34,7 +40,10 @@ export const FamilyMemberView = () => {
|
|
|
34
40
|
return "—";
|
|
35
41
|
return formatDate(new Date(value).toISOString(), DATE_FORMATS.LOCALE_DATE);
|
|
36
42
|
};
|
|
37
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "flex items-center gap-6", children: [_jsxs(Avatar, { className: "h-24 w-24", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: fullName }), _jsx(AvatarFallback, { className: "text-2xl", children: initials || "FM" })] }), _jsxs("div", { className: "flex-1", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("h2", { className: "text-2xl font-bold", children: fullName }), enabled ? (_jsxs(Badge, { variant: "default", className: "gap-1", children: [_jsx(CheckCircle2, { className: "h-3 w-3" }), t("badgeActive")] })) : (_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(XCircle, { className: "h-3 w-3" }), t("badgeInactive")] })), isPrimary && (_jsxs(Badge, { variant: "outline", className: "gap-1", children: [_jsx(ShieldCheck, { className: "h-3 w-3" }), t("formPrimaryContactLabel")] }))] }), _jsx("p", { className: "text-muted-foreground mt-1 text-sm", children: t("viewFieldFamilyMemberProfile") }), _jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-2", children: [role ? (_jsx(Badge, { variant: "secondary", className: "capitalize", children: formatEnumValue(role) })) : null, relationship ? (_jsx(Badge, { variant: "outline", className: "capitalize", children: formatEnumValue(relationship) })) : null, gender ? (_jsx(Badge, { variant: "outline", className: "capitalize", children: formatEnumValue(gender) })) : null] })] })] }) }) }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(User, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("formSectionPersonalInformation") })] }), _jsx(CardDescription, { children: t("viewSectionBasicIdentityAndProfileDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formFirstNameLabel") }), _jsx("p", { className: "text-base", children: formatValue(firstName) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formLastNameLabel") }), _jsx("p", { className: "text-base", children: formatValue(lastName) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formRoleLabel") }), role ? (_jsx(Badge, { variant: "secondary", className: "capitalize", children: formatEnumValue(role) })) : (_jsx("p", { className: "text-base", children: "\u2014" }))] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formDateOfBirthLabel") })] }), _jsx("p", { className: "text-base", children: formatDateValue(dateOfBirth) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formGenderLabel") }), gender ? (_jsx(Badge, { variant: "outline", className: "capitalize", children: formatEnumValue(gender) })) : (_jsx("p", { className: "text-base", children: "\u2014" }))] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Heart, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formBloodGroupLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(bloodGroup) })] }), _jsxs("div", { className: "space-y-1
|
|
43
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "flex items-center gap-6", children: [_jsxs(Avatar, { className: "h-24 w-24", children: [_jsx(AvatarImage, { src: avatar || undefined, alt: fullName }), _jsx(AvatarFallback, { className: "text-2xl", children: initials || "FM" })] }), _jsxs("div", { className: "flex-1", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("h2", { className: "text-2xl font-bold", children: fullName }), enabled ? (_jsxs(Badge, { variant: "default", className: "gap-1", children: [_jsx(CheckCircle2, { className: "h-3 w-3" }), t("badgeActive")] })) : (_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(XCircle, { className: "h-3 w-3" }), t("badgeInactive")] })), isPrimary && (_jsxs(Badge, { variant: "outline", className: "gap-1", children: [_jsx(ShieldCheck, { className: "h-3 w-3" }), t("formPrimaryContactLabel")] }))] }), _jsx("p", { className: "text-muted-foreground mt-1 text-sm", children: t("viewFieldFamilyMemberProfile") }), _jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-2", children: [role ? (_jsx(Badge, { variant: "secondary", className: "capitalize", children: formatEnumValue(role) })) : null, relationship ? (_jsx(Badge, { variant: "outline", className: "capitalize", children: formatEnumValue(relationship) })) : null, gender ? (_jsx(Badge, { variant: "outline", className: "capitalize", children: formatEnumValue(gender) })) : null] })] })] }) }) }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(User, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("formSectionPersonalInformation") })] }), _jsx(CardDescription, { children: t("viewSectionBasicIdentityAndProfileDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formFirstNameLabel") }), _jsx("p", { className: "text-base", children: formatValue(firstName) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formLastNameLabel") }), _jsx("p", { className: "text-base", children: formatValue(lastName) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formRoleLabel") }), role ? (_jsx(Badge, { variant: "secondary", className: "capitalize", children: formatEnumValue(role) })) : (_jsx("p", { className: "text-base", children: "\u2014" }))] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formDateOfBirthLabel") })] }), _jsx("p", { className: "text-base", children: formatDateValue(dateOfBirth) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formGenderLabel") }), gender ? (_jsx(Badge, { variant: "outline", className: "capitalize", children: formatEnumValue(gender) })) : (_jsx("p", { className: "text-base", children: "\u2014" }))] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Heart, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formBloodGroupLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(bloodGroup) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: governmentIdT("typeLabel") }), _jsx("p", { className: "text-base", children: formatIdType(idType) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formIdNumberLabel") }), _jsx("p", { className: "text-base", children: formatValue(idNumber) })] }), _jsxs("div", { className: "space-y-2 md:col-span-2", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: governmentIdT("imagesLabel") }), idImages && idImages.length > 0 ? (_jsx("div", { className: "space-y-2", children: idImages.map((url, idx) => {
|
|
44
|
+
const fileName = url.split("/").pop() || url;
|
|
45
|
+
return (_jsxs("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "bg-muted/50 flex items-center gap-2 rounded-lg border p-3 text-sm hover:underline", children: [_jsx("span", { className: "flex-1 truncate", children: fileName }), _jsx(ExternalLink, { className: "text-muted-foreground h-3.5 w-3.5 shrink-0" })] }, `${url}-${idx}`));
|
|
46
|
+
}) })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: governmentIdT("imagesEmpty") }))] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("formSectionContactInformation") })] }), _jsx(CardDescription, { children: t("viewSectionReachabilityAndEmergencyContactDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formPhoneLabel") })] }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(phone) || formatValue(phone) })] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Mail, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formEmailLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(email) })] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Phone, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formEmergencyPhoneLabel") })] }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(emergencyPhone) ||
|
|
38
47
|
formatValue(emergencyPhone) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldFamilyRole") })] }), _jsx(CardDescription, { children: t("viewFieldRelationshipAndHouseholdResponsibilities") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formRelationshipLabel") }), relationship ? (_jsx(Badge, { variant: "secondary", className: "capitalize", children: formatEnumValue(relationship) })) : (_jsx("p", { className: "text-base", children: "\u2014" }))] }), _jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Briefcase, { className: "text-muted-foreground h-4 w-4" }), _jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formOccupationLabel") })] }), _jsx("p", { className: "text-base", children: formatValue(occupation) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(ShieldCheck, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldStatus") })] }), _jsx(CardDescription, { children: t("viewFieldPrimaryContactAndAccountActivity") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsx(ShieldCheck, { className: "text-primary mt-0.5 h-5 w-5" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: isPrimary
|
|
39
48
|
? t("formPrimaryContactLabel")
|
|
40
49
|
: t("viewFieldSecondaryContact") }), _jsx("p", { className: "text-muted-foreground text-sm", children: isPrimary
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type GovernmentIdType } from "../utils/government-id";
|
|
2
|
+
export interface GovernmentIdTypeSelectProps {
|
|
3
|
+
id: string;
|
|
4
|
+
value?: string | null;
|
|
5
|
+
onChange: (value: GovernmentIdType | "") => void;
|
|
6
|
+
error?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
info?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Shared picker for the global list of government-issued ID types.
|
|
16
|
+
* Labels come from the `governmentId` translation namespace.
|
|
17
|
+
*/
|
|
18
|
+
export declare function GovernmentIdTypeSelect({ id, value, onChange, error, required, disabled, label, info, placeholder, className, }: GovernmentIdTypeSelectProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
5
|
+
import { GOVERNMENT_ID_TYPES, } from "../utils/government-id";
|
|
6
|
+
/**
|
|
7
|
+
* Shared picker for the global list of government-issued ID types.
|
|
8
|
+
* Labels come from the `governmentId` translation namespace.
|
|
9
|
+
*/
|
|
10
|
+
export function GovernmentIdTypeSelect({ id, value, onChange, error, required = false, disabled = false, label, info, placeholder, className, }) {
|
|
11
|
+
const t = useTranslations("governmentId");
|
|
12
|
+
return (_jsx(EnhancedCombobox, { className: className, disabled: disabled, emptyText: t("typeEmptyText"), error: error, id: id, info: info !== null && info !== void 0 ? info : t("typeInfo"), label: label !== null && label !== void 0 ? label : t("typeLabel"), onValueChange: (next) => onChange(next), options: GOVERNMENT_ID_TYPES.map((type) => ({
|
|
13
|
+
value: type.value,
|
|
14
|
+
label: t(type.labelKey),
|
|
15
|
+
})), placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("typePlaceholder"), required: required, searchPlaceholder: t("typeSearchPlaceholder"), value: value !== null && value !== void 0 ? value : "" }));
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface AdmissionPDFData {
|
|
2
2
|
firstName: string;
|
|
3
3
|
lastName: string;
|
|
4
|
+
studentIdType?: string;
|
|
4
5
|
studentIdNumber: string;
|
|
5
6
|
gender: string;
|
|
6
7
|
dob: string;
|
|
@@ -8,12 +9,14 @@ export interface AdmissionPDFData {
|
|
|
8
9
|
discountCode?: string;
|
|
9
10
|
fatherFirstName: string;
|
|
10
11
|
fatherLastName: string;
|
|
12
|
+
fatherIdType?: string;
|
|
11
13
|
fatherIdNumber: string;
|
|
12
14
|
fatherMobile: string;
|
|
13
15
|
fatherOccupation?: string;
|
|
14
16
|
fatherOrganization?: string;
|
|
15
17
|
motherFirstName: string;
|
|
16
18
|
motherLastName: string;
|
|
19
|
+
motherIdType?: string;
|
|
17
20
|
motherIdNumber: string;
|
|
18
21
|
motherMobile: string;
|
|
19
22
|
address: string;
|
|
@@ -19,6 +19,23 @@ function section(title, content) {
|
|
|
19
19
|
<div class="section-body">${content}</div>
|
|
20
20
|
</div>`;
|
|
21
21
|
}
|
|
22
|
+
const ID_TYPE_LABELS = {
|
|
23
|
+
NATIONAL_ID: "National ID / CNIC",
|
|
24
|
+
PASSPORT: "Passport",
|
|
25
|
+
DRIVING_LICENCE: "Driving Licence",
|
|
26
|
+
BIRTH_CERTIFICATE: "Birth Certificate / B-Form",
|
|
27
|
+
VOTER_ID: "Voter ID",
|
|
28
|
+
RESIDENCE_PERMIT: "Residence Permit",
|
|
29
|
+
REFUGEE_ID: "Refugee / Asylum ID",
|
|
30
|
+
MILITARY_ID: "Military ID",
|
|
31
|
+
OTHER: "Other",
|
|
32
|
+
};
|
|
33
|
+
function idTypeLabel(value) {
|
|
34
|
+
var _a;
|
|
35
|
+
if (!value)
|
|
36
|
+
return "";
|
|
37
|
+
return (_a = ID_TYPE_LABELS[value]) !== null && _a !== void 0 ? _a : value;
|
|
38
|
+
}
|
|
22
39
|
function row(label, value) {
|
|
23
40
|
return `
|
|
24
41
|
<div class="field-row">
|
|
@@ -244,6 +261,7 @@ export function buildAdmissionFormHtml(data) {
|
|
|
244
261
|
<div class="two-col">
|
|
245
262
|
${row("Student Name", studentName)}
|
|
246
263
|
${row("Class for Admission", fmt(data.classForAdmission))}
|
|
264
|
+
${row("Government ID Type", idTypeLabel(data.studentIdType))}
|
|
247
265
|
${row("Government ID", fmt(data.studentIdNumber))}
|
|
248
266
|
<div class="field-row">
|
|
249
267
|
<span class="field-label">Gender:</span>
|
|
@@ -261,6 +279,7 @@ export function buildAdmissionFormHtml(data) {
|
|
|
261
279
|
<h4>Father</h4>
|
|
262
280
|
<div class="two-col">
|
|
263
281
|
${row("Name", fatherName)}
|
|
282
|
+
${row("ID Type", idTypeLabel(data.fatherIdType))}
|
|
264
283
|
${row("ID / CNIC", fmt(data.fatherIdNumber))}
|
|
265
284
|
${row("Occupation", fmt(data.fatherOccupation))}
|
|
266
285
|
${row("Organization", fmt(data.fatherOrganization))}
|
|
@@ -271,6 +290,7 @@ export function buildAdmissionFormHtml(data) {
|
|
|
271
290
|
<h4>Mother</h4>
|
|
272
291
|
<div class="two-col">
|
|
273
292
|
${row("Name", motherName)}
|
|
293
|
+
${row("ID Type", idTypeLabel(data.motherIdType))}
|
|
274
294
|
${row("ID / CNIC", fmt(data.motherIdNumber))}
|
|
275
295
|
${row("Mobile", fmt(data.motherMobile))}
|
|
276
296
|
</div>
|