@appcorp/fusion-storybook 0.3.91 → 0.3.93
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/expense/context/expense-api-provider.js +1 -6
- package/base-modules/expense/context/use-expense-module.js +36 -3
- package/base-modules/expense/page.d.ts +1 -4
- package/base-modules/expense/page.js +5 -7
- package/base-modules/fee-structure/context/fee-structure-api-provider.js +1 -9
- package/base-modules/fee-structure/context/use-fee-structure-module.js +19 -3
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -72,13 +72,8 @@ export const ExpenseApiProvider = ({ children, }) => {
|
|
|
72
72
|
// ==========================================================================
|
|
73
73
|
// API PARAMETERS
|
|
74
74
|
// ==========================================================================
|
|
75
|
-
const listParams = useMemo(() => (Object.assign(
|
|
76
|
-
? { filterEnabled: state.filterEnabled }
|
|
77
|
-
: {}))), [
|
|
75
|
+
const listParams = useMemo(() => (Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {}))), [
|
|
78
76
|
state.currentPage,
|
|
79
|
-
state.filterCategory,
|
|
80
|
-
state.filterEnabled,
|
|
81
|
-
state.filterStatus,
|
|
82
77
|
state.pageLimit,
|
|
83
78
|
debouncedQuery,
|
|
84
79
|
schoolId,
|
|
@@ -149,12 +149,38 @@ export const useExpenseModule = () => {
|
|
|
149
149
|
});
|
|
150
150
|
}, [dispatch]);
|
|
151
151
|
const applyFilters = useCallback(() => {
|
|
152
|
+
closeDrawer();
|
|
153
|
+
dispatch({
|
|
154
|
+
type: EXPENSE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
155
|
+
payload: { key: "filterCategory", value: state.filterCategory },
|
|
156
|
+
});
|
|
157
|
+
dispatch({
|
|
158
|
+
type: EXPENSE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
159
|
+
payload: { key: "filterStatus", value: state.filterStatus },
|
|
160
|
+
});
|
|
161
|
+
dispatch({
|
|
162
|
+
type: EXPENSE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
163
|
+
payload: { key: "filterEnabled", value: state.filterEnabled },
|
|
164
|
+
});
|
|
152
165
|
dispatch({
|
|
153
166
|
type: EXPENSE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
154
167
|
payload: { currentPage: 1 },
|
|
155
168
|
});
|
|
156
|
-
|
|
157
|
-
|
|
169
|
+
listFetchNow === null || listFetchNow === void 0 ? void 0 : listFetchNow(undefined, {
|
|
170
|
+
params: Object.assign(Object.assign(Object.assign({ currentPage: 1, pageLimit: state.pageLimit, schoolId }, (state.filterCategory && { filterCategory: state.filterCategory })), (state.filterStatus && { filterStatus: state.filterStatus })), (state.filterEnabled !== undefined && {
|
|
171
|
+
filterEnabled: state.filterEnabled,
|
|
172
|
+
})),
|
|
173
|
+
});
|
|
174
|
+
}, [
|
|
175
|
+
closeDrawer,
|
|
176
|
+
dispatch,
|
|
177
|
+
listFetchNow,
|
|
178
|
+
schoolId,
|
|
179
|
+
state.filterCategory,
|
|
180
|
+
state.filterEnabled,
|
|
181
|
+
state.filterStatus,
|
|
182
|
+
state.pageLimit,
|
|
183
|
+
]);
|
|
158
184
|
const clearFilters = useCallback(() => {
|
|
159
185
|
dispatch({
|
|
160
186
|
type: EXPENSE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
@@ -170,7 +196,14 @@ export const useExpenseModule = () => {
|
|
|
170
196
|
},
|
|
171
197
|
},
|
|
172
198
|
});
|
|
173
|
-
|
|
199
|
+
listFetchNow(undefined, {
|
|
200
|
+
params: {
|
|
201
|
+
currentPage: 1,
|
|
202
|
+
pageLimit: state.pageLimit,
|
|
203
|
+
schoolId,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
}, [dispatch, listFetchNow, state.pageLimit, schoolId]);
|
|
174
207
|
// ============================================================================
|
|
175
208
|
// 1.4.5 NETWORK ACTIONS
|
|
176
209
|
// ============================================================================
|
|
@@ -15,10 +15,7 @@
|
|
|
15
15
|
import { FC } from "react";
|
|
16
16
|
import { USER_ROLE } from "../../type";
|
|
17
17
|
interface ConfigProps {
|
|
18
|
-
|
|
19
|
-
type: string;
|
|
20
|
-
payload?: unknown;
|
|
21
|
-
}>;
|
|
18
|
+
clearFilters: () => void;
|
|
22
19
|
drawerButtonCancel: string;
|
|
23
20
|
drawerButtonSave: string;
|
|
24
21
|
drawerFilterDescription: string;
|
|
@@ -18,7 +18,7 @@ import { useMemo } from "react";
|
|
|
18
18
|
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
19
19
|
import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
|
|
20
20
|
import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
|
|
21
|
-
import { useExpenseModule, ExpenseProvider, ExpenseApiProvider,
|
|
21
|
+
import { useExpenseModule, ExpenseProvider, ExpenseApiProvider, } from "./context";
|
|
22
22
|
import { ExpenseFilter } from "./filter";
|
|
23
23
|
import { ExpenseForm } from "./form";
|
|
24
24
|
import { ExpenseMoreActions } from "./more-actions";
|
|
@@ -64,7 +64,7 @@ const createComponentInstances = () => ({
|
|
|
64
64
|
moreActions: _jsx(ExpenseMoreActions, {}),
|
|
65
65
|
view: _jsx(ExpenseView, {}),
|
|
66
66
|
});
|
|
67
|
-
const createExpenseConfig = ({
|
|
67
|
+
const createExpenseConfig = ({ clearFilters, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderAmount, tableColumnHeaderCategory, tableColumnHeaderExpenseDate, tableColumnHeaderId, tableColumnHeaderStatus, tableColumnHeaderTitle, tableColumnHeaderVendorName, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
|
|
68
68
|
const components = createComponentInstances();
|
|
69
69
|
return {
|
|
70
70
|
moduleName: "expense",
|
|
@@ -95,9 +95,7 @@ const createExpenseConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, d
|
|
|
95
95
|
tableDescription,
|
|
96
96
|
tableTitle,
|
|
97
97
|
viewContent: components.view,
|
|
98
|
-
onClearFilters:
|
|
99
|
-
dispatch({ type: EXPENSE_ACTION_TYPES.RESET_FORM });
|
|
100
|
-
},
|
|
98
|
+
onClearFilters: clearFilters,
|
|
101
99
|
};
|
|
102
100
|
};
|
|
103
101
|
// ============================================================================
|
|
@@ -111,7 +109,7 @@ const ExpensePageInner = (props) => {
|
|
|
111
109
|
const context = useExpenseModule();
|
|
112
110
|
// Memoize config creation - destructure props to avoid object reference changes
|
|
113
111
|
const expenseConfig = useMemo(() => createExpenseConfig({
|
|
114
|
-
|
|
112
|
+
clearFilters: context.clearFilters,
|
|
115
113
|
drawerButtonCancel: props.drawerButtonCancel,
|
|
116
114
|
drawerButtonSave: props.drawerButtonSave,
|
|
117
115
|
drawerFormTitle: props.drawerFormTitle,
|
|
@@ -134,7 +132,7 @@ const ExpensePageInner = (props) => {
|
|
|
134
132
|
tableSearchPlaceholder: props.tableSearchPlaceholder,
|
|
135
133
|
tableTitle: props.tableTitle,
|
|
136
134
|
}), [
|
|
137
|
-
context.
|
|
135
|
+
context.clearFilters,
|
|
138
136
|
props.drawerButtonCancel,
|
|
139
137
|
props.drawerButtonSave,
|
|
140
138
|
props.drawerFormTitle,
|
|
@@ -62,15 +62,7 @@ export const FeeStructureApiProvider = ({ children, }) => {
|
|
|
62
62
|
// ==========================================================================
|
|
63
63
|
// API PARAMETERS
|
|
64
64
|
// ==========================================================================
|
|
65
|
-
const listParams = useMemo(() => (Object.assign(
|
|
66
|
-
? { filterEnabled: String(state.filterEnabled) }
|
|
67
|
-
: {}))), [
|
|
68
|
-
state.currentPage,
|
|
69
|
-
state.filterEnabled,
|
|
70
|
-
state.pageLimit,
|
|
71
|
-
debouncedQuery,
|
|
72
|
-
schoolId,
|
|
73
|
-
]);
|
|
65
|
+
const listParams = useMemo(() => (Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {}))), [state.currentPage, state.pageLimit, debouncedQuery, schoolId]);
|
|
74
66
|
const updateParams = useMemo(() => (Object.assign(Object.assign(Object.assign({}, (state.id ? { id: state.id } : {})), (!state.id ? { schoolId } : {})), { amount: Number(state.amount), classId: state.classId || null, description: state.description || null, enabled: state.enabled, feeType: state.feeType, frequency: state.frequency || null, name: state.name })), [state, schoolId]);
|
|
75
67
|
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
76
68
|
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
@@ -128,12 +128,21 @@ export const useFeeStructureModule = () => {
|
|
|
128
128
|
});
|
|
129
129
|
}, [dispatch]);
|
|
130
130
|
const applyFilters = useCallback(() => {
|
|
131
|
+
closeDrawer();
|
|
132
|
+
dispatch({
|
|
133
|
+
type: FEE_STRUCTURE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
134
|
+
payload: { key: "filterEnabled", value: state.filterEnabled },
|
|
135
|
+
});
|
|
131
136
|
dispatch({
|
|
132
137
|
type: FEE_STRUCTURE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
133
138
|
payload: { currentPage: 1 },
|
|
134
139
|
});
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
listFetchNow === null || listFetchNow === void 0 ? void 0 : listFetchNow(undefined, {
|
|
141
|
+
params: Object.assign({ currentPage: 1, pageLimit: state.pageLimit, schoolId }, (state.filterEnabled !== undefined
|
|
142
|
+
? { filterEnabled: String(state.filterEnabled) }
|
|
143
|
+
: {})),
|
|
144
|
+
});
|
|
145
|
+
}, [closeDrawer, dispatch, listFetchNow, schoolId, state.filterEnabled, state.pageLimit]);
|
|
137
146
|
const clearFilters = useCallback(() => {
|
|
138
147
|
dispatch({
|
|
139
148
|
type: FEE_STRUCTURE_ACTION_TYPES.SET_FILTERS,
|
|
@@ -143,7 +152,14 @@ export const useFeeStructureModule = () => {
|
|
|
143
152
|
type: FEE_STRUCTURE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
144
153
|
payload: { currentPage: 1 },
|
|
145
154
|
});
|
|
146
|
-
|
|
155
|
+
listFetchNow === null || listFetchNow === void 0 ? void 0 : listFetchNow(undefined, {
|
|
156
|
+
params: {
|
|
157
|
+
currentPage: 1,
|
|
158
|
+
pageLimit: state.pageLimit,
|
|
159
|
+
schoolId,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}, [dispatch, listFetchNow, state.pageLimit, schoolId]);
|
|
147
163
|
const toggleStatus = useCallback((row) => {
|
|
148
164
|
updateFetchNow(undefined, {
|
|
149
165
|
body: JSON.stringify(Object.assign(Object.assign({}, row), { enabled: !(row === null || row === void 0 ? void 0 : row.enabled) })),
|