@appcorp/fusion-storybook 0.4.13 → 0.4.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/use-admission-module.d.ts +4 -0
- package/base-modules/admission/context/use-admission-module.js +159 -60
- package/base-modules/admission/context.d.ts +10 -0
- package/base-modules/admission/context.js +3 -0
- package/base-modules/admission/form.js +15 -4
- package/base-modules/admission/view.js +8 -4
- package/base-modules/student-fee/constants.d.ts +4 -0
- package/base-modules/student-fee/constants.js +13 -0
- package/base-modules/student-fee/context/shared.d.ts +30 -0
- package/base-modules/student-fee/context/shared.js +10 -2
- package/base-modules/student-fee/context/student-fee-api-provider.js +18 -1
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +6 -0
- package/base-modules/student-fee/context/use-student-fee-module.js +38 -23
- package/base-modules/student-fee/filter.js +3 -2
- package/constants.d.ts +3 -0
- package/constants.js +3 -0
- package/package.json +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/admission.d.ts +1 -0
- package/utils/file-to-base64.d.ts +1 -0
- package/utils/file-to-base64.js +10 -0
|
@@ -16,6 +16,7 @@ export declare const useAdmissionModule: () => {
|
|
|
16
16
|
handlePageChange: (page: number | unknown) => void;
|
|
17
17
|
handlePageLimitChange: (k: string, value: object) => void;
|
|
18
18
|
handlePrint: (row?: TableRow) => Promise<void>;
|
|
19
|
+
handleRemoveDocument: (url: string) => Promise<void>;
|
|
19
20
|
handleSearch: (query: string) => void;
|
|
20
21
|
handleSetEndDate: (endDate: string) => void;
|
|
21
22
|
handleSetStartDate: (startDate: string) => void;
|
|
@@ -31,6 +32,7 @@ export declare const useAdmissionModule: () => {
|
|
|
31
32
|
listLoading: boolean;
|
|
32
33
|
rowActions: RowAction[];
|
|
33
34
|
updateLoading: boolean;
|
|
35
|
+
uploadAdmissionDocuments: (files: File[]) => Promise<string[]>;
|
|
34
36
|
state: {
|
|
35
37
|
items: AdmissionBE[];
|
|
36
38
|
count: number;
|
|
@@ -69,6 +71,8 @@ export declare const useAdmissionModule: () => {
|
|
|
69
71
|
classForAdmission: string;
|
|
70
72
|
previousSchool: string;
|
|
71
73
|
siblings: string;
|
|
74
|
+
documents: string[];
|
|
75
|
+
documentsFiles: File[];
|
|
72
76
|
admissionNotes: string;
|
|
73
77
|
notes: string;
|
|
74
78
|
enabled: boolean;
|
|
@@ -11,17 +11,18 @@ import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
|
|
|
11
11
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
12
12
|
import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
|
|
13
13
|
import { ADMISSION_STATUS, GENDER, } from "../../../type";
|
|
14
|
-
import { ADMISSION_API_ROUTES, DISCOUNT_CODE_API_ROUTES, } from "../../../constants";
|
|
14
|
+
import { ADMISSION_API_ROUTES, DISCOUNT_CODE_API_ROUTES, DOCUMENT_UPLOAD_API_ROUTES, } from "../../../constants";
|
|
15
15
|
import { admissionFormValidation } from "../validate";
|
|
16
16
|
import { getCachedWorkspaceSync } from "../../workspace/cache";
|
|
17
17
|
import { downloadAdmissionFormPDF, } from "../../../utils/admission-pdf";
|
|
18
|
+
import { fileToBase64 } from "../../../utils/file-to-base64";
|
|
18
19
|
import { normalizeIdNumber } from "../../../utils/id-number";
|
|
19
20
|
import { toE164Phone } from "../../../utils/to-e164-phone";
|
|
20
21
|
import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
|
|
21
22
|
import { Filter, Plus } from "lucide-react";
|
|
22
23
|
import { ADMISSION_DRAWER, ADMISSION_ACTION_TYPES, useAdmissionContext, } from "../context";
|
|
23
24
|
export const useAdmissionModule = () => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
25
26
|
// ============================================================================
|
|
26
27
|
// 1.4.1 STATE & CORE HOOKS
|
|
27
28
|
// ============================================================================
|
|
@@ -76,6 +77,7 @@ export const useAdmissionModule = () => {
|
|
|
76
77
|
country: state.country || "",
|
|
77
78
|
discountCodeId: state.discountCodeId || "",
|
|
78
79
|
dob: state.dob || null,
|
|
80
|
+
documents: state.documents || [],
|
|
79
81
|
emergencyContact: state.emergencyContact || "",
|
|
80
82
|
enabled: (_a = state.enabled) !== null && _a !== void 0 ? _a : true,
|
|
81
83
|
fatherIdNumber: state.fatherIdNumber || "",
|
|
@@ -110,6 +112,7 @@ export const useAdmissionModule = () => {
|
|
|
110
112
|
state.country,
|
|
111
113
|
state.discountCodeId,
|
|
112
114
|
state.dob,
|
|
115
|
+
state.documents,
|
|
113
116
|
state.emergencyContact,
|
|
114
117
|
state.enabled,
|
|
115
118
|
state.fatherFirstName,
|
|
@@ -209,7 +212,7 @@ export const useAdmissionModule = () => {
|
|
|
209
212
|
}
|
|
210
213
|
}, [resetFormAndCloseDrawer, showToast, t]);
|
|
211
214
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
212
|
-
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, _9, _10, _11, _12;
|
|
215
|
+
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, _9, _10, _11, _12, _13, _14;
|
|
213
216
|
if (error) {
|
|
214
217
|
showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
|
|
215
218
|
return;
|
|
@@ -260,12 +263,19 @@ export const useAdmissionModule = () => {
|
|
|
260
263
|
setField("admissionNotes", (_7 = admission.officeUse) === null || _7 === void 0 ? void 0 : _7.admissionNotes);
|
|
261
264
|
setField("previousSchool", (_8 = admission.admissionDetails) === null || _8 === void 0 ? void 0 : _8.previousSchool);
|
|
262
265
|
setField("siblings", (_9 = admission.admissionDetails) === null || _9 === void 0 ? void 0 : _9.siblings);
|
|
263
|
-
|
|
266
|
+
dispatch({
|
|
267
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
268
|
+
payload: {
|
|
269
|
+
key: "documents",
|
|
270
|
+
value: (_11 = (_10 = admission.admissionDetails) === null || _10 === void 0 ? void 0 : _10.documents) !== null && _11 !== void 0 ? _11 : [],
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
setField("classForAdmission", (_12 = admission.admissionDetails) === null || _12 === void 0 ? void 0 : _12.classForAdmission);
|
|
264
274
|
setField("status", admission.status || ADMISSION_STATUS.PENDING);
|
|
265
|
-
setField("enabled", (
|
|
275
|
+
setField("enabled", (_13 = admission.enabled) !== null && _13 !== void 0 ? _13 : true);
|
|
266
276
|
// Populate AI analysis if present
|
|
267
|
-
const aiAnalysis = (
|
|
268
|
-
.aiAnalysis) !== null &&
|
|
277
|
+
const aiAnalysis = (_14 = admission
|
|
278
|
+
.aiAnalysis) !== null && _14 !== void 0 ? _14 : null;
|
|
269
279
|
dispatch({
|
|
270
280
|
type: ADMISSION_ACTION_TYPES.SET_FORM_DATA,
|
|
271
281
|
payload: { form: { aiAnalysis } },
|
|
@@ -283,6 +293,30 @@ export const useAdmissionModule = () => {
|
|
|
283
293
|
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
284
294
|
}
|
|
285
295
|
}, [showToast, t]);
|
|
296
|
+
const uploadAdmissionDocuments = useCallback(async (files) => {
|
|
297
|
+
var _a;
|
|
298
|
+
const schoolId = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id;
|
|
299
|
+
if (!schoolId) {
|
|
300
|
+
throw new Error("School context is not available");
|
|
301
|
+
}
|
|
302
|
+
const payload = await Promise.all(files.map(async (file) => ({
|
|
303
|
+
fileName: file.name,
|
|
304
|
+
contentType: file.type || "application/octet-stream",
|
|
305
|
+
fileBase64: await fileToBase64(file),
|
|
306
|
+
})));
|
|
307
|
+
const { data, error } = await fetchData({
|
|
308
|
+
url: DOCUMENT_UPLOAD_API_ROUTES.UNIT,
|
|
309
|
+
method: API_METHODS.POST,
|
|
310
|
+
headers: {
|
|
311
|
+
"Content-Type": "application/json",
|
|
312
|
+
},
|
|
313
|
+
body: JSON.stringify({ schoolId, files: payload }),
|
|
314
|
+
});
|
|
315
|
+
if (error || !(data === null || data === void 0 ? void 0 : data.urls)) {
|
|
316
|
+
throw new Error("Upload failed");
|
|
317
|
+
}
|
|
318
|
+
return data.urls;
|
|
319
|
+
}, [(_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
|
|
286
320
|
// ============================================================================
|
|
287
321
|
// 1.4.5 API HOOKS
|
|
288
322
|
// ============================================================================
|
|
@@ -347,6 +381,42 @@ export const useAdmissionModule = () => {
|
|
|
347
381
|
body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id }),
|
|
348
382
|
});
|
|
349
383
|
}, [t, deleteFetchNow]);
|
|
384
|
+
const handleRemoveDocument = useCallback(async (url) => {
|
|
385
|
+
var _a;
|
|
386
|
+
const next = (state.documents || []).filter((d) => d !== url);
|
|
387
|
+
dispatch({
|
|
388
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
389
|
+
payload: { key: "documents", value: next },
|
|
390
|
+
});
|
|
391
|
+
const { data, error } = await fetchData({
|
|
392
|
+
url: ADMISSION_API_ROUTES.UNIT,
|
|
393
|
+
method: API_METHODS.PUT,
|
|
394
|
+
headers: {
|
|
395
|
+
"Content-Type": "application/json",
|
|
396
|
+
},
|
|
397
|
+
body: JSON.stringify({
|
|
398
|
+
id: state.id,
|
|
399
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
400
|
+
admissionDetails: {
|
|
401
|
+
classForAdmission: state.classForAdmission || "",
|
|
402
|
+
previousSchool: state.previousSchool || "",
|
|
403
|
+
siblings: state.siblings || "",
|
|
404
|
+
documents: next,
|
|
405
|
+
},
|
|
406
|
+
}),
|
|
407
|
+
});
|
|
408
|
+
if (error || !data) {
|
|
409
|
+
throw new Error("Document removal failed");
|
|
410
|
+
}
|
|
411
|
+
}, [
|
|
412
|
+
dispatch,
|
|
413
|
+
(_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id,
|
|
414
|
+
state.documents,
|
|
415
|
+
state.id,
|
|
416
|
+
state.classForAdmission,
|
|
417
|
+
state.previousSchool,
|
|
418
|
+
state.siblings,
|
|
419
|
+
]);
|
|
350
420
|
const handleFilters = useCallback(() => {
|
|
351
421
|
dispatch({
|
|
352
422
|
type: ADMISSION_ACTION_TYPES.SET_DRAWER,
|
|
@@ -553,7 +623,7 @@ export const useAdmissionModule = () => {
|
|
|
553
623
|
description: `${t("messagesAnalyzeSuccess")} ${(_c = result === null || result === void 0 ? void 0 : result.score) !== null && _c !== void 0 ? _c : "N/A"} — ${(_d = result === null || result === void 0 ? void 0 : result.status) !== null && _d !== void 0 ? _d : ""}`,
|
|
554
624
|
variant: TOAST_VARIANT.SUCCESS,
|
|
555
625
|
});
|
|
556
|
-
}, [(
|
|
626
|
+
}, [(_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id, t, showToast, byIdFetchNow, dispatch]);
|
|
557
627
|
const handleSubmit = useCallback(() => {
|
|
558
628
|
dispatch({
|
|
559
629
|
type: ADMISSION_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
@@ -562,56 +632,80 @@ export const useAdmissionModule = () => {
|
|
|
562
632
|
validateForm({
|
|
563
633
|
params: updateParams,
|
|
564
634
|
schema: admissionFormValidation,
|
|
565
|
-
successCallback: () => {
|
|
635
|
+
successCallback: async () => {
|
|
566
636
|
var _a;
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
637
|
+
try {
|
|
638
|
+
const merged = state.documentsFiles.length
|
|
639
|
+
? [
|
|
640
|
+
...(state.documents || []),
|
|
641
|
+
...(await uploadAdmissionDocuments(state.documentsFiles)),
|
|
642
|
+
]
|
|
643
|
+
: state.documents || [];
|
|
644
|
+
dispatch({
|
|
645
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
646
|
+
payload: { key: "documents", value: merged },
|
|
647
|
+
});
|
|
648
|
+
dispatch({
|
|
649
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
650
|
+
payload: { key: "documentsFiles", value: [] },
|
|
651
|
+
});
|
|
652
|
+
updateFetchNow(undefined, {
|
|
653
|
+
body: JSON.stringify({
|
|
654
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
655
|
+
admissionDetails: {
|
|
656
|
+
classForAdmission: updateParams.classForAdmission,
|
|
657
|
+
previousSchool: updateParams.previousSchool,
|
|
658
|
+
siblings: updateParams.siblings,
|
|
659
|
+
documents: merged,
|
|
660
|
+
},
|
|
661
|
+
fatherDetails: {
|
|
662
|
+
fatherIdNumber: normalizeIdNumber(updateParams.fatherIdNumber),
|
|
663
|
+
fatherFirstName: updateParams.fatherFirstName,
|
|
664
|
+
fatherLastName: updateParams.fatherLastName,
|
|
665
|
+
fatherMobile: updateParams.fatherMobile,
|
|
666
|
+
fatherOccupation: updateParams.fatherOccupation,
|
|
667
|
+
fatherOrganization: updateParams.fatherOrganization,
|
|
668
|
+
emergencyContact: updateParams.emergencyContact === "Father",
|
|
669
|
+
},
|
|
670
|
+
motherDetails: {
|
|
671
|
+
motherIdNumber: normalizeIdNumber(updateParams.motherIdNumber || ""),
|
|
672
|
+
motherFirstName: updateParams.motherFirstName || "N/A",
|
|
673
|
+
motherLastName: updateParams.motherLastName || "N/A",
|
|
674
|
+
motherMobile: updateParams.motherMobile,
|
|
675
|
+
emergencyContact: updateParams.emergencyContact === "Mother",
|
|
676
|
+
},
|
|
677
|
+
homeDetails: {
|
|
678
|
+
address: updateParams.address,
|
|
679
|
+
city: updateParams.city,
|
|
680
|
+
country: updateParams.country,
|
|
681
|
+
postalCode: updateParams.postalCode,
|
|
682
|
+
state: updateParams.state,
|
|
683
|
+
},
|
|
684
|
+
officeUse: {
|
|
685
|
+
notes: updateParams.notes,
|
|
686
|
+
admissionNotes: updateParams.admissionNotes,
|
|
687
|
+
},
|
|
688
|
+
studentDetails: {
|
|
689
|
+
studentIdNumber: normalizeIdNumber(updateParams.studentIdNumber),
|
|
690
|
+
discountCodeId: updateParams.discountCodeId,
|
|
691
|
+
dob: updateParams.dob,
|
|
692
|
+
firstName: updateParams.firstName,
|
|
693
|
+
gender: updateParams.gender,
|
|
694
|
+
hafiz: updateParams.hafiz,
|
|
695
|
+
lastName: updateParams.lastName,
|
|
696
|
+
orphan: updateParams.orphan,
|
|
697
|
+
registrationCode: updateParams.registrationCode,
|
|
698
|
+
},
|
|
699
|
+
}),
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
catch (_b) {
|
|
703
|
+
dispatch({
|
|
704
|
+
type: ADMISSION_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
705
|
+
payload: { disabled: false },
|
|
706
|
+
});
|
|
707
|
+
showToast(t("messagesDocumentsUploadFailed"), TOAST_VARIANT.ERROR);
|
|
708
|
+
}
|
|
615
709
|
},
|
|
616
710
|
errorCallback: (errors) => {
|
|
617
711
|
dispatch({
|
|
@@ -631,12 +725,15 @@ export const useAdmissionModule = () => {
|
|
|
631
725
|
t,
|
|
632
726
|
showToast,
|
|
633
727
|
updateFetchNow,
|
|
634
|
-
|
|
728
|
+
state.documents,
|
|
729
|
+
state.documentsFiles,
|
|
730
|
+
uploadAdmissionDocuments,
|
|
731
|
+
(_g = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _g === void 0 ? void 0 : _g.id,
|
|
635
732
|
]);
|
|
636
733
|
// ============================================================================
|
|
637
734
|
// 1.4.8 HEADER & ROW ACTIONS
|
|
638
735
|
// ============================================================================
|
|
639
|
-
const hasGeminiSecrets = Boolean(((
|
|
736
|
+
const hasGeminiSecrets = Boolean(((_h = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _h === void 0 ? void 0 : _h.GEMINI_API_KEY) && ((_j = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _j === void 0 ? void 0 : _j.GEMINI_MODEL));
|
|
640
737
|
const headerActions = useMemo(() => [
|
|
641
738
|
{
|
|
642
739
|
enabled: true,
|
|
@@ -739,6 +836,7 @@ export const useAdmissionModule = () => {
|
|
|
739
836
|
handlePageChange,
|
|
740
837
|
handlePageLimitChange,
|
|
741
838
|
handlePrint,
|
|
839
|
+
handleRemoveDocument,
|
|
742
840
|
handleSearch,
|
|
743
841
|
handleSetEndDate,
|
|
744
842
|
handleSetStartDate,
|
|
@@ -747,5 +845,6 @@ export const useAdmissionModule = () => {
|
|
|
747
845
|
headerActions,
|
|
748
846
|
listLoading,
|
|
749
847
|
rowActions,
|
|
750
|
-
updateLoading
|
|
848
|
+
updateLoading,
|
|
849
|
+
uploadAdmissionDocuments });
|
|
751
850
|
};
|
|
@@ -55,6 +55,8 @@ export declare const ADMISSION_ACTION_TYPES: {
|
|
|
55
55
|
classForAdmission: string;
|
|
56
56
|
previousSchool: string;
|
|
57
57
|
siblings: string;
|
|
58
|
+
documents: string[];
|
|
59
|
+
documentsFiles: File[];
|
|
58
60
|
admissionNotes: string;
|
|
59
61
|
notes: string;
|
|
60
62
|
enabled: boolean;
|
|
@@ -107,6 +109,8 @@ export declare const ADMISSION_ACTION_TYPES: {
|
|
|
107
109
|
classForAdmission: string;
|
|
108
110
|
previousSchool: string;
|
|
109
111
|
siblings: string;
|
|
112
|
+
documents: string[];
|
|
113
|
+
documentsFiles: File[];
|
|
110
114
|
admissionNotes: string;
|
|
111
115
|
notes: string;
|
|
112
116
|
enabled: boolean;
|
|
@@ -161,6 +165,8 @@ export declare const ADMISSION_ACTION_TYPES: {
|
|
|
161
165
|
classForAdmission: string;
|
|
162
166
|
previousSchool: string;
|
|
163
167
|
siblings: string;
|
|
168
|
+
documents: string[];
|
|
169
|
+
documentsFiles: File[];
|
|
164
170
|
admissionNotes: string;
|
|
165
171
|
notes: string;
|
|
166
172
|
enabled: boolean;
|
|
@@ -213,6 +219,8 @@ export declare const ADMISSION_ACTION_TYPES: {
|
|
|
213
219
|
classForAdmission: string;
|
|
214
220
|
previousSchool: string;
|
|
215
221
|
siblings: string;
|
|
222
|
+
documents: string[];
|
|
223
|
+
documentsFiles: File[];
|
|
216
224
|
admissionNotes: string;
|
|
217
225
|
notes: string;
|
|
218
226
|
enabled: boolean;
|
|
@@ -265,6 +273,8 @@ export declare const ADMISSION_ACTION_TYPES: {
|
|
|
265
273
|
classForAdmission: string;
|
|
266
274
|
previousSchool: string;
|
|
267
275
|
siblings: string;
|
|
276
|
+
documents: string[];
|
|
277
|
+
documentsFiles: File[];
|
|
268
278
|
admissionNotes: string;
|
|
269
279
|
notes: string;
|
|
270
280
|
enabled: boolean;
|
|
@@ -9,12 +9,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
* Note: the `state` field in `moduleState` (province/state) is aliased
|
|
10
10
|
* to `provinceState` to avoid a name collision with the hook's `state` object.
|
|
11
11
|
*/
|
|
12
|
+
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
13
|
+
import { EnhancedDropzone } from "@appcorp/shadcn/components/enhanced-dropzone";
|
|
12
14
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
13
15
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
14
|
-
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
15
16
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
16
|
-
import { useAdmissionModule, ADMISSION_ACTION_TYPES } from "./context";
|
|
17
17
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
18
|
+
import { useAdmissionModule, ADMISSION_ACTION_TYPES } from "./context";
|
|
18
19
|
import { useEffect } from "react";
|
|
19
20
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
20
21
|
import { getDialCode } from "@react-pakistan/util-functions/general/get-dial-code";
|
|
@@ -27,7 +28,7 @@ import { useTranslations } from "next-intl";
|
|
|
27
28
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
28
29
|
export const AdmissionForm = () => {
|
|
29
30
|
const { state, handleChange, dispatch } = useAdmissionModule();
|
|
30
|
-
const { address, admissionNotes, studentIdNumber, city, classForAdmission, country, discountCodeId, dob, emergencyContact, errors, fatherIdNumber, fatherFirstName, fatherLastName, fatherMobile, fatherOccupation, fatherOrganization, firstName, gender, id, lastName, motherIdNumber, motherFirstName, motherLastName, motherMobile, notes, previousSchool, registrationCode, siblings, state: provinceState, } = state;
|
|
31
|
+
const { address, admissionNotes, studentIdNumber, city, classForAdmission, country, discountCodeId, dob, documents, emergencyContact, errors, fatherIdNumber, fatherFirstName, fatherLastName, fatherMobile, fatherOccupation, fatherOrganization, firstName, gender, id, lastName, motherIdNumber, motherFirstName, motherLastName, motherMobile, notes, previousSchool, registrationCode, siblings, state: provinceState, } = state;
|
|
31
32
|
const t = useTranslations("admission");
|
|
32
33
|
const genderLabelMap = {
|
|
33
34
|
MALE: t("formOptionMale"),
|
|
@@ -131,5 +132,15 @@ export const AdmissionForm = () => {
|
|
|
131
132
|
}
|
|
132
133
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
133
134
|
}, [id, dispatch]);
|
|
134
|
-
return (_jsxs("div", { className: "grid grid-cols-1 gap-2 space-y-2", children: [_jsx("h4", { className: "m-0 p-0", children: t("formSectionStudentInformation") }), _jsxs("div", { className: "grid grid-cols-5 gap-4", children: [_jsx(EnhancedInput, { error: errors.firstName, id: "firstName", info: t("formFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("firstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: firstName || "" }), _jsx(EnhancedInput, { error: errors.lastName, id: "lastName", info: t("formLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("lastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: lastName || "" }), _jsx(EnhancedInput, { error: errors.studentIdNumber, id: "studentIdNumber", info: t("formStudentIdNumberInfo"), label: t("formStudentIdNumberLabel"), onChange: (e) => handleChange("studentIdNumber", e.target.value), placeholder: t("formStudentIdNumberPlaceholder"), required: true, type: "text", value: studentIdNumber || "" }), genderCombo, _jsx(EnhancedInput, { error: errors.dob, id: "dob", info: t("formDobInfo"), label: t("formDobLabel"), onChange: (e) => handleChange("dob", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: t("formDobPlaceholder"), required: true, type: "date", value: dob || "" }), _jsx(EnhancedInput, { error: errors.registrationCode, id: "registrationCode", info: t("formRegistrationCodeInfo"), label: t("formRegistrationCodeLabel"), onChange: (e) => handleChange("registrationCode", e.target.value), placeholder: t("formRegistrationCodePlaceholder"), required: true, type: "text", value: registrationCode || "", disabled: true }), discountCodeCombo, _jsx(EnhancedCheckbox, { label: t("formHafizLabel"), id: "hafiz", info: t("formHafizInfo"), onCheckedChange: (checked) => handleChange("hafiz", checked) }), _jsx(EnhancedCheckbox, { label: t("formOrphanLabel"), id: "orphan", info: t("formOrphanInfo"), onCheckedChange: (checked) => handleChange("orphan", checked) })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionFatherInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedInput, { error: errors.fatherFirstName, id: "fatherFirstName", info: t("formFatherFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("fatherFirstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: fatherFirstName || "" }), _jsx(EnhancedInput, { error: errors.fatherLastName, id: "fatherLastName", info: t("formFatherLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("fatherLastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: fatherLastName || "" }), _jsx(EnhancedInput, { error: errors.fatherIdNumber, id: "fatherIdNumber", info: t("formFatherIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("fatherIdNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), required: true, type: "text", value: fatherIdNumber || "" }), _jsx(EnhancedInput, { error: errors.fatherMobile, id: "fatherMobile", info: t("formFatherMobileInfo"), label: t("formMobileLabel"), onChange: (e) => handleChange("fatherMobile", e.target.value), placeholder: "+923001234567", required: true, type: "text", value: fatherMobile || "" }), _jsx(EnhancedInput, { error: errors.fatherOccupation, id: "fatherOccupation", info: t("formFatherOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("fatherOccupation", e.target.value), placeholder: t("formOccupationPlaceholder"), required: false, type: "text", value: fatherOccupation || "" }), _jsx(EnhancedInput, { error: errors.fatherOrganization, id: "fatherOrganization", info: t("formFatherOrganizationInfo"), label: t("formOrganizationLabel"), onChange: (e) => handleChange("fatherOrganization", e.target.value), placeholder: t("formOrganizationPlaceholder"), required: false, type: "text", value: fatherOrganization || "" }), _jsx(EnhancedCheckbox, { label: t("formEmergencyContactLabel"), id: "emergencyContactFather", info: t("formFatherEmergencyContactInfo"), checked: emergencyContact === "Father", onCheckedChange: (checked) => handleChange("emergencyContact", checked ? "Father" : "") })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionMotherInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedInput, { error: errors.motherFirstName, id: "motherFirstName", info: t("formMotherFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("motherFirstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: motherFirstName || "" }), _jsx(EnhancedInput, { error: errors.motherLastName, id: "motherLastName", info: t("formMotherLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("motherLastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: motherLastName || "" }), _jsx(EnhancedInput, { error: errors.motherIdNumber, id: "motherIdNumber", info: t("formMotherIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("motherIdNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), required: true, type: "text", value: motherIdNumber || "" }), _jsx(EnhancedInput, { error: errors.motherMobile, id: "motherMobile", info: t("formMotherMobileInfo"), label: t("formMobileLabel"), onChange: (e) => handleChange("motherMobile", e.target.value), placeholder: "+923001234567", required: true, type: "text", value: motherMobile || "" }), _jsx(EnhancedCheckbox, { label: t("formEmergencyContactLabel"), id: "emergencyContactMother", info: t("formMotherEmergencyContactInfo"), checked: emergencyContact === "Mother", onCheckedChange: (checked) => handleChange("emergencyContact", checked ? "Mother" : "") })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionHomeInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedTextarea, { error: errors.address, id: "homeAddress", info: t("formHomeAddressInfo"), label: t("formHomeAddressLabel"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("formHomeAddressPlaceholder"), required: true, rows: 2, value: address || "" }), _jsx(EnhancedInput, { error: errors.city, id: "city", info: t("formCityInfo"), label: t("formCityLabel"), onChange: (e) => handleChange("city", e.target.value), placeholder: t("formCityPlaceholder"), required: true, type: "text", value: city || "" }), _jsx(EnhancedInput, { error: errors.state, id: "state", info: t("formStateInfo"), label: t("formStateLabel"), onChange: (e) => handleChange("state", e.target.value), placeholder: t("formStatePlaceholder"), required: true, type: "text", value: provinceState || "" }), _jsx(EnhancedInput, { error: errors.country, id: "country", info: t("formCountryInfo"), label: t("formCountryLabel"), onChange: (e) => handleChange("country", e.target.value), placeholder: t("formCountryPlaceholder"), required: true, type: "text", value: country || "" })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionAdmissionInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedInput, { error: errors.classForAdmission, id: "classForAdmission", info: t("formClassForAdmissionInfo"), label: t("formClassForAdmissionLabel"), onChange: (e) => handleChange("classForAdmission", e.target.value), placeholder: t("formClassForAdmissionPlaceholder"), required: true, type: "text", value: classForAdmission || "" }), _jsx(EnhancedInput, { error: errors.previousSchool, id: "previousSchool", info: t("formPreviousSchoolInfo"), label: t("formPreviousSchoolLabel"), onChange: (e) => handleChange("previousSchool", e.target.value), placeholder: t("formPreviousSchoolPlaceholder"), type: "text", value: previousSchool || "" }), _jsx(EnhancedTextarea, { error: errors.siblings, id: "siblings", info: t("formSiblingsInfo"), label: t("formSiblingsLabel"), onChange: (e) => handleChange("siblings", e.target.value), placeholder: t("formSiblingsPlaceholder"), rows: 3, value: siblings || "" })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionOfficeUse") }), _jsxs("div", { className: "grid grid-cols-4 gap-4", children: [_jsx(EnhancedTextarea, { error: errors.notes, id: "notes", info: t("formNotesInfo"), label: t("formNotesLabel"), onChange: (e) => handleChange("notes", e.target.value), placeholder: t("formNotesPlaceholder"), rows: 3, value: notes || "" }), _jsx(EnhancedTextarea, { error: errors.admissionNotes, id: "admissionNotes", info: t("formAdmissionNotesInfo"), label: t("formAdmissionNotesLabel"), onChange: (e) => handleChange("admissionNotes", e.target.value), placeholder: t("formAdmissionNotesPlaceholder"), rows: 3, value: admissionNotes || "" })] })
|
|
135
|
+
return (_jsxs("div", { className: "grid grid-cols-1 gap-2 space-y-2", children: [_jsx("h4", { className: "m-0 p-0", children: t("formSectionStudentInformation") }), _jsxs("div", { className: "grid grid-cols-5 gap-4", children: [_jsx(EnhancedInput, { error: errors.firstName, id: "firstName", info: t("formFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("firstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: firstName || "" }), _jsx(EnhancedInput, { error: errors.lastName, id: "lastName", info: t("formLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("lastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: lastName || "" }), _jsx(EnhancedInput, { error: errors.studentIdNumber, id: "studentIdNumber", info: t("formStudentIdNumberInfo"), label: t("formStudentIdNumberLabel"), onChange: (e) => handleChange("studentIdNumber", e.target.value), placeholder: t("formStudentIdNumberPlaceholder"), required: true, type: "text", value: studentIdNumber || "" }), genderCombo, _jsx(EnhancedInput, { error: errors.dob, id: "dob", info: t("formDobInfo"), label: t("formDobLabel"), onChange: (e) => handleChange("dob", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: t("formDobPlaceholder"), required: true, type: "date", value: dob || "" }), _jsx(EnhancedInput, { error: errors.registrationCode, id: "registrationCode", info: t("formRegistrationCodeInfo"), label: t("formRegistrationCodeLabel"), onChange: (e) => handleChange("registrationCode", e.target.value), placeholder: t("formRegistrationCodePlaceholder"), required: true, type: "text", value: registrationCode || "", disabled: true }), discountCodeCombo, _jsx(EnhancedCheckbox, { label: t("formHafizLabel"), id: "hafiz", info: t("formHafizInfo"), onCheckedChange: (checked) => handleChange("hafiz", checked) }), _jsx(EnhancedCheckbox, { label: t("formOrphanLabel"), id: "orphan", info: t("formOrphanInfo"), onCheckedChange: (checked) => handleChange("orphan", checked) })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionFatherInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedInput, { error: errors.fatherFirstName, id: "fatherFirstName", info: t("formFatherFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("fatherFirstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: fatherFirstName || "" }), _jsx(EnhancedInput, { error: errors.fatherLastName, id: "fatherLastName", info: t("formFatherLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("fatherLastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: fatherLastName || "" }), _jsx(EnhancedInput, { error: errors.fatherIdNumber, id: "fatherIdNumber", info: t("formFatherIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("fatherIdNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), required: true, type: "text", value: fatherIdNumber || "" }), _jsx(EnhancedInput, { error: errors.fatherMobile, id: "fatherMobile", info: t("formFatherMobileInfo"), label: t("formMobileLabel"), onChange: (e) => handleChange("fatherMobile", e.target.value), placeholder: "+923001234567", required: true, type: "text", value: fatherMobile || "" }), _jsx(EnhancedInput, { error: errors.fatherOccupation, id: "fatherOccupation", info: t("formFatherOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("fatherOccupation", e.target.value), placeholder: t("formOccupationPlaceholder"), required: false, type: "text", value: fatherOccupation || "" }), _jsx(EnhancedInput, { error: errors.fatherOrganization, id: "fatherOrganization", info: t("formFatherOrganizationInfo"), label: t("formOrganizationLabel"), onChange: (e) => handleChange("fatherOrganization", e.target.value), placeholder: t("formOrganizationPlaceholder"), required: false, type: "text", value: fatherOrganization || "" }), _jsx(EnhancedCheckbox, { label: t("formEmergencyContactLabel"), id: "emergencyContactFather", info: t("formFatherEmergencyContactInfo"), checked: emergencyContact === "Father", onCheckedChange: (checked) => handleChange("emergencyContact", checked ? "Father" : "") })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionMotherInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedInput, { error: errors.motherFirstName, id: "motherFirstName", info: t("formMotherFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("motherFirstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: motherFirstName || "" }), _jsx(EnhancedInput, { error: errors.motherLastName, id: "motherLastName", info: t("formMotherLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("motherLastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: motherLastName || "" }), _jsx(EnhancedInput, { error: errors.motherIdNumber, id: "motherIdNumber", info: t("formMotherIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("motherIdNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), required: true, type: "text", value: motherIdNumber || "" }), _jsx(EnhancedInput, { error: errors.motherMobile, id: "motherMobile", info: t("formMotherMobileInfo"), label: t("formMobileLabel"), onChange: (e) => handleChange("motherMobile", e.target.value), placeholder: "+923001234567", required: true, type: "text", value: motherMobile || "" }), _jsx(EnhancedCheckbox, { label: t("formEmergencyContactLabel"), id: "emergencyContactMother", info: t("formMotherEmergencyContactInfo"), checked: emergencyContact === "Mother", onCheckedChange: (checked) => handleChange("emergencyContact", checked ? "Mother" : "") })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionHomeInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedTextarea, { error: errors.address, id: "homeAddress", info: t("formHomeAddressInfo"), label: t("formHomeAddressLabel"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("formHomeAddressPlaceholder"), required: true, rows: 2, value: address || "" }), _jsx(EnhancedInput, { error: errors.city, id: "city", info: t("formCityInfo"), label: t("formCityLabel"), onChange: (e) => handleChange("city", e.target.value), placeholder: t("formCityPlaceholder"), required: true, type: "text", value: city || "" }), _jsx(EnhancedInput, { error: errors.state, id: "state", info: t("formStateInfo"), label: t("formStateLabel"), onChange: (e) => handleChange("state", e.target.value), placeholder: t("formStatePlaceholder"), required: true, type: "text", value: provinceState || "" }), _jsx(EnhancedInput, { error: errors.country, id: "country", info: t("formCountryInfo"), label: t("formCountryLabel"), onChange: (e) => handleChange("country", e.target.value), placeholder: t("formCountryPlaceholder"), required: true, type: "text", value: country || "" })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionAdmissionInformation") }), _jsxs("div", { className: "grid grid-cols-6 gap-4", children: [_jsx(EnhancedInput, { error: errors.classForAdmission, id: "classForAdmission", info: t("formClassForAdmissionInfo"), label: t("formClassForAdmissionLabel"), onChange: (e) => handleChange("classForAdmission", e.target.value), placeholder: t("formClassForAdmissionPlaceholder"), required: true, type: "text", value: classForAdmission || "" }), _jsx(EnhancedInput, { error: errors.previousSchool, id: "previousSchool", info: t("formPreviousSchoolInfo"), label: t("formPreviousSchoolLabel"), onChange: (e) => handleChange("previousSchool", e.target.value), placeholder: t("formPreviousSchoolPlaceholder"), type: "text", value: previousSchool || "" }), _jsx(EnhancedTextarea, { error: errors.siblings, id: "siblings", info: t("formSiblingsInfo"), label: t("formSiblingsLabel"), onChange: (e) => handleChange("siblings", e.target.value), placeholder: t("formSiblingsPlaceholder"), rows: 3, value: siblings || "" })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionOfficeUse") }), _jsxs("div", { className: "grid grid-cols-4 gap-4", children: [_jsx(EnhancedTextarea, { error: errors.notes, id: "notes", info: t("formNotesInfo"), label: t("formNotesLabel"), onChange: (e) => handleChange("notes", e.target.value), placeholder: t("formNotesPlaceholder"), rows: 3, value: notes || "" }), _jsx(EnhancedTextarea, { error: errors.admissionNotes, id: "admissionNotes", info: t("formAdmissionNotesInfo"), label: t("formAdmissionNotesLabel"), onChange: (e) => handleChange("admissionNotes", e.target.value), placeholder: t("formAdmissionNotesPlaceholder"), rows: 3, value: admissionNotes || "" })] }), _jsx(Separator, {}), _jsx("h4", { className: "m-0 p-0", children: t("formSectionDocumentsLabel") }), _jsx(EnhancedDropzone, { accept: [
|
|
136
|
+
"application/pdf",
|
|
137
|
+
"image/jpeg",
|
|
138
|
+
"image/png",
|
|
139
|
+
"image/webp",
|
|
140
|
+
"application/msword",
|
|
141
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
142
|
+
], error: errors.documents ? t(errors.documents) : undefined, id: "documents", info: t("formDocumentsInfo"), label: t("formDocumentsLabel"), maxFiles: 10, maxSize: 10 * 1024 * 1024, onChange: (files) => dispatch({
|
|
143
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
144
|
+
payload: { key: "documentsFiles", value: files },
|
|
145
|
+
}), value: documents || [] })] }));
|
|
135
146
|
};
|
|
@@ -15,7 +15,7 @@ import { useAdmissionModule } from "./context";
|
|
|
15
15
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@appcorp/shadcn/components/ui/card";
|
|
16
16
|
import { Badge } from "@appcorp/shadcn/components/ui/badge";
|
|
17
17
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
18
|
-
import { AlertTriangle, BookOpen, Brain, Calendar, CheckCircle2, FileText, Home, Loader2, RefreshCw, ShieldCheck, ShieldX, User, XCircle, } from "lucide-react";
|
|
18
|
+
import { AlertTriangle, BookOpen, Brain, Calendar, CheckCircle2, ExternalLink, FileText, Home, Loader2, RefreshCw, ShieldCheck, ShieldX, Trash2, User, XCircle, } from "lucide-react";
|
|
19
19
|
import { Button } from "@appcorp/shadcn/components/ui/button";
|
|
20
20
|
import { useTranslations } from "next-intl";
|
|
21
21
|
import { formatValue } from "@react-pakistan/util-functions/general/format-value";
|
|
@@ -25,8 +25,8 @@ import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
|
25
25
|
import { ADMISSION_STATUS } from "../../type";
|
|
26
26
|
export const AdmissionView = () => {
|
|
27
27
|
var _a, _b, _c;
|
|
28
|
-
const { state, handleAnalyze } = useAdmissionModule();
|
|
29
|
-
const { address, admissionNotes, aiAnalysis, analyzeLoading, analyzeError, studentIdNumber, city, classForAdmission, country, discountCodeId, dob, emergencyContact, enabled, fatherIdNumber, fatherFirstName, fatherLastName, fatherMobile, fatherOccupation, fatherOrganization, firstName, gender, hafiz, id, lastName, motherIdNumber, motherFirstName, motherLastName, motherMobile, notes, orphan, postalCode, previousSchool, registrationCode, siblings, state: provinceState, status, } = state;
|
|
28
|
+
const { state, handleAnalyze, handleRemoveDocument } = useAdmissionModule();
|
|
29
|
+
const { address, admissionNotes, aiAnalysis, analyzeLoading, analyzeError, studentIdNumber, city, classForAdmission, country, discountCodeId, dob, documents, emergencyContact, enabled, fatherIdNumber, fatherFirstName, fatherLastName, fatherMobile, fatherOccupation, fatherOrganization, firstName, gender, hafiz, id, lastName, motherIdNumber, motherFirstName, motherLastName, motherMobile, notes, orphan, postalCode, previousSchool, registrationCode, siblings, state: provinceState, status, } = state;
|
|
30
30
|
const workspace = getCachedWorkspaceSync();
|
|
31
31
|
const hasGeminiSecrets = Boolean(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _a === void 0 ? void 0 : _a.GEMINI_API_KEY) && ((_b = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _b === void 0 ? void 0 : _b.GEMINI_MODEL));
|
|
32
32
|
const t = useTranslations("admission");
|
|
@@ -57,5 +57,9 @@ export const AdmissionView = () => {
|
|
|
57
57
|
? t("viewButtonReRunAnalysis")
|
|
58
58
|
: t("viewButtonAnalyzeWithAi")] }))] }), _jsx(CardDescription, { children: t("viewFieldGeminiPoweredAdmissionScoring") })] }), _jsx(Separator, {}), _jsxs(CardContent, { className: "pt-6", children: [analyzeLoading && (_jsxs("div", { className: "text-muted-foreground flex items-center gap-3", children: [_jsx(Loader2, { className: "h-5 w-5 animate-spin" }), _jsx("span", { children: t("viewTextRunningAiAnalysis") })] })), analyzeError && !analyzeLoading && (_jsxs("div", { className: "text-destructive flex items-center gap-2 text-sm", children: [_jsx(AlertTriangle, { className: "h-4 w-4" }), _jsx("span", { children: analyzeError })] })), !analyzeLoading && aiAnalysis && (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [_jsxs("div", { className: "bg-muted flex flex-col items-center rounded-lg px-6 py-3", children: [_jsx("span", { className: "text-primary text-3xl font-bold", children: aiAnalysis.score }), _jsx("span", { className: "text-muted-foreground text-xs tracking-wide uppercase", children: "/ 100" })] }), _jsxs("span", { className: `inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium ${decisionColor(aiAnalysis.decision)}`, children: [decisionIcon(aiAnalysis.decision), aiAnalysis.decision.replace("_", " ")] }), _jsxs("div", { className: "text-muted-foreground text-sm", children: [_jsxs("span", { className: "font-medium", children: [t("viewFieldConfidence"), ":", " "] }), (aiAnalysis.confidence * 100).toFixed(0), "%"] })] }), aiAnalysis.reasons.length > 0 && (_jsxs("div", { children: [_jsx("p", { className: "mb-2 text-sm font-medium", children: t("viewFieldAiReasoningAndRiskFlags") }), _jsx("ul", { className: "space-y-1.5", children: aiAnalysis.reasons.map((reason, i) => (_jsxs("li", { className: "flex items-start gap-2 text-sm", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0 text-yellow-500" }), _jsx("span", { children: reason })] }, i))) })] })), _jsxs("p", { className: "text-muted-foreground text-xs", children: [t("viewFieldLastAnalyzed"), ":", " ", formatDate(String(aiAnalysis.processedAt), DATE_FORMATS.LOCALE_DATE)] })] })), !analyzeLoading && !aiAnalysis && !analyzeError && (_jsx("p", { className: "text-muted-foreground text-sm", children: t("viewTextNoAiAnalysisYet") }))] })] })), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionAdmissionDetails") })] }), _jsx(CardDescription, { children: t("viewSectionRegistrationAndAdmissionInformation") })] }), _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("viewFieldRegistrationCode") }), _jsx("p", { className: "font-mono text-base", children: formatValue(registrationCode) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldClassForAdmission") }), _jsx("p", { className: "text-base", children: formatValue(classForAdmission) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStatus") }), _jsx("p", { className: "text-base", children: formatValue(status) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPreviousSchool") }), _jsx("p", { className: "text-base", children: formatValue(previousSchool) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldSiblings") }), _jsx("p", { className: "text-base", children: formatValue(siblings) })] })] }) })] }), _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("viewSectionStudentInformation") })] }), _jsx(CardDescription, { children: t("viewSectionPersonalDetails") })] }), _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("viewFieldFullName") }), _jsxs("p", { className: "text-base", children: [formatValue(firstName), " ", formatValue(lastName)] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldDateOfBirth") }), _jsx("p", { className: "text-base", children: formatDate(String(dob), DATE_FORMATS.LOCALE_DATE) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldGender") }), _jsx("p", { className: "text-base", children: formatValue(gender) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStudentIdNumber") }), _jsx("p", { className: "text-base", children: formatValue(studentIdNumber) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldDiscountCode") }), _jsx("p", { className: "text-base", children: discountCodeId
|
|
59
59
|
? ((_c = discountCode === null || discountCode === void 0 ? void 0 : discountCode.code) !== null && _c !== void 0 ? _c : discountCodeId)
|
|
60
|
-
: "N/A" })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldEmergencyContact") }), _jsx("p", { className: "text-base", children: formatValue(emergencyContact) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldHafizEQuran") }), _jsx("p", { className: "text-base", children: hafiz ? t("badgeYes") : t("badgeNo") })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldOrphan") }), _jsx("p", { className: "text-base", children: orphan ? t("badgeYes") : t("badgeNo") })] })] }) })] }), _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("viewSectionFatherInformation") })] }), _jsx(CardDescription, { children: t("viewSectionFatherDetails") })] }), _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("viewFieldFullName") }), _jsxs("p", { className: "text-base", children: [formatValue(fatherFirstName), " ", formatValue(fatherLastName)] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldIdNumber") }), _jsx("p", { className: "text-base", children: formatValue(fatherIdNumber) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldMobile") }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(fatherMobile) || formatValue(fatherMobile) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldOccupation") }), _jsx("p", { className: "text-base", children: formatValue(fatherOccupation) })] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldOrganization") }), _jsx("p", { className: "text-base", children: formatValue(fatherOrganization) })] })] }) })] }), _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("viewSectionMotherInformation") })] }), _jsx(CardDescription, { children: t("viewSectionMotherDetails") })] }), _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("viewFieldFullName") }), _jsxs("p", { className: "text-base", children: [formatValue(motherFirstName), " ", formatValue(motherLastName)] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldIdNumber") }), _jsx("p", { className: "text-base", children: formatValue(motherIdNumber) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldMobile") }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(motherMobile) || formatValue(motherMobile) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Home, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionHomeDetails") })] }), _jsx(CardDescription, { children: t("viewSectionAddressInformation") })] }), _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 md:col-span-2", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldAddress") }), _jsx("p", { className: "text-base", children: formatValue(address) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCity") }), _jsx("p", { className: "text-base", children: formatValue(city) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldState") }), _jsx("p", { className: "text-base", children: formatValue(provinceState) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCountry") }), _jsx("p", { className: "text-base", children: formatValue(country) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPostalCode") }), _jsx("p", { className: "text-base", children: formatValue(postalCode) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FileText, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionOfficeUse") })] }), _jsx(CardDescription, { children: t("viewSectionInternalNotesAndProcessingInformation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldNotes") }), _jsx("p", { className: "text-base", children: formatValue(notes) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldAdmissionNotes") }), _jsx("p", { className: "text-base", children: formatValue(admissionNotes) })] })] }) })] }), _jsxs(Card, { children: [
|
|
60
|
+
: "N/A" })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldEmergencyContact") }), _jsx("p", { className: "text-base", children: formatValue(emergencyContact) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldHafizEQuran") }), _jsx("p", { className: "text-base", children: hafiz ? t("badgeYes") : t("badgeNo") })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldOrphan") }), _jsx("p", { className: "text-base", children: orphan ? t("badgeYes") : t("badgeNo") })] })] }) })] }), _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("viewSectionFatherInformation") })] }), _jsx(CardDescription, { children: t("viewSectionFatherDetails") })] }), _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("viewFieldFullName") }), _jsxs("p", { className: "text-base", children: [formatValue(fatherFirstName), " ", formatValue(fatherLastName)] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldIdNumber") }), _jsx("p", { className: "text-base", children: formatValue(fatherIdNumber) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldMobile") }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(fatherMobile) || formatValue(fatherMobile) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldOccupation") }), _jsx("p", { className: "text-base", children: formatValue(fatherOccupation) })] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldOrganization") }), _jsx("p", { className: "text-base", children: formatValue(fatherOrganization) })] })] }) })] }), _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("viewSectionMotherInformation") })] }), _jsx(CardDescription, { children: t("viewSectionMotherDetails") })] }), _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("viewFieldFullName") }), _jsxs("p", { className: "text-base", children: [formatValue(motherFirstName), " ", formatValue(motherLastName)] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldIdNumber") }), _jsx("p", { className: "text-base", children: formatValue(motherIdNumber) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldMobile") }), _jsx("p", { className: "text-base", children: formatPhoneDisplay(motherMobile) || formatValue(motherMobile) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Home, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionHomeDetails") })] }), _jsx(CardDescription, { children: t("viewSectionAddressInformation") })] }), _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 md:col-span-2", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldAddress") }), _jsx("p", { className: "text-base", children: formatValue(address) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCity") }), _jsx("p", { className: "text-base", children: formatValue(city) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldState") }), _jsx("p", { className: "text-base", children: formatValue(provinceState) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldCountry") }), _jsx("p", { className: "text-base", children: formatValue(country) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldPostalCode") }), _jsx("p", { className: "text-base", children: formatValue(postalCode) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FileText, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionOfficeUse") })] }), _jsx(CardDescription, { children: t("viewSectionInternalNotesAndProcessingInformation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldNotes") }), _jsx("p", { className: "text-base", children: formatValue(notes) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldAdmissionNotes") }), _jsx("p", { className: "text-base", children: formatValue(admissionNotes) })] })] }) })] }), _jsxs(Card, { children: [_jsx(CardHeader, { className: "pb-3", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FileText, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionDocumentsLabel") })] }) }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: documents && documents.length > 0 ? (_jsx("div", { className: "space-y-2", children: documents.map((url, idx) => {
|
|
61
|
+
var _a;
|
|
62
|
+
const fileName = ((_a = url.split("/").pop()) === null || _a === void 0 ? void 0 : _a.split("-").slice(1).join("-")) || url;
|
|
63
|
+
return (_jsxs("div", { className: "flex items-center justify-between gap-3 rounded-lg border bg-muted/50 p-3", children: [_jsxs("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "text-sm truncate flex-1 hover:underline", children: [fileName, _jsx(ExternalLink, { className: "ml-2 inline h-3.5 w-3.5 text-muted-foreground" })] }), _jsx(Button, { type: "button", size: "icon", variant: "ghost", className: "h-8 w-8 shrink-0", "aria-label": "Remove document", onClick: () => handleRemoveDocument(url), children: _jsx(Trash2, { className: "h-4 w-4" }) })] }, `${url}-${idx}`));
|
|
64
|
+
}) })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: t("viewTextNoDocuments") })) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Calendar, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionRecordStatus") })] }), _jsx(CardDescription, { children: t("viewFieldRecordStateAndMetadata") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldEnabled") }), _jsxs(Badge, { variant: enabled ? "default" : "destructive", className: "gap-1", children: [enabled ? (_jsx(CheckCircle2, { className: "h-3 w-3" })) : (_jsx(XCircle, { className: "h-3 w-3" })), enabled ? t("badgeActive") : t("badgeInactive")] })] }) })] })] }));
|
|
61
65
|
};
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { PAYMENT_STATUS } from "../../type";
|
|
10
10
|
export declare const pageLimit: number;
|
|
11
|
+
export declare const filterDateDefaults: () => {
|
|
12
|
+
filterFromDate: string;
|
|
13
|
+
filterToDate: string;
|
|
14
|
+
};
|
|
11
15
|
export declare const PAYMENT_STATUS_OPTIONS: {
|
|
12
16
|
label: string;
|
|
13
17
|
value: PAYMENT_STATUS;
|
|
@@ -12,6 +12,19 @@ import { PAYMENT_STATUS } from "../../type";
|
|
|
12
12
|
// ============================================================================
|
|
13
13
|
export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
14
14
|
// ============================================================================
|
|
15
|
+
// FILTER DATE DEFAULTS
|
|
16
|
+
// ============================================================================
|
|
17
|
+
export const filterDateDefaults = () => {
|
|
18
|
+
const now = new Date();
|
|
19
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
20
|
+
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
|
21
|
+
const toISODate = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
22
|
+
return {
|
|
23
|
+
filterFromDate: toISODate(start),
|
|
24
|
+
filterToDate: toISODate(end),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
// ============================================================================
|
|
15
28
|
// STATUS OPTIONS
|
|
16
29
|
// ============================================================================
|
|
17
30
|
export const PAYMENT_STATUS_OPTIONS = [
|