@appcorp/fusion-storybook 0.5.34 → 0.5.36
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 +45 -2
- 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
package/types/academics.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* teacher, enrollment, attendance, grade, schedule, student profile, family,
|
|
6
6
|
* and family member domain models.
|
|
7
7
|
*/
|
|
8
|
-
import { GENDER, FAMILY_MEMBER_ROLE, STUDENT_STATUS, ATTENDANCE_STATUS, GRADE_TYPE, DAY_OF_WEEK } from "./enums";
|
|
8
|
+
import { GENDER, FAMILY_MEMBER_ROLE, GOVERNMENT_ID_TYPE, STUDENT_STATUS, ATTENDANCE_STATUS, GRADE_TYPE, DAY_OF_WEEK } from "./enums";
|
|
9
9
|
import type { FamilyPushTokenBE, MobileNotificationBE, NotificationPreferenceBE } from "./communication";
|
|
10
10
|
import type { SchoolBE, CampusBE, UserBE } from "./user-management";
|
|
11
11
|
import type { FeeStructureBE, StudentFeeBE } from "./finance";
|
|
@@ -49,6 +49,8 @@ export interface FamilyMemberBE {
|
|
|
49
49
|
gender: GENDER;
|
|
50
50
|
id: string;
|
|
51
51
|
idNumber: string;
|
|
52
|
+
idType: GOVERNMENT_ID_TYPE | null;
|
|
53
|
+
idImages: string[];
|
|
52
54
|
isPrimary: boolean;
|
|
53
55
|
lastName: string;
|
|
54
56
|
occupation: string | null;
|
package/types/admission.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This file contains TypeScript interfaces for the admission domain models.
|
|
5
5
|
*/
|
|
6
|
-
import { GENDER, ADMISSION_STATUS } from "./enums";
|
|
6
|
+
import { GENDER, ADMISSION_STATUS, GOVERNMENT_ID_TYPE } from "./enums";
|
|
7
7
|
import type { SchoolBE } from "./user-management";
|
|
8
8
|
export interface AdmissionDetails {
|
|
9
9
|
classForAdmission: string;
|
|
@@ -13,6 +13,8 @@ export interface AdmissionDetails {
|
|
|
13
13
|
}
|
|
14
14
|
export interface FatherDetails {
|
|
15
15
|
fatherIdNumber: string;
|
|
16
|
+
fatherIdType?: GOVERNMENT_ID_TYPE | null;
|
|
17
|
+
fatherIdImages?: string[];
|
|
16
18
|
fatherFirstName: string;
|
|
17
19
|
fatherLastName: string;
|
|
18
20
|
fatherMobile: string;
|
|
@@ -22,6 +24,8 @@ export interface FatherDetails {
|
|
|
22
24
|
}
|
|
23
25
|
export interface MotherDetails {
|
|
24
26
|
motherIdNumber: string;
|
|
27
|
+
motherIdType?: GOVERNMENT_ID_TYPE | null;
|
|
28
|
+
motherIdImages?: string[];
|
|
25
29
|
motherFirstName: string;
|
|
26
30
|
motherLastName: string;
|
|
27
31
|
motherMobile: string;
|
|
@@ -36,6 +40,8 @@ export interface HomeDetails {
|
|
|
36
40
|
}
|
|
37
41
|
export interface StudentDetails {
|
|
38
42
|
studentIdNumber: string;
|
|
43
|
+
studentIdType?: GOVERNMENT_ID_TYPE | null;
|
|
44
|
+
studentIdImages?: string[];
|
|
39
45
|
discountCodeId: string;
|
|
40
46
|
dob: string;
|
|
41
47
|
emergencyContact: string;
|
package/types/enums.d.ts
CHANGED
|
@@ -43,6 +43,20 @@ export declare enum GENDER {
|
|
|
43
43
|
OTHER = "OTHER",
|
|
44
44
|
PREFER_NOT_TO_SAY = "PREFER_NOT_TO_SAY"
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Government-issued identity document types
|
|
48
|
+
*/
|
|
49
|
+
export declare enum GOVERNMENT_ID_TYPE {
|
|
50
|
+
NATIONAL_ID = "NATIONAL_ID",
|
|
51
|
+
PASSPORT = "PASSPORT",
|
|
52
|
+
DRIVING_LICENCE = "DRIVING_LICENCE",
|
|
53
|
+
BIRTH_CERTIFICATE = "BIRTH_CERTIFICATE",
|
|
54
|
+
VOTER_ID = "VOTER_ID",
|
|
55
|
+
RESIDENCE_PERMIT = "RESIDENCE_PERMIT",
|
|
56
|
+
REFUGEE_ID = "REFUGEE_ID",
|
|
57
|
+
MILITARY_ID = "MILITARY_ID",
|
|
58
|
+
OTHER = "OTHER"
|
|
59
|
+
}
|
|
46
60
|
/**
|
|
47
61
|
* Day of the week for scheduling
|
|
48
62
|
*/
|
package/types/enums.js
CHANGED
|
@@ -50,6 +50,21 @@ export var GENDER;
|
|
|
50
50
|
GENDER["OTHER"] = "OTHER";
|
|
51
51
|
GENDER["PREFER_NOT_TO_SAY"] = "PREFER_NOT_TO_SAY";
|
|
52
52
|
})(GENDER || (GENDER = {}));
|
|
53
|
+
/**
|
|
54
|
+
* Government-issued identity document types
|
|
55
|
+
*/
|
|
56
|
+
export var GOVERNMENT_ID_TYPE;
|
|
57
|
+
(function (GOVERNMENT_ID_TYPE) {
|
|
58
|
+
GOVERNMENT_ID_TYPE["NATIONAL_ID"] = "NATIONAL_ID";
|
|
59
|
+
GOVERNMENT_ID_TYPE["PASSPORT"] = "PASSPORT";
|
|
60
|
+
GOVERNMENT_ID_TYPE["DRIVING_LICENCE"] = "DRIVING_LICENCE";
|
|
61
|
+
GOVERNMENT_ID_TYPE["BIRTH_CERTIFICATE"] = "BIRTH_CERTIFICATE";
|
|
62
|
+
GOVERNMENT_ID_TYPE["VOTER_ID"] = "VOTER_ID";
|
|
63
|
+
GOVERNMENT_ID_TYPE["RESIDENCE_PERMIT"] = "RESIDENCE_PERMIT";
|
|
64
|
+
GOVERNMENT_ID_TYPE["REFUGEE_ID"] = "REFUGEE_ID";
|
|
65
|
+
GOVERNMENT_ID_TYPE["MILITARY_ID"] = "MILITARY_ID";
|
|
66
|
+
GOVERNMENT_ID_TYPE["OTHER"] = "OTHER";
|
|
67
|
+
})(GOVERNMENT_ID_TYPE || (GOVERNMENT_ID_TYPE = {}));
|
|
53
68
|
/**
|
|
54
69
|
* Day of the week for scheduling
|
|
55
70
|
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical, country-agnostic list of government-issued identity documents.
|
|
3
|
+
*
|
|
4
|
+
* Keep this in sync with:
|
|
5
|
+
* - `fusion-api/src/utils/government-id-types.ts`
|
|
6
|
+
* - `fusion-api/prisma/schema.prisma` (`GovernmentIdType` enum)
|
|
7
|
+
*/
|
|
8
|
+
export declare const GOVERNMENT_ID_TYPES: readonly [{
|
|
9
|
+
readonly value: "NATIONAL_ID";
|
|
10
|
+
readonly labelKey: "typeNationalId";
|
|
11
|
+
}, {
|
|
12
|
+
readonly value: "PASSPORT";
|
|
13
|
+
readonly labelKey: "typePassport";
|
|
14
|
+
}, {
|
|
15
|
+
readonly value: "DRIVING_LICENCE";
|
|
16
|
+
readonly labelKey: "typeDrivingLicence";
|
|
17
|
+
}, {
|
|
18
|
+
readonly value: "BIRTH_CERTIFICATE";
|
|
19
|
+
readonly labelKey: "typeBirthCertificate";
|
|
20
|
+
}, {
|
|
21
|
+
readonly value: "VOTER_ID";
|
|
22
|
+
readonly labelKey: "typeVoterId";
|
|
23
|
+
}, {
|
|
24
|
+
readonly value: "RESIDENCE_PERMIT";
|
|
25
|
+
readonly labelKey: "typeResidencePermit";
|
|
26
|
+
}, {
|
|
27
|
+
readonly value: "REFUGEE_ID";
|
|
28
|
+
readonly labelKey: "typeRefugeeId";
|
|
29
|
+
}, {
|
|
30
|
+
readonly value: "MILITARY_ID";
|
|
31
|
+
readonly labelKey: "typeMilitaryId";
|
|
32
|
+
}, {
|
|
33
|
+
readonly value: "OTHER";
|
|
34
|
+
readonly labelKey: "typeOther";
|
|
35
|
+
}];
|
|
36
|
+
export type GovernmentIdType = (typeof GOVERNMENT_ID_TYPES)[number]["value"];
|
|
37
|
+
export declare const GOVERNMENT_ID_TYPE_VALUES: GovernmentIdType[];
|
|
38
|
+
export declare function isGovernmentIdType(value: unknown): value is GovernmentIdType;
|
|
39
|
+
export declare function governmentIdTypeLabelKey(idType: string | null | undefined): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Normalize an ID number for storage. National IDs keep the existing CNIC
|
|
42
|
+
* behaviour (13 digits are stored without separators); most other document
|
|
43
|
+
* numbers are trimmed and upper-cased. `OTHER` is only trimmed.
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeIdNumberForType(value: string, idType?: GovernmentIdType | null): string;
|
|
46
|
+
/**
|
|
47
|
+
* Lenient, global validation. Country-specific document numbers vary widely,
|
|
48
|
+
* so this only rejects empty values, unsupported characters and obviously
|
|
49
|
+
* wrong lengths.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isValidIdNumberForType(value: string, idType: GovernmentIdType): boolean;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical, country-agnostic list of government-issued identity documents.
|
|
3
|
+
*
|
|
4
|
+
* Keep this in sync with:
|
|
5
|
+
* - `fusion-api/src/utils/government-id-types.ts`
|
|
6
|
+
* - `fusion-api/prisma/schema.prisma` (`GovernmentIdType` enum)
|
|
7
|
+
*/
|
|
8
|
+
export const GOVERNMENT_ID_TYPES = [
|
|
9
|
+
{ value: "NATIONAL_ID", labelKey: "typeNationalId" },
|
|
10
|
+
{ value: "PASSPORT", labelKey: "typePassport" },
|
|
11
|
+
{ value: "DRIVING_LICENCE", labelKey: "typeDrivingLicence" },
|
|
12
|
+
{ value: "BIRTH_CERTIFICATE", labelKey: "typeBirthCertificate" },
|
|
13
|
+
{ value: "VOTER_ID", labelKey: "typeVoterId" },
|
|
14
|
+
{ value: "RESIDENCE_PERMIT", labelKey: "typeResidencePermit" },
|
|
15
|
+
{ value: "REFUGEE_ID", labelKey: "typeRefugeeId" },
|
|
16
|
+
{ value: "MILITARY_ID", labelKey: "typeMilitaryId" },
|
|
17
|
+
{ value: "OTHER", labelKey: "typeOther" },
|
|
18
|
+
];
|
|
19
|
+
export const GOVERNMENT_ID_TYPE_VALUES = GOVERNMENT_ID_TYPES.map((type) => type.value);
|
|
20
|
+
export function isGovernmentIdType(value) {
|
|
21
|
+
return (typeof value === "string" &&
|
|
22
|
+
GOVERNMENT_ID_TYPE_VALUES.includes(value));
|
|
23
|
+
}
|
|
24
|
+
export function governmentIdTypeLabelKey(idType) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (!idType)
|
|
27
|
+
return null;
|
|
28
|
+
const match = GOVERNMENT_ID_TYPES.find((type) => type.value === idType);
|
|
29
|
+
return (_a = match === null || match === void 0 ? void 0 : match.labelKey) !== null && _a !== void 0 ? _a : null;
|
|
30
|
+
}
|
|
31
|
+
const ID_NUMBER_PATTERNS = {
|
|
32
|
+
NATIONAL_ID: /^[A-Z0-9][A-Z0-9 ./-]{4,19}$/i,
|
|
33
|
+
PASSPORT: /^[A-Z0-9][A-Z0-9 ./-]{4,19}$/i,
|
|
34
|
+
DRIVING_LICENCE: /^[A-Z0-9][A-Z0-9 ./-]{2,19}$/i,
|
|
35
|
+
BIRTH_CERTIFICATE: /^[A-Z0-9][A-Z0-9 ./-]{2,29}$/i,
|
|
36
|
+
VOTER_ID: /^[A-Z0-9][A-Z0-9 ./-]{2,19}$/i,
|
|
37
|
+
RESIDENCE_PERMIT: /^[A-Z0-9][A-Z0-9 ./-]{2,19}$/i,
|
|
38
|
+
REFUGEE_ID: /^[A-Z0-9][A-Z0-9 ./-]{2,19}$/i,
|
|
39
|
+
MILITARY_ID: /^[A-Z0-9][A-Z0-9 ./-]{2,19}$/i,
|
|
40
|
+
OTHER: /^[\s\S]{1,40}$/,
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Normalize an ID number for storage. National IDs keep the existing CNIC
|
|
44
|
+
* behaviour (13 digits are stored without separators); most other document
|
|
45
|
+
* numbers are trimmed and upper-cased. `OTHER` is only trimmed.
|
|
46
|
+
*/
|
|
47
|
+
export function normalizeIdNumberForType(value, idType) {
|
|
48
|
+
const trimmed = value.trim().replace(/\s+/g, " ");
|
|
49
|
+
if (!idType)
|
|
50
|
+
return trimmed;
|
|
51
|
+
switch (idType) {
|
|
52
|
+
case "NATIONAL_ID": {
|
|
53
|
+
const digits = trimmed.replace(/\D/g, "");
|
|
54
|
+
return digits.length === 13 ? digits : trimmed;
|
|
55
|
+
}
|
|
56
|
+
case "OTHER":
|
|
57
|
+
return trimmed;
|
|
58
|
+
default:
|
|
59
|
+
return trimmed.toUpperCase();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Lenient, global validation. Country-specific document numbers vary widely,
|
|
64
|
+
* so this only rejects empty values, unsupported characters and obviously
|
|
65
|
+
* wrong lengths.
|
|
66
|
+
*/
|
|
67
|
+
export function isValidIdNumberForType(value, idType) {
|
|
68
|
+
if (!value.trim())
|
|
69
|
+
return false;
|
|
70
|
+
return ID_NUMBER_PATTERNS[idType].test(normalizeIdNumberForType(value, idType));
|
|
71
|
+
}
|
package/utils/id-number.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { GovernmentIdType } from "./government-id";
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a government ID number.
|
|
4
|
+
*
|
|
5
|
+
* When `idType` is supplied the value is normalized according to the document
|
|
6
|
+
* type (e.g. a 13-digit CNIC loses separators, a passport is upper-cased).
|
|
7
|
+
* Without `idType` the legacy behaviour is preserved so existing callers keep
|
|
8
|
+
* working unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeIdNumber(value: unknown, idType?: GovernmentIdType | null): string | null | undefined;
|
package/utils/id-number.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { normalizeIdNumberForType } from "./government-id";
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a government ID number.
|
|
4
|
+
*
|
|
5
|
+
* When `idType` is supplied the value is normalized according to the document
|
|
6
|
+
* type (e.g. a 13-digit CNIC loses separators, a passport is upper-cased).
|
|
7
|
+
* Without `idType` the legacy behaviour is preserved so existing callers keep
|
|
8
|
+
* working unchanged.
|
|
9
|
+
*/
|
|
10
|
+
export function normalizeIdNumber(value, idType) {
|
|
2
11
|
if (value === null)
|
|
3
12
|
return null;
|
|
4
13
|
if (typeof value !== "string")
|
|
5
14
|
return undefined;
|
|
15
|
+
if (idType)
|
|
16
|
+
return normalizeIdNumberForType(value, idType);
|
|
6
17
|
const stripped = value.replace(/\D/g, "");
|
|
7
18
|
if (stripped.length === 13)
|
|
8
19
|
return stripped;
|