@appcorp/fusion-storybook 0.1.14 → 0.1.15
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.js +97 -38
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.d.ts +2 -0
|
@@ -128,7 +128,7 @@ export const { actionTypes: ADMISSION_ACTION_TYPES, config: admissionModuleConfi
|
|
|
128
128
|
// ENHANCED ADMISSION HOOK WITH API INTEGRATION
|
|
129
129
|
// ============================================================================
|
|
130
130
|
export const useAdmissionModule = () => {
|
|
131
|
-
var _a, _b, _c, _d, _e;
|
|
131
|
+
var _a, _b, _c, _d, _e, _f;
|
|
132
132
|
const context = useAdmissionContext();
|
|
133
133
|
const t = useTranslations("admission");
|
|
134
134
|
const workspace = getCachedWorkspaceSync();
|
|
@@ -302,19 +302,25 @@ export const useAdmissionModule = () => {
|
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
304
|
const byIdCallback = ({ data, error }) => {
|
|
305
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
|
|
305
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
306
306
|
if (error) {
|
|
307
307
|
showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
if (data) {
|
|
311
311
|
const admission = data;
|
|
312
|
+
if ((_a = admission === null || admission === void 0 ? void 0 : admission.fatherDetails) === null || _a === void 0 ? void 0 : _a.emergencyContact) {
|
|
313
|
+
setField("emergencyContact", "Father");
|
|
314
|
+
}
|
|
315
|
+
if ((_b = admission === null || admission === void 0 ? void 0 : admission.motherDetails) === null || _b === void 0 ? void 0 : _b.emergencyContact) {
|
|
316
|
+
setField("emergencyContact", "Mother");
|
|
317
|
+
}
|
|
312
318
|
setField("id", admission.id);
|
|
313
|
-
setField("firstName", (
|
|
314
|
-
setField("lastName", (
|
|
315
|
-
setField("bForm", (
|
|
319
|
+
setField("firstName", (_c = admission.studentDetails) === null || _c === void 0 ? void 0 : _c.firstName);
|
|
320
|
+
setField("lastName", (_d = admission.studentDetails) === null || _d === void 0 ? void 0 : _d.lastName);
|
|
321
|
+
setField("bForm", (_e = admission.studentDetails) === null || _e === void 0 ? void 0 : _e.bForm);
|
|
316
322
|
// Normalise gender to match GENDER enum values (e.g. 'Male' → 'MALE')
|
|
317
|
-
const rawGender = (
|
|
323
|
+
const rawGender = (_f = admission.studentDetails) === null || _f === void 0 ? void 0 : _f.gender;
|
|
318
324
|
let normalizedGender = null;
|
|
319
325
|
if (typeof rawGender === "string" && rawGender.length > 0) {
|
|
320
326
|
const upper = rawGender.toUpperCase();
|
|
@@ -323,36 +329,36 @@ export const useAdmissionModule = () => {
|
|
|
323
329
|
: rawGender;
|
|
324
330
|
}
|
|
325
331
|
setField("gender", normalizedGender);
|
|
326
|
-
setField("dob", (
|
|
327
|
-
setField("registrationCode", (
|
|
328
|
-
setField("discountCode", (
|
|
329
|
-
setField("hafiz", (
|
|
330
|
-
setField("orphan", (
|
|
331
|
-
setField("fatherFirstName", (
|
|
332
|
-
setField("fatherLastName", (
|
|
333
|
-
setField("fatherCnic", (
|
|
334
|
-
setField("fatherMobile", (
|
|
335
|
-
setField("fatherOccupation", (
|
|
336
|
-
setField("fatherOrganization", (
|
|
337
|
-
setField("motherFirstName", (
|
|
338
|
-
setField("motherLastName", (
|
|
339
|
-
setField("motherCnic", (
|
|
340
|
-
setField("motherMobile", (
|
|
341
|
-
setField("address", (
|
|
342
|
-
setField("city", (
|
|
343
|
-
setField("country", (
|
|
344
|
-
setField("postalCode", (
|
|
345
|
-
setField("state", (
|
|
346
|
-
setField("notes", (
|
|
347
|
-
setField("admissionNotes", (
|
|
348
|
-
setField("previousSchool", (
|
|
349
|
-
setField("siblings", (
|
|
350
|
-
setField("classForAdmission", (
|
|
332
|
+
setField("dob", (_g = admission.studentDetails) === null || _g === void 0 ? void 0 : _g.dob);
|
|
333
|
+
setField("registrationCode", (_h = admission.studentDetails) === null || _h === void 0 ? void 0 : _h.registrationCode);
|
|
334
|
+
setField("discountCode", (_j = admission.studentDetails) === null || _j === void 0 ? void 0 : _j.discountCode);
|
|
335
|
+
setField("hafiz", (_k = admission.studentDetails) === null || _k === void 0 ? void 0 : _k.hafiz);
|
|
336
|
+
setField("orphan", (_l = admission.studentDetails) === null || _l === void 0 ? void 0 : _l.orphan);
|
|
337
|
+
setField("fatherFirstName", (_m = admission.fatherDetails) === null || _m === void 0 ? void 0 : _m.fatherFirstName);
|
|
338
|
+
setField("fatherLastName", (_o = admission.fatherDetails) === null || _o === void 0 ? void 0 : _o.fatherLastName);
|
|
339
|
+
setField("fatherCnic", (_p = admission.fatherDetails) === null || _p === void 0 ? void 0 : _p.fatherCnic);
|
|
340
|
+
setField("fatherMobile", (_q = admission.fatherDetails) === null || _q === void 0 ? void 0 : _q.fatherMobile);
|
|
341
|
+
setField("fatherOccupation", (_r = admission.fatherDetails) === null || _r === void 0 ? void 0 : _r.fatherOccupation);
|
|
342
|
+
setField("fatherOrganization", (_s = admission.fatherDetails) === null || _s === void 0 ? void 0 : _s.fatherOrganization);
|
|
343
|
+
setField("motherFirstName", (_t = admission.motherDetails) === null || _t === void 0 ? void 0 : _t.motherFirstName);
|
|
344
|
+
setField("motherLastName", (_u = admission.motherDetails) === null || _u === void 0 ? void 0 : _u.motherLastName);
|
|
345
|
+
setField("motherCnic", (_v = admission.motherDetails) === null || _v === void 0 ? void 0 : _v.motherCnic);
|
|
346
|
+
setField("motherMobile", (_w = admission.motherDetails) === null || _w === void 0 ? void 0 : _w.motherMobile);
|
|
347
|
+
setField("address", (_x = admission.homeDetails) === null || _x === void 0 ? void 0 : _x.address);
|
|
348
|
+
setField("city", (_y = admission.homeDetails) === null || _y === void 0 ? void 0 : _y.city);
|
|
349
|
+
setField("country", (_z = admission.homeDetails) === null || _z === void 0 ? void 0 : _z.country);
|
|
350
|
+
setField("postalCode", (_0 = admission.homeDetails) === null || _0 === void 0 ? void 0 : _0.postalCode);
|
|
351
|
+
setField("state", (_1 = admission.homeDetails) === null || _1 === void 0 ? void 0 : _1.state);
|
|
352
|
+
setField("notes", (_2 = admission.officeUse) === null || _2 === void 0 ? void 0 : _2.notes);
|
|
353
|
+
setField("admissionNotes", (_3 = admission.officeUse) === null || _3 === void 0 ? void 0 : _3.admissionNotes);
|
|
354
|
+
setField("previousSchool", (_4 = admission.admissionDetails) === null || _4 === void 0 ? void 0 : _4.previousSchool);
|
|
355
|
+
setField("siblings", (_5 = admission.admissionDetails) === null || _5 === void 0 ? void 0 : _5.siblings);
|
|
356
|
+
setField("classForAdmission", (_6 = admission.admissionDetails) === null || _6 === void 0 ? void 0 : _6.classForAdmission);
|
|
351
357
|
setField("status", admission.status || ADMISSION_STATUS.PENDING);
|
|
352
|
-
setField("enabled", (
|
|
358
|
+
setField("enabled", (_7 = admission.enabled) !== null && _7 !== void 0 ? _7 : true);
|
|
353
359
|
// Populate AI analysis if present
|
|
354
|
-
const aiAnalysis = (
|
|
355
|
-
.aiAnalysis) !== null &&
|
|
360
|
+
const aiAnalysis = (_8 = admission
|
|
361
|
+
.aiAnalysis) !== null && _8 !== void 0 ? _8 : null;
|
|
356
362
|
context.dispatch({
|
|
357
363
|
type: ADMISSION_ACTION_TYPES.SET_FORM_DATA,
|
|
358
364
|
payload: { form: { aiAnalysis } },
|
|
@@ -647,8 +653,54 @@ export const useAdmissionModule = () => {
|
|
|
647
653
|
params: updateParams,
|
|
648
654
|
schema: admissionFormValidation,
|
|
649
655
|
successCallback: () => {
|
|
656
|
+
var _a;
|
|
650
657
|
updateFetchNow(undefined, {
|
|
651
|
-
body: JSON.stringify(
|
|
658
|
+
body: JSON.stringify({
|
|
659
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
660
|
+
admissionDetails: {
|
|
661
|
+
classForAdmission: updateParams.classForAdmission,
|
|
662
|
+
previousSchool: updateParams.previousSchool,
|
|
663
|
+
siblings: updateParams.siblings,
|
|
664
|
+
},
|
|
665
|
+
fatherDetails: {
|
|
666
|
+
fatherCnic: updateParams.fatherCnic,
|
|
667
|
+
fatherFirstName: updateParams.fatherFirstName,
|
|
668
|
+
fatherLastName: updateParams.fatherLastName,
|
|
669
|
+
fatherMobile: updateParams.fatherMobile,
|
|
670
|
+
fatherOccupation: updateParams.fatherOccupation,
|
|
671
|
+
fatherOrganization: updateParams.fatherOrganization,
|
|
672
|
+
emergencyContact: updateParams.emergencyContact === "Father",
|
|
673
|
+
},
|
|
674
|
+
motherDetails: {
|
|
675
|
+
motherCnic: updateParams.motherCnic,
|
|
676
|
+
motherFirstName: updateParams.motherFirstName,
|
|
677
|
+
motherLastName: updateParams.motherLastName,
|
|
678
|
+
motherMobile: updateParams.motherMobile,
|
|
679
|
+
emergencyContact: updateParams.emergencyContact === "Mother",
|
|
680
|
+
},
|
|
681
|
+
homeDetails: {
|
|
682
|
+
address: updateParams.address,
|
|
683
|
+
city: updateParams.city,
|
|
684
|
+
country: updateParams.country,
|
|
685
|
+
postalCode: updateParams.postalCode,
|
|
686
|
+
state: updateParams.state,
|
|
687
|
+
},
|
|
688
|
+
officeUse: {
|
|
689
|
+
notes: updateParams.notes,
|
|
690
|
+
admissionNotes: updateParams.admissionNotes,
|
|
691
|
+
},
|
|
692
|
+
studentDetails: {
|
|
693
|
+
bForm: updateParams.bForm,
|
|
694
|
+
discountCode: updateParams.discountCode,
|
|
695
|
+
dob: updateParams.dob,
|
|
696
|
+
firstName: updateParams.firstName,
|
|
697
|
+
gender: updateParams.gender,
|
|
698
|
+
hafiz: updateParams.hafiz,
|
|
699
|
+
lastName: updateParams.lastName,
|
|
700
|
+
orphan: updateParams.orphan,
|
|
701
|
+
registrationCode: updateParams.registrationCode,
|
|
702
|
+
},
|
|
703
|
+
}),
|
|
652
704
|
});
|
|
653
705
|
},
|
|
654
706
|
errorCallback: (errors) => {
|
|
@@ -663,11 +715,18 @@ export const useAdmissionModule = () => {
|
|
|
663
715
|
showToast(t("messagesFormErrors"), TOAST_VARIANT.ERROR);
|
|
664
716
|
},
|
|
665
717
|
});
|
|
666
|
-
}, [
|
|
718
|
+
}, [
|
|
719
|
+
context,
|
|
720
|
+
updateParams,
|
|
721
|
+
t,
|
|
722
|
+
showToast,
|
|
723
|
+
updateFetchNow,
|
|
724
|
+
(_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id,
|
|
725
|
+
]);
|
|
667
726
|
// ============================================================================
|
|
668
727
|
// HEADER & ROW ACTIONS
|
|
669
728
|
// ============================================================================
|
|
670
|
-
const hasGeminiSecrets = Boolean(((
|
|
729
|
+
const hasGeminiSecrets = Boolean(((_e = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _e === void 0 ? void 0 : _e.GEMINI_API_KEY) && ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _f === void 0 ? void 0 : _f.GEMINI_MODEL));
|
|
671
730
|
const headerActions = useMemo(() => [
|
|
672
731
|
{
|
|
673
732
|
enabled: true,
|
|
@@ -759,7 +818,7 @@ export const useAdmissionModule = () => {
|
|
|
759
818
|
showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
760
819
|
}
|
|
761
820
|
})();
|
|
762
|
-
}, [listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, t, showToast, context
|
|
821
|
+
}, [listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, t, showToast, context]);
|
|
763
822
|
// ============================================================================
|
|
764
823
|
// RETURN
|
|
765
824
|
// ============================================================================
|