@appcorp/fusion-storybook 0.3.12 → 0.3.14
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.
|
@@ -7,7 +7,7 @@ export declare const useStudentFeeModule: () => {
|
|
|
7
7
|
clearSearch: () => void;
|
|
8
8
|
closeDrawer: () => void;
|
|
9
9
|
deleteLoading: boolean;
|
|
10
|
-
handleChange: (field: string, value: string | number | boolean | PAYMENT_STATUS | FEE_RISK_LEVEL | null | undefined) => void
|
|
10
|
+
handleChange: (field: string, value: string | number | boolean | PAYMENT_STATUS | FEE_RISK_LEVEL | null | undefined) => Promise<void>;
|
|
11
11
|
handleCreate: () => void;
|
|
12
12
|
handleCreateMonthly: () => void;
|
|
13
13
|
handleCreateSingleEntry: () => void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { useTheme } from "next-themes";
|
|
4
4
|
import { useTranslations } from "next-intl";
|
|
5
|
-
import { validateForm, isCreatedOrUpdated, } from "@react-pakistan/util-functions";
|
|
5
|
+
import { validateForm, isCreatedOrUpdated, API_METHODS, fetchData, } from "@react-pakistan/util-functions";
|
|
6
6
|
import { useModuleEntityV2, } from "@react-pakistan/util-functions/hooks/use-module-entity-v2";
|
|
7
7
|
import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
|
|
8
8
|
import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
|
|
@@ -29,7 +29,7 @@ export const useStudentFeeModule = () => {
|
|
|
29
29
|
// ============================================================================
|
|
30
30
|
// 1.4.1 STATE & CORE HOOKS
|
|
31
31
|
// ============================================================================
|
|
32
|
-
var _a, _b, _c, _d, _e;
|
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
|
33
33
|
const context = useStudentFeeContext();
|
|
34
34
|
const { dispatch } = context;
|
|
35
35
|
const state = context.state;
|
|
@@ -230,7 +230,7 @@ export const useStudentFeeModule = () => {
|
|
|
230
230
|
// ============================================================================
|
|
231
231
|
// 1.4.6 HANDLERS
|
|
232
232
|
// ============================================================================
|
|
233
|
-
const handleChange = useCallback((field, value) => {
|
|
233
|
+
const handleChange = useCallback(async (field, value) => {
|
|
234
234
|
var _a, _b, _c, _d, _e;
|
|
235
235
|
dispatch({
|
|
236
236
|
type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
|
|
@@ -287,12 +287,19 @@ export const useStudentFeeModule = () => {
|
|
|
287
287
|
}
|
|
288
288
|
if (field === "studentProfileId" && typeof value === "string" && value) {
|
|
289
289
|
try {
|
|
290
|
-
const
|
|
290
|
+
const { data } = await fetchData({
|
|
291
|
+
url: "/api/v1/student-profile",
|
|
292
|
+
method: API_METHODS.GET,
|
|
293
|
+
headers: { "Content-Type": "application/json" },
|
|
294
|
+
params: { id: value, schoolId: (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id },
|
|
295
|
+
});
|
|
296
|
+
const familyId = (data === null || data === void 0 ? void 0 : data.studentProfile.familyMember.familyId) || "";
|
|
297
|
+
const studentProfile = (_c = getCachedStudentProfilesSync().items) === null || _c === void 0 ? void 0 : _c.find((s) => s.id === value);
|
|
291
298
|
dispatch({
|
|
292
299
|
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
293
300
|
payload: {
|
|
294
301
|
key: "familyId",
|
|
295
|
-
value:
|
|
302
|
+
value: familyId,
|
|
296
303
|
},
|
|
297
304
|
});
|
|
298
305
|
if (studentProfile === null || studentProfile === void 0 ? void 0 : studentProfile.discountCode) {
|
|
@@ -423,7 +430,7 @@ export const useStudentFeeModule = () => {
|
|
|
423
430
|
payload: { key: "amountDue", value: amountDue },
|
|
424
431
|
});
|
|
425
432
|
}
|
|
426
|
-
}, [dispatch, state]);
|
|
433
|
+
}, [dispatch, state, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
|
|
427
434
|
const handlePageChange = useCallback((page) => {
|
|
428
435
|
const nextPage = typeof page === "number" ? page : state.currentPage + 1;
|
|
429
436
|
dispatch({
|
|
@@ -577,7 +584,7 @@ export const useStudentFeeModule = () => {
|
|
|
577
584
|
payload: { disabled: false },
|
|
578
585
|
});
|
|
579
586
|
}
|
|
580
|
-
}, [dispatch, showToast, t, (
|
|
587
|
+
}, [dispatch, showToast, t, (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id, resetFormAndCloseDrawer]);
|
|
581
588
|
const handleSubmit = useCallback(() => {
|
|
582
589
|
dispatch({
|
|
583
590
|
type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
@@ -592,7 +599,6 @@ export const useStudentFeeModule = () => {
|
|
|
592
599
|
});
|
|
593
600
|
},
|
|
594
601
|
errorCallback: (errors) => {
|
|
595
|
-
console.log("errors", errors);
|
|
596
602
|
dispatch({
|
|
597
603
|
type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
|
|
598
604
|
payload: { errors },
|
|
@@ -679,7 +685,7 @@ export const useStudentFeeModule = () => {
|
|
|
679
685
|
if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
|
|
680
686
|
return;
|
|
681
687
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
682
|
-
}, [dispatch, listParams, (
|
|
688
|
+
}, [dispatch, listParams, (_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id, showToast, t]);
|
|
683
689
|
// ============================================================================
|
|
684
690
|
// 1.4.10 RETURN
|
|
685
691
|
// ============================================================================
|