@appcorp/fusion-storybook 0.3.68 → 0.3.71
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/student-fee/context/shared.d.ts +10 -0
- package/base-modules/student-fee/context/shared.js +4 -1
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +2 -0
- package/base-modules/student-fee/context/use-student-fee-module.js +48 -40
- package/base-modules/student-fee/form.js +5 -3
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -56,6 +56,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
56
56
|
studentProfileId: string;
|
|
57
57
|
filterEnabled: boolean | undefined;
|
|
58
58
|
filterStatus: PAYMENT_STATUS | "";
|
|
59
|
+
appliedFilterEnabled: boolean | undefined;
|
|
60
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
59
61
|
}>, initialStudentFeeState: {
|
|
60
62
|
items: StudentFeeBE[];
|
|
61
63
|
count: number;
|
|
@@ -87,6 +89,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
87
89
|
studentProfileId: string;
|
|
88
90
|
filterEnabled: boolean | undefined;
|
|
89
91
|
filterStatus: PAYMENT_STATUS | "";
|
|
92
|
+
appliedFilterEnabled: boolean | undefined;
|
|
93
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
90
94
|
}, StudentFeeProvider: import("react").FC<{
|
|
91
95
|
children: React.ReactNode;
|
|
92
96
|
}>, studentFeeReducer: (state: {
|
|
@@ -120,6 +124,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
120
124
|
studentProfileId: string;
|
|
121
125
|
filterEnabled: boolean | undefined;
|
|
122
126
|
filterStatus: PAYMENT_STATUS | "";
|
|
127
|
+
appliedFilterEnabled: boolean | undefined;
|
|
128
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
123
129
|
}, action: any) => {
|
|
124
130
|
items: StudentFeeBE[];
|
|
125
131
|
count: number;
|
|
@@ -151,6 +157,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
151
157
|
studentProfileId: string;
|
|
152
158
|
filterEnabled: boolean | undefined;
|
|
153
159
|
filterStatus: PAYMENT_STATUS | "";
|
|
160
|
+
appliedFilterEnabled: boolean | undefined;
|
|
161
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
154
162
|
}, useStudentFeeContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
155
163
|
items: StudentFeeBE[];
|
|
156
164
|
count: number;
|
|
@@ -182,4 +190,6 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
182
190
|
studentProfileId: string;
|
|
183
191
|
filterEnabled: boolean | undefined;
|
|
184
192
|
filterStatus: PAYMENT_STATUS | "";
|
|
193
|
+
appliedFilterEnabled: boolean | undefined;
|
|
194
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
185
195
|
}>;
|
|
@@ -57,9 +57,12 @@ const studentFeeConfig = {
|
|
|
57
57
|
schoolId: "",
|
|
58
58
|
status: PAYMENT_STATUS.PENDING,
|
|
59
59
|
studentProfileId: "",
|
|
60
|
-
// Filters
|
|
60
|
+
// Filters (pending — updated immediately by UI)
|
|
61
61
|
filterEnabled: undefined,
|
|
62
62
|
filterStatus: "",
|
|
63
|
+
// Applied filters (only updated on "Apply" / "Clear")
|
|
64
|
+
appliedFilterEnabled: undefined,
|
|
65
|
+
appliedFilterStatus: "",
|
|
63
66
|
},
|
|
64
67
|
};
|
|
65
68
|
// ============================================================================
|
|
@@ -68,6 +68,8 @@ export declare const useStudentFeeModule: () => {
|
|
|
68
68
|
studentProfileId: string;
|
|
69
69
|
filterEnabled: boolean | undefined;
|
|
70
70
|
filterStatus: PAYMENT_STATUS | "";
|
|
71
|
+
appliedFilterEnabled: boolean | undefined;
|
|
72
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
71
73
|
};
|
|
72
74
|
dispatch: React.Dispatch<any>;
|
|
73
75
|
};
|
|
@@ -31,7 +31,7 @@ export const useStudentFeeModule = () => {
|
|
|
31
31
|
// ============================================================================
|
|
32
32
|
// 1.4.1 STATE & CORE HOOKS
|
|
33
33
|
// ============================================================================
|
|
34
|
-
var _a, _b, _c, _d
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
35
|
const context = useStudentFeeContext();
|
|
36
36
|
const { dispatch } = context;
|
|
37
37
|
const state = context.state;
|
|
@@ -40,42 +40,39 @@ export const useStudentFeeModule = () => {
|
|
|
40
40
|
const workspace = getCachedWorkspaceSync();
|
|
41
41
|
const listFetchNowRef = useRef(null);
|
|
42
42
|
const debouncedQuery = useDebounce(state.searchQuery, 800);
|
|
43
|
+
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
43
44
|
// ============================================================================
|
|
44
45
|
// 1.4.2 API PARAMETERS
|
|
45
46
|
// ============================================================================
|
|
46
|
-
const listParams = useMemo(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const listParams = useMemo(() => (Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.appliedFilterEnabled !== undefined
|
|
48
|
+
? { filterEnabled: String(state.appliedFilterEnabled) }
|
|
49
|
+
: {})), (state.appliedFilterStatus
|
|
50
|
+
? { status: state.appliedFilterStatus }
|
|
51
|
+
: {}))), [
|
|
52
|
+
state.appliedFilterEnabled,
|
|
53
|
+
state.appliedFilterStatus,
|
|
52
54
|
state.currentPage,
|
|
53
|
-
state.filterEnabled,
|
|
54
|
-
state.filterStatus,
|
|
55
55
|
state.pageLimit,
|
|
56
56
|
debouncedQuery,
|
|
57
|
-
|
|
57
|
+
schoolId,
|
|
58
58
|
]);
|
|
59
|
-
const updateParams = useMemo(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
studentProfileId: state.studentProfileId,
|
|
77
|
-
});
|
|
78
|
-
}, [state, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id]);
|
|
59
|
+
const updateParams = useMemo(() => ({
|
|
60
|
+
amount: Number(state.amount),
|
|
61
|
+
amountDue: Number(state.amountDue),
|
|
62
|
+
amountPaid: Number(state.amountPaid),
|
|
63
|
+
discountAmount: Number(state.discountAmount),
|
|
64
|
+
discountCodeId: state.discountCodeId,
|
|
65
|
+
dueDate: state.dueDate,
|
|
66
|
+
enabled: state.enabled,
|
|
67
|
+
familyId: state.familyId,
|
|
68
|
+
feeStructureId: state.feeStructureId,
|
|
69
|
+
id: state.id,
|
|
70
|
+
paidAt: state.paidAt || null,
|
|
71
|
+
remarks: state.remarks || null,
|
|
72
|
+
schoolId,
|
|
73
|
+
status: state.status,
|
|
74
|
+
studentProfileId: state.studentProfileId,
|
|
75
|
+
}), [state, schoolId]);
|
|
79
76
|
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
80
77
|
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
81
78
|
// ============================================================================
|
|
@@ -146,7 +143,7 @@ export const useStudentFeeModule = () => {
|
|
|
146
143
|
},
|
|
147
144
|
},
|
|
148
145
|
});
|
|
149
|
-
}, [dispatch, workspace === null || workspace === void 0 ? void 0 : workspace.dueDateLength, (
|
|
146
|
+
}, [dispatch, workspace === null || workspace === void 0 ? void 0 : workspace.dueDateLength, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id]);
|
|
150
147
|
// ============================================================================
|
|
151
148
|
// 1.4.4 API CALLBACKS
|
|
152
149
|
// ============================================================================
|
|
@@ -501,17 +498,30 @@ export const useStudentFeeModule = () => {
|
|
|
501
498
|
});
|
|
502
499
|
}, [dispatch]);
|
|
503
500
|
const applyFilters = useCallback(() => {
|
|
501
|
+
dispatch({
|
|
502
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
503
|
+
payload: { key: "appliedFilterEnabled", value: state.filterEnabled },
|
|
504
|
+
});
|
|
505
|
+
dispatch({
|
|
506
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
507
|
+
payload: { key: "appliedFilterStatus", value: state.filterStatus },
|
|
508
|
+
});
|
|
504
509
|
dispatch({
|
|
505
510
|
type: STUDENT_FEE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
506
511
|
payload: { currentPage: 1 },
|
|
507
512
|
});
|
|
508
513
|
closeDrawer();
|
|
509
|
-
}, [dispatch, closeDrawer]);
|
|
514
|
+
}, [dispatch, closeDrawer, state.filterEnabled, state.filterStatus]);
|
|
510
515
|
const clearFilters = useCallback(() => {
|
|
511
516
|
dispatch({
|
|
512
517
|
type: STUDENT_FEE_ACTION_TYPES.SET_FILTERS,
|
|
513
518
|
payload: {
|
|
514
|
-
filters: {
|
|
519
|
+
filters: {
|
|
520
|
+
filterEnabled: undefined,
|
|
521
|
+
filterStatus: "",
|
|
522
|
+
appliedFilterEnabled: undefined,
|
|
523
|
+
appliedFilterStatus: "",
|
|
524
|
+
},
|
|
515
525
|
},
|
|
516
526
|
});
|
|
517
527
|
dispatch({
|
|
@@ -563,7 +573,7 @@ export const useStudentFeeModule = () => {
|
|
|
563
573
|
payload: { disabled: false },
|
|
564
574
|
});
|
|
565
575
|
}
|
|
566
|
-
}, [dispatch, showToast, t, (
|
|
576
|
+
}, [dispatch, showToast, t, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id, resetFormAndCloseDrawer]);
|
|
567
577
|
const handleSubmit = useCallback(() => {
|
|
568
578
|
dispatch({
|
|
569
579
|
type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
@@ -628,7 +638,7 @@ export const useStudentFeeModule = () => {
|
|
|
628
638
|
payload: { disabled: false },
|
|
629
639
|
});
|
|
630
640
|
}
|
|
631
|
-
}, [dispatch, showToast, t, (
|
|
641
|
+
}, [dispatch, showToast, t, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id, resetFormAndCloseDrawer]);
|
|
632
642
|
// ============================================================================
|
|
633
643
|
// 1.4.8 HEADER & ROW ACTIONS
|
|
634
644
|
// ============================================================================
|
|
@@ -680,11 +690,9 @@ export const useStudentFeeModule = () => {
|
|
|
680
690
|
listFetchNowRef.current = listFetchNow;
|
|
681
691
|
}, [listFetchNow]);
|
|
682
692
|
useEffect(() => {
|
|
683
|
-
var _a
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
687
|
-
}, [dispatch, listParams, (_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id, showToast, t]);
|
|
693
|
+
var _a;
|
|
694
|
+
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
695
|
+
}, [listParams]);
|
|
688
696
|
// ============================================================================
|
|
689
697
|
// 1.4.10 RETURN
|
|
690
698
|
// ============================================================================
|
|
@@ -11,7 +11,7 @@ import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
|
11
11
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
12
12
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
13
13
|
import { useEffect } from "react";
|
|
14
|
-
import { useStudentFeeModule } from "./context";
|
|
14
|
+
import { useStudentFeeModule, STUDENT_FEE_DRAWER } from "./context";
|
|
15
15
|
import { PAYMENT_STATUS_OPTIONS } from "./constants";
|
|
16
16
|
import { STUDENT_FEE_API_ROUTES, DISCOUNT_CODE_API_ROUTES, FEE_STRUCTURE_API_ROUTES, STUDENT_PROFILE_API_ROUTES, } from "../../constants";
|
|
17
17
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
@@ -24,7 +24,7 @@ import { getTranslatedError } from "../../utils/get-translated-error";
|
|
|
24
24
|
export const StudentFeeForm = () => {
|
|
25
25
|
var _a, _b, _c, _d, _e;
|
|
26
26
|
const { state, handleChange } = useStudentFeeModule();
|
|
27
|
-
const { amount, amountDue, amountPaid, discountAmount, discountCodeId, dueDate, enabled, errors, feeStructureId, paidAt, remarks, status, studentProfileId, } = state;
|
|
27
|
+
const { amount, amountDue, amountPaid, discountAmount, discountCodeId, drawer, dueDate, enabled, errors, feeStructureId, paidAt, remarks, status, studentProfileId, } = state;
|
|
28
28
|
const workspace = getCachedWorkspaceSync();
|
|
29
29
|
const currency = (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : "";
|
|
30
30
|
const t = useTranslations("studentFee");
|
|
@@ -49,11 +49,13 @@ export const StudentFeeForm = () => {
|
|
|
49
49
|
method: API_METHODS.GET,
|
|
50
50
|
});
|
|
51
51
|
useEffect(() => {
|
|
52
|
+
if (drawer !== STUDENT_FEE_DRAWER.FORM_DRAWER)
|
|
53
|
+
return;
|
|
52
54
|
studentProfileFetchNow();
|
|
53
55
|
feeStructureFetchNow();
|
|
54
56
|
discountCodeFetchNow();
|
|
55
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
-
}, []);
|
|
58
|
+
}, [drawer]);
|
|
57
59
|
const { enhancedComboboxElement: studentProfileIdCombo } = useEnhancedCombobox({
|
|
58
60
|
emptyText: t("formNoStudentEmpty"),
|
|
59
61
|
id: "studentProfileId",
|