@appcorp/fusion-storybook 0.3.66 → 0.3.67
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 -1
- package/base-modules/student-fee/context/use-student-fee-module.js +30 -30
- package/base-modules/student-fee/filter.js +9 -18
- 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
|
// ============================================================================
|
|
@@ -14,7 +14,6 @@ export declare const useStudentFeeModule: () => {
|
|
|
14
14
|
handleDelete: (row?: TableRow) => void;
|
|
15
15
|
handleEdit: (row?: TableRow) => void;
|
|
16
16
|
handleFilters: () => void;
|
|
17
|
-
setPendingFilter: (field: string, value: boolean | undefined | string) => void;
|
|
18
17
|
handleMoreActions: () => void;
|
|
19
18
|
handlePageChange: (page: number | unknown) => void;
|
|
20
19
|
handlePageLimitChange: (k: string, value: object) => void;
|
|
@@ -69,6 +68,8 @@ export declare const useStudentFeeModule: () => {
|
|
|
69
68
|
studentProfileId: string;
|
|
70
69
|
filterEnabled: boolean | undefined;
|
|
71
70
|
filterStatus: PAYMENT_STATUS | "";
|
|
71
|
+
appliedFilterEnabled: boolean | undefined;
|
|
72
|
+
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
72
73
|
};
|
|
73
74
|
dispatch: React.Dispatch<any>;
|
|
74
75
|
};
|
|
@@ -40,25 +40,20 @@ export const useStudentFeeModule = () => {
|
|
|
40
40
|
const workspace = getCachedWorkspaceSync();
|
|
41
41
|
const listFetchNowRef = useRef(null);
|
|
42
42
|
const debouncedQuery = useDebounce(state.searchQuery, 800);
|
|
43
|
-
const pendingFiltersRef = useRef({
|
|
44
|
-
filterEnabled: state.filterEnabled,
|
|
45
|
-
filterStatus: state.filterStatus || "",
|
|
46
|
-
});
|
|
47
|
-
const setPendingFilter = useCallback((field, value) => {
|
|
48
|
-
pendingFiltersRef.current = Object.assign(Object.assign({}, pendingFiltersRef.current), { [field]: value });
|
|
49
|
-
}, []);
|
|
50
43
|
// ============================================================================
|
|
51
44
|
// 1.4.2 API PARAMETERS
|
|
52
45
|
// ============================================================================
|
|
53
46
|
const listParams = useMemo(() => {
|
|
54
47
|
var _a;
|
|
55
|
-
return (Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.
|
|
56
|
-
? { filterEnabled: state.
|
|
57
|
-
: {})), (state.
|
|
48
|
+
return (Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.appliedFilterEnabled !== undefined
|
|
49
|
+
? { filterEnabled: state.appliedFilterEnabled }
|
|
50
|
+
: {})), (state.appliedFilterStatus
|
|
51
|
+
? { status: state.appliedFilterStatus }
|
|
52
|
+
: {})));
|
|
58
53
|
}, [
|
|
59
54
|
state.currentPage,
|
|
60
|
-
state.
|
|
61
|
-
state.
|
|
55
|
+
state.appliedFilterEnabled,
|
|
56
|
+
state.appliedFilterStatus,
|
|
62
57
|
state.pageLimit,
|
|
63
58
|
debouncedQuery,
|
|
64
59
|
(_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
@@ -508,34 +503,40 @@ export const useStudentFeeModule = () => {
|
|
|
508
503
|
});
|
|
509
504
|
}, [dispatch]);
|
|
510
505
|
const applyFilters = useCallback(() => {
|
|
511
|
-
const pending = pendingFiltersRef.current;
|
|
512
506
|
dispatch({
|
|
513
|
-
type: STUDENT_FEE_ACTION_TYPES.
|
|
514
|
-
payload: {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
},
|
|
507
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
508
|
+
payload: { key: "appliedFilterEnabled", value: state.filterEnabled },
|
|
509
|
+
});
|
|
510
|
+
dispatch({
|
|
511
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
512
|
+
payload: { key: "appliedFilterStatus", value: state.filterStatus },
|
|
520
513
|
});
|
|
521
514
|
dispatch({
|
|
522
515
|
type: STUDENT_FEE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
523
516
|
payload: { currentPage: 1 },
|
|
524
517
|
});
|
|
525
518
|
closeDrawer();
|
|
526
|
-
}, [dispatch, closeDrawer]);
|
|
519
|
+
}, [dispatch, closeDrawer, state.filterEnabled, state.filterStatus]);
|
|
527
520
|
const clearFilters = useCallback(() => {
|
|
528
|
-
pendingFiltersRef.current = {
|
|
529
|
-
filterEnabled: undefined,
|
|
530
|
-
filterStatus: "",
|
|
531
|
-
};
|
|
532
521
|
dispatch({
|
|
533
|
-
type: STUDENT_FEE_ACTION_TYPES.
|
|
534
|
-
payload: {
|
|
522
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
523
|
+
payload: { key: "filterEnabled", value: undefined },
|
|
535
524
|
});
|
|
536
525
|
dispatch({
|
|
537
|
-
type: STUDENT_FEE_ACTION_TYPES.
|
|
538
|
-
payload: {
|
|
526
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
527
|
+
payload: { key: "filterStatus", value: "" },
|
|
528
|
+
});
|
|
529
|
+
dispatch({
|
|
530
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
531
|
+
payload: { key: "appliedFilterEnabled", value: undefined },
|
|
532
|
+
});
|
|
533
|
+
dispatch({
|
|
534
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
535
|
+
payload: { key: "appliedFilterStatus", value: "" },
|
|
536
|
+
});
|
|
537
|
+
dispatch({
|
|
538
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
539
|
+
payload: { currentPage: 1 },
|
|
539
540
|
});
|
|
540
541
|
}, [dispatch]);
|
|
541
542
|
const handleSearch = useCallback((query) => {
|
|
@@ -720,7 +721,6 @@ export const useStudentFeeModule = () => {
|
|
|
720
721
|
handleDelete,
|
|
721
722
|
handleEdit,
|
|
722
723
|
handleFilters,
|
|
723
|
-
setPendingFilter,
|
|
724
724
|
handleMoreActions,
|
|
725
725
|
handlePageChange,
|
|
726
726
|
handlePageLimitChange,
|
|
@@ -6,7 +6,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* Filter UI for the student-fee list. Supports filterEnabled (radio) and
|
|
7
7
|
* filterStatus (payment status combobox).
|
|
8
8
|
*/
|
|
9
|
-
import { useState } from "react";
|
|
10
9
|
import { EnhancedRadio } from "@appcorp/shadcn/components/enhanced-radio";
|
|
11
10
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
12
11
|
import { useStudentFeeModule } from "./context";
|
|
@@ -14,11 +13,9 @@ import { PAYMENT_STATUS_OPTIONS } from "./constants";
|
|
|
14
13
|
import { STUDENT_FEE_API_ROUTES } from "../../constants";
|
|
15
14
|
import { useTranslations } from "next-intl";
|
|
16
15
|
export const StudentFeeFilter = () => {
|
|
17
|
-
const { state,
|
|
16
|
+
const { state, handleChange } = useStudentFeeModule();
|
|
18
17
|
const { filterEnabled, filterStatus } = state;
|
|
19
18
|
const t = useTranslations("studentFee");
|
|
20
|
-
const [localFilterEnabled, setLocalFilterEnabled] = useState(filterEnabled);
|
|
21
|
-
const [localFilterStatus, setLocalFilterStatus] = useState(filterStatus || "");
|
|
22
19
|
const paymentStatusLabelMap = {
|
|
23
20
|
PENDING: t("formOptionPending"),
|
|
24
21
|
PARTIAL: t("formOptionPartial"),
|
|
@@ -27,26 +24,17 @@ export const StudentFeeFilter = () => {
|
|
|
27
24
|
CANCELLED: t("formOptionCancelled"),
|
|
28
25
|
REFUNDED: t("formOptionRefunded"),
|
|
29
26
|
};
|
|
30
|
-
const filterEnabledValue =
|
|
27
|
+
const filterEnabledValue = filterEnabled === undefined
|
|
31
28
|
? "undefined"
|
|
32
|
-
:
|
|
29
|
+
: filterEnabled
|
|
33
30
|
? "true"
|
|
34
31
|
: "false";
|
|
35
|
-
const handleStatusChange = (value) => {
|
|
36
|
-
setLocalFilterStatus(value);
|
|
37
|
-
setPendingFilter("filterStatus", value);
|
|
38
|
-
};
|
|
39
|
-
const handleEnabledChange = (next) => {
|
|
40
|
-
const parsed = next === "true" ? true : next === "false" ? false : undefined;
|
|
41
|
-
setLocalFilterEnabled(parsed);
|
|
42
|
-
setPendingFilter("filterEnabled", parsed);
|
|
43
|
-
};
|
|
44
32
|
const { enhancedComboboxElement: filterStatusCombo } = useEnhancedCombobox({
|
|
45
33
|
emptyText: t("filterNoStatusFoundLabel"),
|
|
46
34
|
id: "filterStatus",
|
|
47
35
|
info: t("filterByPaymentStatus"),
|
|
48
36
|
label: t("filterPaymentStatusLabel"),
|
|
49
|
-
onValueChange:
|
|
37
|
+
onValueChange: (value) => handleChange("filterStatus", value),
|
|
50
38
|
options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
|
|
51
39
|
value: opt.value,
|
|
52
40
|
label: paymentStatusLabelMap[opt.value] || opt.label,
|
|
@@ -61,11 +49,14 @@ export const StudentFeeFilter = () => {
|
|
|
61
49
|
value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
|
|
62
50
|
});
|
|
63
51
|
},
|
|
64
|
-
value:
|
|
52
|
+
value: filterStatus || "",
|
|
65
53
|
});
|
|
66
54
|
return (_jsxs("div", { className: "space-y-4", children: [filterStatusCombo, _jsx(EnhancedRadio, { label: t("filterEnabledLabel"), name: "filterEnabled", value: filterEnabledValue, options: [
|
|
67
55
|
{ label: t("filterOptionAll"), value: "undefined" },
|
|
68
56
|
{ label: t("filterOptionEnabled"), value: "true" },
|
|
69
57
|
{ label: t("filterOptionDisabled"), value: "false" },
|
|
70
|
-
], onValueChange:
|
|
58
|
+
], onValueChange: (next) => {
|
|
59
|
+
const parsed = next === "true" ? true : next === "false" ? false : undefined;
|
|
60
|
+
handleChange("filterEnabled", parsed);
|
|
61
|
+
} })] }));
|
|
71
62
|
};
|