@appcorp/fusion-storybook 0.5.23 → 0.5.27
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/student-fee-api-provider.js +20 -14
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +3 -3
- package/base-modules/student-fee/context/use-student-fee-module.js +63 -30
- package/base-modules/student-fee/form.js +8 -24
- package/base-modules/student-fee/more-actions.js +9 -9
- package/base-modules/student-fee/page.js +1 -1
- package/base-modules/student-profile/constants.d.ts +2 -24
- package/base-modules/student-profile/constants.js +2 -68
- package/base-modules/student-profile/context/module-base.d.ts +10 -0
- package/base-modules/student-profile/context/module-base.js +2 -0
- package/base-modules/student-profile/context/use-student-profile-module.d.ts +3 -1
- package/base-modules/student-profile/context/use-student-profile-module.js +113 -71
- package/base-modules/student-profile/filter.js +5 -22
- package/base-modules/student-profile/form.js +22 -46
- package/base-modules/student-profile/page.js +2 -4
- package/base-modules/subject/context.d.ts +7 -0
- package/base-modules/subject/context.js +68 -33
- package/base-modules/subject/form.js +1 -1
- package/base-modules/subject/more-actions.js +34 -13
- package/base-modules/subject/page.js +2 -2
- package/base-modules/subject/validate.js +2 -6
- package/base-modules/subject/view.js +1 -3
- package/base-modules/teacher/context.d.ts +6 -0
- package/base-modules/teacher/context.js +59 -33
- package/base-modules/teacher/date.d.ts +6 -0
- package/base-modules/teacher/date.js +13 -0
- package/base-modules/teacher/form.js +6 -25
- package/base-modules/teacher/more-actions.js +34 -13
- package/base-modules/teacher/validate.js +6 -7
- package/constants.d.ts +0 -2
- package/constants.js +0 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/resolve-rbac-permissions.js +7 -4
- package/base-modules/student-profile/more-actions.d.ts +0 -1
- package/base-modules/student-profile/more-actions.js +0 -257
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, } from "react";
|
|
4
4
|
import { useTheme } from "next-themes";
|
|
5
5
|
import { useTranslations } from "next-intl";
|
|
6
6
|
import { isCreatedOrUpdated } from "@react-pakistan/util-functions/general/is-created-or-updated";
|
|
@@ -113,30 +113,35 @@ export const StudentFeeApiProvider = ({ children, }) => {
|
|
|
113
113
|
state.studentProfileId,
|
|
114
114
|
schoolId,
|
|
115
115
|
]);
|
|
116
|
-
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
117
|
-
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
116
|
+
const byIdParams = useMemo(() => ({ id: state.id, schoolId }), [state.id, schoolId]);
|
|
117
|
+
const deleteParams = useMemo(() => ({ id: state.id, schoolId }), [state.id, schoolId]);
|
|
118
118
|
// ==========================================================================
|
|
119
119
|
// API CALLBACKS
|
|
120
120
|
// ==========================================================================
|
|
121
|
+
const apiError = (data) => data === null || data === void 0 ? void 0 : data.error;
|
|
121
122
|
const listCallback = useCallback(({ data, error }) => {
|
|
122
|
-
var _a, _b;
|
|
123
|
+
var _a, _b, _c;
|
|
123
124
|
if (error) {
|
|
124
|
-
showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
125
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
125
126
|
return;
|
|
126
127
|
}
|
|
127
128
|
if (data) {
|
|
128
129
|
const response = data;
|
|
129
130
|
dispatch({
|
|
130
131
|
type: STUDENT_FEE_ACTION_TYPES.SET_ITEMS,
|
|
131
|
-
payload: { items: (
|
|
132
|
+
payload: { items: (_b = response.items) !== null && _b !== void 0 ? _b : [], count: (_c = response.count) !== null && _c !== void 0 ? _c : 0 },
|
|
132
133
|
});
|
|
133
134
|
}
|
|
134
135
|
}, [dispatch, showToast, t]);
|
|
135
136
|
const listFetchNowRef = useRef(null);
|
|
136
137
|
const updateCallback = useCallback(({ data, error }) => {
|
|
137
|
-
var _a;
|
|
138
|
+
var _a, _b;
|
|
138
139
|
if (error) {
|
|
139
|
-
|
|
140
|
+
dispatch({
|
|
141
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
142
|
+
payload: { disabled: false },
|
|
143
|
+
});
|
|
144
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
140
145
|
return;
|
|
141
146
|
}
|
|
142
147
|
if (data) {
|
|
@@ -145,12 +150,13 @@ export const StudentFeeApiProvider = ({ children, }) => {
|
|
|
145
150
|
? t("messagesStudentFeeCreated")
|
|
146
151
|
: t("messagesStudentFeeUpdated"), TOAST_VARIANT.SUCCESS);
|
|
147
152
|
resetFormAndCloseDrawer();
|
|
148
|
-
(
|
|
153
|
+
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
149
154
|
}
|
|
150
|
-
}, [showToast, t, resetFormAndCloseDrawer]);
|
|
155
|
+
}, [dispatch, showToast, t, resetFormAndCloseDrawer]);
|
|
151
156
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
157
|
+
var _a;
|
|
152
158
|
if (error) {
|
|
153
|
-
showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
159
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
154
160
|
return;
|
|
155
161
|
}
|
|
156
162
|
if (data) {
|
|
@@ -179,14 +185,14 @@ export const StudentFeeApiProvider = ({ children, }) => {
|
|
|
179
185
|
}
|
|
180
186
|
}, [dispatch, showToast, t]);
|
|
181
187
|
const deleteCallback = useCallback(({ data, error }) => {
|
|
182
|
-
var _a;
|
|
188
|
+
var _a, _b;
|
|
183
189
|
if (error) {
|
|
184
|
-
showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
190
|
+
showToast((_a = apiError(data)) !== null && _a !== void 0 ? _a : t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
185
191
|
return;
|
|
186
192
|
}
|
|
187
193
|
if (data) {
|
|
188
194
|
showToast(t("messagesStudentFeeDeleted"), TOAST_VARIANT.SUCCESS);
|
|
189
|
-
(
|
|
195
|
+
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
190
196
|
}
|
|
191
197
|
}, [showToast, t]);
|
|
192
198
|
// ==========================================================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PAYMENT_STATUS, FEE_RISK_LEVEL, StudentProfileBE } from "../../../type";
|
|
1
|
+
import { PAYMENT_STATUS, FEE_RISK_LEVEL, StudentProfileBE, StudentFeeBE } from "../../../type";
|
|
2
2
|
import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
|
|
3
3
|
export declare const useStudentFeeModule: () => {
|
|
4
4
|
applyFilters: () => void;
|
|
@@ -38,7 +38,7 @@ export declare const useStudentFeeModule: () => {
|
|
|
38
38
|
updateLoading: boolean;
|
|
39
39
|
handleCloseDrawer?: () => void;
|
|
40
40
|
state: {
|
|
41
|
-
items:
|
|
41
|
+
items: StudentFeeBE[];
|
|
42
42
|
count: number;
|
|
43
43
|
currentPage: number;
|
|
44
44
|
pageLimit: number;
|
|
@@ -79,7 +79,7 @@ export declare const useStudentFeeModule: () => {
|
|
|
79
79
|
appliedFilterStatus: PAYMENT_STATUS | "";
|
|
80
80
|
appliedFilterFromDate: string;
|
|
81
81
|
appliedFilterToDate: string;
|
|
82
|
-
studentFeesSingleEntry:
|
|
82
|
+
studentFeesSingleEntry: StudentFeeBE[];
|
|
83
83
|
selectedStudentFeeIds: string[];
|
|
84
84
|
};
|
|
85
85
|
dispatch: React.Dispatch<any>;
|
|
@@ -196,33 +196,47 @@ export const useStudentFeeModule = () => {
|
|
|
196
196
|
payload: { key: "familyId", value: familyId },
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
|
-
if (field === "discountCodeId"
|
|
200
|
-
|
|
199
|
+
if (field === "discountCodeId") {
|
|
200
|
+
const gross = Number(currentState.originalFee) ||
|
|
201
|
+
Number(currentState.amount) + Number(currentState.discountAmount) ||
|
|
202
|
+
0;
|
|
203
|
+
const amountPaid = Number(currentState.amountPaid) || 0;
|
|
204
|
+
let discountAmount = 0;
|
|
205
|
+
if (value && typeof value === "string") {
|
|
201
206
|
const discountCode = (_c = discountCodes.items) === null || _c === void 0 ? void 0 : _c.find((code) => code.id === value && code.enabled);
|
|
202
207
|
if (discountCode) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
discountAmount = Math.min(discountAmount,
|
|
208
|
-
dispatch({
|
|
209
|
-
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
210
|
-
payload: { key: "discountAmount", value: discountAmount },
|
|
211
|
-
});
|
|
212
|
-
const { amount, amountDue } = calculateAmounts(originalFee, discountAmount, Number(currentState.amountPaid) || 0);
|
|
213
|
-
dispatch({
|
|
214
|
-
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
215
|
-
payload: { key: "amount", value: amount },
|
|
216
|
-
});
|
|
217
|
-
dispatch({
|
|
218
|
-
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
219
|
-
payload: { key: "amountDue", value: amountDue },
|
|
220
|
-
});
|
|
208
|
+
discountAmount =
|
|
209
|
+
discountCode.discountType === DISCOUNT_TYPE.PERCENTAGE
|
|
210
|
+
? (gross * discountCode.discountValue) / 100
|
|
211
|
+
: discountCode.discountValue;
|
|
212
|
+
discountAmount = Math.min(discountAmount, gross);
|
|
221
213
|
}
|
|
222
214
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
215
|
+
// Clearing the code restores the gross amount (amount = gross).
|
|
216
|
+
dispatch({
|
|
217
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
218
|
+
payload: { key: "discountAmount", value: discountAmount },
|
|
219
|
+
});
|
|
220
|
+
const { amount, amountDue } = calculateAmounts(gross, discountAmount, amountPaid);
|
|
221
|
+
dispatch({
|
|
222
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
223
|
+
payload: { key: "amount", value: amount },
|
|
224
|
+
});
|
|
225
|
+
dispatch({
|
|
226
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
227
|
+
payload: { key: "amountDue", value: amountDue },
|
|
228
|
+
});
|
|
229
|
+
dispatch({
|
|
230
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
231
|
+
payload: {
|
|
232
|
+
key: "status",
|
|
233
|
+
value: amountPaid <= 0
|
|
234
|
+
? PAYMENT_STATUS.PENDING
|
|
235
|
+
: amountPaid >= amount
|
|
236
|
+
? PAYMENT_STATUS.PAID
|
|
237
|
+
: PAYMENT_STATUS.PARTIAL,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
226
240
|
}
|
|
227
241
|
if (field === "discountAmount" && typeof value === "number") {
|
|
228
242
|
const originalFee = Number(currentState.originalFee) || 0;
|
|
@@ -325,9 +339,13 @@ export const useStudentFeeModule = () => {
|
|
|
325
339
|
}, [dispatch]);
|
|
326
340
|
const toggleStatus = useCallback((row) => {
|
|
327
341
|
updateFetchNow(undefined, {
|
|
328
|
-
body: JSON.stringify(
|
|
342
|
+
body: JSON.stringify({
|
|
343
|
+
id: row === null || row === void 0 ? void 0 : row.id,
|
|
344
|
+
schoolId,
|
|
345
|
+
enabled: !(row === null || row === void 0 ? void 0 : row.enabled),
|
|
346
|
+
}),
|
|
329
347
|
});
|
|
330
|
-
}, [updateFetchNow]);
|
|
348
|
+
}, [schoolId, updateFetchNow]);
|
|
331
349
|
const handleCreate = useCallback(() => {
|
|
332
350
|
resetRecordFormState();
|
|
333
351
|
dispatch({
|
|
@@ -373,9 +391,9 @@ export const useStudentFeeModule = () => {
|
|
|
373
391
|
if (!confirm(t("messagesDeleteConfirmation")))
|
|
374
392
|
return;
|
|
375
393
|
deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
|
|
376
|
-
body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id }),
|
|
394
|
+
body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id, schoolId }),
|
|
377
395
|
});
|
|
378
|
-
}, [t, deleteFetchNow]);
|
|
396
|
+
}, [t, deleteFetchNow, schoolId]);
|
|
379
397
|
const handleFilters = useCallback(() => {
|
|
380
398
|
dispatch({
|
|
381
399
|
type: STUDENT_FEE_ACTION_TYPES.SET_FILTERS,
|
|
@@ -620,7 +638,6 @@ export const useStudentFeeModule = () => {
|
|
|
620
638
|
resetFormAndCloseDrawer,
|
|
621
639
|
listFetchNow,
|
|
622
640
|
state.studentFeesSingleEntry,
|
|
623
|
-
state.amountPaid,
|
|
624
641
|
state.paidAt,
|
|
625
642
|
state.remarks,
|
|
626
643
|
state.status,
|
|
@@ -664,13 +681,29 @@ export const useStudentFeeModule = () => {
|
|
|
664
681
|
order: 2,
|
|
665
682
|
},
|
|
666
683
|
{
|
|
667
|
-
enabled:
|
|
684
|
+
enabled: (row) => {
|
|
685
|
+
const status = row === null || row === void 0 ? void 0 : row.status;
|
|
686
|
+
return (status !== PAYMENT_STATUS.PAID &&
|
|
687
|
+
status !== PAYMENT_STATUS.CANCELLED &&
|
|
688
|
+
status !== PAYMENT_STATUS.REFUNDED);
|
|
689
|
+
},
|
|
668
690
|
handleOnClick: handleDelete,
|
|
669
691
|
label: t("actionsButtonDelete"),
|
|
670
692
|
order: 3,
|
|
671
693
|
variant: "destructive",
|
|
672
694
|
},
|
|
673
|
-
|
|
695
|
+
{
|
|
696
|
+
enabled: (row) => {
|
|
697
|
+
const status = row === null || row === void 0 ? void 0 : row.status;
|
|
698
|
+
return (status !== PAYMENT_STATUS.PAID &&
|
|
699
|
+
status !== PAYMENT_STATUS.CANCELLED &&
|
|
700
|
+
status !== PAYMENT_STATUS.REFUNDED);
|
|
701
|
+
},
|
|
702
|
+
handleOnClick: toggleStatus,
|
|
703
|
+
label: t("actionsButtonToggleStatus"),
|
|
704
|
+
order: 4,
|
|
705
|
+
},
|
|
706
|
+
], [handleDelete, handleEdit, handleView, t, toggleStatus]);
|
|
674
707
|
// ============================================================================
|
|
675
708
|
// 1.4.7 RETURN
|
|
676
709
|
// ============================================================================
|
|
@@ -8,12 +8,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
*/
|
|
9
9
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
10
10
|
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
11
|
+
import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
|
|
11
12
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
12
13
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
13
14
|
import { useEffect } from "react";
|
|
14
15
|
import { useStudentFeeModule, STUDENT_FEE_DRAWER } from "./context";
|
|
15
16
|
import { PAYMENT_STATUS_OPTIONS } from "./constants";
|
|
16
|
-
import {
|
|
17
|
+
import { DISCOUNT_CODE_API_ROUTES, FEE_STRUCTURE_API_ROUTES, STUDENT_PROFILE_API_ROUTES, } from "../../constants";
|
|
17
18
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
18
19
|
import { API_METHODS } from "@react-pakistan/util-functions/constants/api-methods";
|
|
19
20
|
import { setStorageValue } from "@react-pakistan/util-functions/local-storage/set-storage-value";
|
|
@@ -22,7 +23,7 @@ import { useTranslations } from "next-intl";
|
|
|
22
23
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
23
24
|
import { getTranslatedError } from "../../utils/get-translated-error";
|
|
24
25
|
export const StudentFeeForm = () => {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
26
27
|
const { state, handleChange } = useStudentFeeModule();
|
|
27
28
|
const { amount, amountDue, amountPaid, discountAmount, discountCodeId, drawer, dueDate, enabled, errors, feeStructureId, paidAt, remarks, status, studentProfileId, } = state;
|
|
28
29
|
const workspace = getCachedWorkspaceSync();
|
|
@@ -100,6 +101,7 @@ export const StudentFeeForm = () => {
|
|
|
100
101
|
placeholder: t("formFeeStructurePlaceholder"),
|
|
101
102
|
required: true,
|
|
102
103
|
searchEndpoint: FEE_STRUCTURE_API_ROUTES.UNIT,
|
|
104
|
+
searchParams: { schoolId: (_j = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _j === void 0 ? void 0 : _j.id },
|
|
103
105
|
searchPlaceholder: t("formSearchFeeStructuresPlaceholder"),
|
|
104
106
|
formatSearchResult: (item) => {
|
|
105
107
|
const feeStructure = item;
|
|
@@ -116,12 +118,13 @@ export const StudentFeeForm = () => {
|
|
|
116
118
|
info: t("formDiscountCodeInfo"),
|
|
117
119
|
label: t("formDiscountCodeLabel"),
|
|
118
120
|
onValueChange: (value) => handleChange("discountCodeId", value),
|
|
119
|
-
options: ((
|
|
121
|
+
options: ((_k = discountCodes === null || discountCodes === void 0 ? void 0 : discountCodes.items) === null || _k === void 0 ? void 0 : _k.map((code) => ({
|
|
120
122
|
value: code.id,
|
|
121
123
|
label: `${code.code} - ${code.discountValue}${code.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`,
|
|
122
124
|
}))) || [],
|
|
123
125
|
placeholder: t("formDiscountCodePlaceholder"),
|
|
124
126
|
searchEndpoint: DISCOUNT_CODE_API_ROUTES.UNIT,
|
|
127
|
+
searchParams: { schoolId: (_l = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _l === void 0 ? void 0 : _l.id },
|
|
125
128
|
searchPlaceholder: t("formSearchDiscountCodesPlaceholder"),
|
|
126
129
|
formatSearchResult: (item) => {
|
|
127
130
|
const discountCode = item;
|
|
@@ -132,28 +135,9 @@ export const StudentFeeForm = () => {
|
|
|
132
135
|
},
|
|
133
136
|
value: discountCodeId || "",
|
|
134
137
|
});
|
|
135
|
-
const {
|
|
136
|
-
emptyText: t("formNoStatusEmpty"),
|
|
137
|
-
id: "status",
|
|
138
|
-
info: t("formStatusInfo"),
|
|
139
|
-
label: t("formStatusLabel"),
|
|
140
|
-
onValueChange: (value) => handleChange("status", value),
|
|
141
|
-
options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
|
|
138
|
+
const statusCombo = (_jsx(EnhancedCombobox, { emptyText: t("formNoStatusEmpty"), error: getTranslatedError({ errors, key: "status", t }), id: "status", info: t("formStatusInfo"), label: t("formStatusLabel"), onValueChange: (value) => handleChange("status", value), options: PAYMENT_STATUS_OPTIONS.map((opt) => ({
|
|
142
139
|
value: opt.value,
|
|
143
140
|
label: paymentStatusLabelMap[opt.value] || opt.label,
|
|
144
|
-
})),
|
|
145
|
-
placeholder: t("formStatusPlaceholder"),
|
|
146
|
-
required: true,
|
|
147
|
-
searchEndpoint: STUDENT_FEE_API_ROUTES.UNIT,
|
|
148
|
-
searchPlaceholder: t("formSearchStatusPlaceholder"),
|
|
149
|
-
formatSearchResult: (item) => {
|
|
150
|
-
var _a, _b;
|
|
151
|
-
return ({
|
|
152
|
-
label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
|
|
153
|
-
value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
value: status,
|
|
157
|
-
});
|
|
141
|
+
})), placeholder: t("formStatusPlaceholder"), required: true, value: status }));
|
|
158
142
|
return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [studentProfileIdCombo, feeStructureIdCombo, discountCodeIdCombo, _jsx(EnhancedInput, { error: errors.discountAmount, id: "discountAmount", info: t("formDiscountAmountInfo"), label: t("formDiscountAmountLabel"), min: "0", onChange: (e) => handleChange("discountAmount", Number(e.target.value)), placeholder: "0.00", step: "0.01", type: "number", value: discountAmount || 0 }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "amount", t }), id: "amount", info: t("formTotalAmountInfo"), label: t("formTotalAmountLabel"), min: "0", onChange: (e) => handleChange("amount", Number(e.target.value)), placeholder: "0.00", required: true, step: "0.01", type: "number", value: amount }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "amountPaid", t }), id: "amountPaid", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), min: "0", required: true, onChange: (e) => handleChange("amountPaid", Number(e.target.value)), placeholder: "0.00", step: "0.01", type: "number", value: amountPaid }), _jsx(EnhancedInput, { disabled: true, error: getTranslatedError({ errors, key: "amountDue", t }), id: "amountDue", info: t("formAmountDueInfo"), label: t("formAmountDueLabel"), min: "0", required: true, onChange: (e) => handleChange("amountDue", Number(e.target.value)), placeholder: "0.00", step: "0.01", type: "number", value: amountDue }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dueDate", t }), id: "dueDate", info: t("formDueDateInfo"), label: t("formDueDateLabel"), onChange: (e) => handleChange("dueDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, required: true, type: "date", value: dueDate || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "paidAt", t }), id: "paidAt", info: t("formPaidAtInfo"), label: t("formPaidAtLabel"), onChange: (e) => handleChange("paidAt", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, type: "date", value: paidAt || "" }), statusCombo, _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "remarks", t }), id: "remarks", label: t("formRemarksLabel"), onChange: (e) => handleChange("remarks", e.target.value), placeholder: t("formRemarksPlaceholder"), value: remarks || "" }), _jsx(EnhancedCheckbox, { checked: enabled, error: getTranslatedError({ errors, key: "enabled", t }), id: "enabled", info: t("formEnabledInfo"), label: t("formEnabledLabel"), onCheckedChange: (checked) => handleChange("enabled", !!checked) })] }));
|
|
159
143
|
};
|
|
@@ -12,10 +12,11 @@ import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
|
12
12
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
13
13
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
14
14
|
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
15
|
-
|
|
15
|
+
/** Read at call time — never cache a workspace captured at module load. */
|
|
16
|
+
const currentSchoolId = () => { var _a, _b; return ((_b = (_a = getCachedWorkspaceSync()) === null || _a === void 0 ? void 0 : _a.school) === null || _b === void 0 ? void 0 : _b.id) || ""; };
|
|
16
17
|
const POLL_INTERVAL_MS = 2000;
|
|
17
18
|
const POLL_TIMEOUT_MS = 300000;
|
|
18
|
-
const PAGE_LIMIT =
|
|
19
|
+
const PAGE_LIMIT = 200;
|
|
19
20
|
async function pollJob(statusUrl, signal, onProgress) {
|
|
20
21
|
const startTime = Date.now();
|
|
21
22
|
let lastProgressToast = 0;
|
|
@@ -76,8 +77,7 @@ export const StudentFeeMoreActions = () => {
|
|
|
76
77
|
});
|
|
77
78
|
}, [dispatch]);
|
|
78
79
|
const refreshList = useCallback(() => {
|
|
79
|
-
|
|
80
|
-
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
80
|
+
const schoolId = currentSchoolId();
|
|
81
81
|
fetch(`${STUDENT_FEE_API_ROUTES.UNIT}?currentPage=1&pageLimit=${PAGE_LIMIT}&schoolId=${schoolId}`, {
|
|
82
82
|
headers: {
|
|
83
83
|
"Content-Type": "application/json",
|
|
@@ -99,8 +99,8 @@ export const StudentFeeMoreActions = () => {
|
|
|
99
99
|
.catch(() => { });
|
|
100
100
|
}, [dispatch]);
|
|
101
101
|
const handleAutoPost = useCallback(async () => {
|
|
102
|
-
var _a, _b, _c
|
|
103
|
-
const schoolId = (
|
|
102
|
+
var _a, _b, _c;
|
|
103
|
+
const schoolId = currentSchoolId();
|
|
104
104
|
const numbers = computerNumbersText
|
|
105
105
|
.split(",")
|
|
106
106
|
.map((n) => n.trim())
|
|
@@ -115,7 +115,7 @@ export const StudentFeeMoreActions = () => {
|
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
setSubmitting(true);
|
|
118
|
-
(
|
|
118
|
+
(_a = abortRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
119
119
|
const controller = new AbortController();
|
|
120
120
|
abortRef.current = controller;
|
|
121
121
|
const { signal } = controller;
|
|
@@ -158,7 +158,7 @@ export const StudentFeeMoreActions = () => {
|
|
|
158
158
|
return;
|
|
159
159
|
if (status.status === "completed") {
|
|
160
160
|
const r = status.results;
|
|
161
|
-
if (r && ((
|
|
161
|
+
if (r && ((_b = r.errors) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
162
162
|
const summary = formatErrorSummary(t, r.errors);
|
|
163
163
|
showSuccessToast(`${t("messagesAutoPostResults", { paid: r.paid, skipped: r.skipped })}\n${summary}`);
|
|
164
164
|
}
|
|
@@ -173,7 +173,7 @@ export const StudentFeeMoreActions = () => {
|
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
175
|
const r = status.results;
|
|
176
|
-
const detail = ((
|
|
176
|
+
const detail = ((_c = r === null || r === void 0 ? void 0 : r.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
177
177
|
? formatErrorSummary(t, r.errors)
|
|
178
178
|
: t("unknownError");
|
|
179
179
|
showErrorToast(`${t("messagesAutoPostFailed")}\n${detail}`);
|
|
@@ -68,7 +68,7 @@ const tableBodyCols = [
|
|
|
68
68
|
{ componentType: COMPONENT_TYPE.TEXT, key: "status" },
|
|
69
69
|
{
|
|
70
70
|
componentType: COMPONENT_TYPE.TEXT,
|
|
71
|
-
key: "
|
|
71
|
+
key: "lastPaidMonths",
|
|
72
72
|
textFormatter: (_, row) => {
|
|
73
73
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
74
74
|
return ((_g = (_f = (_e = (_d = (_c = (_b = (_a = row.family) === null || _a === void 0 ? void 0 : _a.studentFees) === null || _b === void 0 ? void 0 : _b.filter((sf) => sf.paidAt !== null && sf.status === "PAID")) === null || _c === void 0 ? void 0 : _c.filter((sf) => sf.studentProfileId ===
|
|
@@ -8,29 +8,7 @@
|
|
|
8
8
|
* - Status Options
|
|
9
9
|
* - Gender Options
|
|
10
10
|
*/
|
|
11
|
-
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
12
11
|
export declare const pageLimit: number;
|
|
13
|
-
export declare const tableHeadItems: {
|
|
14
|
-
label: string;
|
|
15
|
-
width: string;
|
|
16
|
-
}[];
|
|
17
|
-
export declare const tableBodyCols: ({
|
|
18
|
-
componentType: COMPONENT_TYPE;
|
|
19
|
-
key: string;
|
|
20
|
-
textFormatter?: undefined;
|
|
21
|
-
} | {
|
|
22
|
-
componentType: COMPONENT_TYPE;
|
|
23
|
-
key: string[];
|
|
24
|
-
textFormatter?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
componentType: COMPONENT_TYPE;
|
|
27
|
-
key: string;
|
|
28
|
-
textFormatter: (value: unknown) => string;
|
|
29
|
-
} | {
|
|
30
|
-
componentType: COMPONENT_TYPE;
|
|
31
|
-
key?: undefined;
|
|
32
|
-
textFormatter?: undefined;
|
|
33
|
-
})[];
|
|
34
12
|
export declare const STATUS_OPTIONS: readonly [{
|
|
35
13
|
readonly label: "Active";
|
|
36
14
|
readonly value: "ACTIVE";
|
|
@@ -44,8 +22,8 @@ export declare const STATUS_OPTIONS: readonly [{
|
|
|
44
22
|
readonly label: "Transferred";
|
|
45
23
|
readonly value: "TRANSFERRED";
|
|
46
24
|
}, {
|
|
47
|
-
readonly label: "
|
|
48
|
-
readonly value: "
|
|
25
|
+
readonly label: "Dropped";
|
|
26
|
+
readonly value: "DROPPED";
|
|
49
27
|
}];
|
|
50
28
|
export declare const STATUS_BADGE_COLORS: Record<string, string>;
|
|
51
29
|
export declare const GENDER_OPTIONS: readonly [{
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* - Status Options
|
|
9
9
|
* - Gender Options
|
|
10
10
|
*/
|
|
11
|
-
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
12
11
|
// ============================================================================
|
|
13
12
|
// PAGE CONFIGURATION
|
|
14
13
|
// ============================================================================
|
|
@@ -16,71 +15,6 @@ export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
|
16
15
|
// ============================================================================
|
|
17
16
|
// TABLE CONFIGURATION
|
|
18
17
|
// ============================================================================
|
|
19
|
-
export const tableHeadItems = [
|
|
20
|
-
{ label: "ID", width: "5%" },
|
|
21
|
-
{ label: "First Name", width: "15%" },
|
|
22
|
-
{ label: "Last Name", width: "15%" },
|
|
23
|
-
{ label: "Computer Number", width: "15%" },
|
|
24
|
-
{ label: "Discount Code", width: "15%" },
|
|
25
|
-
{ label: "Enrolled Class", width: "15%" },
|
|
26
|
-
{ label: "Status", width: "10%" },
|
|
27
|
-
{ label: "Enabled", width: "5%" },
|
|
28
|
-
{ label: "Actions", width: "5%" },
|
|
29
|
-
];
|
|
30
|
-
export const tableBodyCols = [
|
|
31
|
-
{
|
|
32
|
-
componentType: COMPONENT_TYPE.ID,
|
|
33
|
-
key: "id",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
componentType: COMPONENT_TYPE.OBJECT,
|
|
37
|
-
key: ["familyMember:firstName"],
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
componentType: COMPONENT_TYPE.OBJECT,
|
|
41
|
-
key: ["familyMember:lastName"],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
componentType: COMPONENT_TYPE.TEXT,
|
|
45
|
-
key: "computerNumber",
|
|
46
|
-
textFormatter: (value) => {
|
|
47
|
-
const raw = value;
|
|
48
|
-
if (!raw)
|
|
49
|
-
return "N/A";
|
|
50
|
-
const parts = raw.split(":");
|
|
51
|
-
return parts[1] || raw;
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
componentType: COMPONENT_TYPE.TEXT,
|
|
56
|
-
key: "enrollments",
|
|
57
|
-
textFormatter: (value) => {
|
|
58
|
-
var _a, _b, _c, _d;
|
|
59
|
-
const enrollments = value;
|
|
60
|
-
if (!enrollments || enrollments.length === 0)
|
|
61
|
-
return "No enrollments";
|
|
62
|
-
if (enrollments.length === 1) {
|
|
63
|
-
const section = enrollments[0].section;
|
|
64
|
-
const courseCount = (_b = (_a = section === null || section === void 0 ? void 0 : section.courses) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
65
|
-
return courseCount > 0
|
|
66
|
-
? `${(_c = section === null || section === void 0 ? void 0 : section.name) !== null && _c !== void 0 ? _c : "Section"} (${courseCount} subjects)`
|
|
67
|
-
: ((_d = section === null || section === void 0 ? void 0 : section.name) !== null && _d !== void 0 ? _d : "Enrolled");
|
|
68
|
-
}
|
|
69
|
-
return `${enrollments.length} sections`;
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
componentType: COMPONENT_TYPE.TEXT,
|
|
74
|
-
key: "status",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
componentType: COMPONENT_TYPE.BOOLEAN,
|
|
78
|
-
key: "enabled",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
componentType: COMPONENT_TYPE.ACTIONS,
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
18
|
// ============================================================================
|
|
85
19
|
// STATUS OPTIONS
|
|
86
20
|
// ============================================================================
|
|
@@ -89,14 +23,14 @@ export const STATUS_OPTIONS = [
|
|
|
89
23
|
{ label: "Inactive", value: "INACTIVE" },
|
|
90
24
|
{ label: "Graduated", value: "GRADUATED" },
|
|
91
25
|
{ label: "Transferred", value: "TRANSFERRED" },
|
|
92
|
-
{ label: "
|
|
26
|
+
{ label: "Dropped", value: "DROPPED" },
|
|
93
27
|
];
|
|
94
28
|
export const STATUS_BADGE_COLORS = {
|
|
95
29
|
ACTIVE: "bg-green-500/10 text-green-700 dark:text-green-400",
|
|
96
30
|
INACTIVE: "bg-gray-500/10 text-gray-700 dark:text-gray-400",
|
|
97
31
|
GRADUATED: "bg-blue-500/10 text-blue-700 dark:text-blue-400",
|
|
98
32
|
TRANSFERRED: "bg-yellow-500/10 text-yellow-700 dark:text-yellow-400",
|
|
99
|
-
|
|
33
|
+
DROPPED: "bg-red-500/10 text-red-700 dark:text-red-400",
|
|
100
34
|
};
|
|
101
35
|
// ============================================================================
|
|
102
36
|
// GENDER OPTIONS
|
|
@@ -51,6 +51,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
51
51
|
filterEnabled: boolean | undefined;
|
|
52
52
|
filterGender: string | undefined;
|
|
53
53
|
filterStatus: string | undefined;
|
|
54
|
+
appliedFilterEnabled: boolean | undefined;
|
|
55
|
+
appliedFilterStatus: string | undefined;
|
|
54
56
|
}>, initialStudentProfileState: {
|
|
55
57
|
items: StudentProfileBE[];
|
|
56
58
|
count: number;
|
|
@@ -85,6 +87,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
85
87
|
filterEnabled: boolean | undefined;
|
|
86
88
|
filterGender: string | undefined;
|
|
87
89
|
filterStatus: string | undefined;
|
|
90
|
+
appliedFilterEnabled: boolean | undefined;
|
|
91
|
+
appliedFilterStatus: string | undefined;
|
|
88
92
|
}, StudentProfileProvider: import("react").FC<{
|
|
89
93
|
children: React.ReactNode;
|
|
90
94
|
}>, studentProfileReducer: (state: {
|
|
@@ -121,6 +125,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
121
125
|
filterEnabled: boolean | undefined;
|
|
122
126
|
filterGender: string | undefined;
|
|
123
127
|
filterStatus: string | undefined;
|
|
128
|
+
appliedFilterEnabled: boolean | undefined;
|
|
129
|
+
appliedFilterStatus: string | undefined;
|
|
124
130
|
}, action: any) => {
|
|
125
131
|
items: StudentProfileBE[];
|
|
126
132
|
count: number;
|
|
@@ -155,6 +161,8 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
155
161
|
filterEnabled: boolean | undefined;
|
|
156
162
|
filterGender: string | undefined;
|
|
157
163
|
filterStatus: string | undefined;
|
|
164
|
+
appliedFilterEnabled: boolean | undefined;
|
|
165
|
+
appliedFilterStatus: string | undefined;
|
|
158
166
|
}, useStudentProfileContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
159
167
|
items: StudentProfileBE[];
|
|
160
168
|
count: number;
|
|
@@ -189,4 +197,6 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
189
197
|
filterEnabled: boolean | undefined;
|
|
190
198
|
filterGender: string | undefined;
|
|
191
199
|
filterStatus: string | undefined;
|
|
200
|
+
appliedFilterEnabled: boolean | undefined;
|
|
201
|
+
appliedFilterStatus: string | undefined;
|
|
192
202
|
}>;
|
|
@@ -46,6 +46,8 @@ const studentProfileConfig = {
|
|
|
46
46
|
filterEnabled: undefined,
|
|
47
47
|
filterGender: undefined,
|
|
48
48
|
filterStatus: undefined,
|
|
49
|
+
appliedFilterEnabled: undefined,
|
|
50
|
+
appliedFilterStatus: undefined,
|
|
49
51
|
},
|
|
50
52
|
};
|
|
51
53
|
export const { actionTypes: STUDENT_PROFILE_ACTION_TYPES, config: studentProfileModuleConfig, initialState: initialStudentProfileState, Provider: StudentProfileProvider, reducer: studentProfileReducer, useContext: useStudentProfileContext, } = createGenericModule(studentProfileConfig);
|
|
@@ -20,7 +20,7 @@ export declare const useStudentProfileModule: () => {
|
|
|
20
20
|
handleSearch: (query: string) => void;
|
|
21
21
|
handleSubmit: () => void;
|
|
22
22
|
handleView: (row?: TableRow) => void;
|
|
23
|
-
handleWithdrawStudent: () =>
|
|
23
|
+
handleWithdrawStudent: (row?: TableRow) => void;
|
|
24
24
|
headerActions: {
|
|
25
25
|
enabled: boolean;
|
|
26
26
|
handleOnClick: () => void;
|
|
@@ -68,6 +68,8 @@ export declare const useStudentProfileModule: () => {
|
|
|
68
68
|
filterEnabled: boolean | undefined;
|
|
69
69
|
filterGender: string | undefined;
|
|
70
70
|
filterStatus: string | undefined;
|
|
71
|
+
appliedFilterEnabled: boolean | undefined;
|
|
72
|
+
appliedFilterStatus: string | undefined;
|
|
71
73
|
};
|
|
72
74
|
dispatch: React.Dispatch<any>;
|
|
73
75
|
};
|