@appcorp/fusion-storybook 0.4.5 → 0.4.7
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 +2 -0
- 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 +32 -1
- package/base-modules/student-fee/misc-2.js +11 -10
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -34,6 +34,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
34
34
|
disableSaveButton: boolean;
|
|
35
35
|
drawer: string | null;
|
|
36
36
|
errors: Record<string, string>;
|
|
37
|
+
keepPosting: boolean;
|
|
38
|
+
computerNumber: string;
|
|
37
39
|
amount: number;
|
|
38
40
|
amountDue: number;
|
|
39
41
|
amountPaid: number;
|
|
@@ -66,6 +68,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
66
68
|
disableSaveButton: boolean;
|
|
67
69
|
drawer: string | null;
|
|
68
70
|
errors: Record<string, string>;
|
|
71
|
+
keepPosting: boolean;
|
|
72
|
+
computerNumber: string;
|
|
69
73
|
amount: number;
|
|
70
74
|
amountDue: number;
|
|
71
75
|
amountPaid: number;
|
|
@@ -100,6 +104,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
100
104
|
disableSaveButton: boolean;
|
|
101
105
|
drawer: string | null;
|
|
102
106
|
errors: Record<string, string>;
|
|
107
|
+
keepPosting: boolean;
|
|
108
|
+
computerNumber: string;
|
|
103
109
|
amount: number;
|
|
104
110
|
amountDue: number;
|
|
105
111
|
amountPaid: number;
|
|
@@ -132,6 +138,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
132
138
|
disableSaveButton: boolean;
|
|
133
139
|
drawer: string | null;
|
|
134
140
|
errors: Record<string, string>;
|
|
141
|
+
keepPosting: boolean;
|
|
142
|
+
computerNumber: string;
|
|
135
143
|
amount: number;
|
|
136
144
|
amountDue: number;
|
|
137
145
|
amountPaid: number;
|
|
@@ -164,6 +172,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
164
172
|
disableSaveButton: boolean;
|
|
165
173
|
drawer: string | null;
|
|
166
174
|
errors: Record<string, string>;
|
|
175
|
+
keepPosting: boolean;
|
|
176
|
+
computerNumber: string;
|
|
167
177
|
amount: number;
|
|
168
178
|
amountDue: number;
|
|
169
179
|
amountPaid: number;
|
|
@@ -540,7 +540,37 @@ export const useStudentFeeModule = () => {
|
|
|
540
540
|
return;
|
|
541
541
|
}
|
|
542
542
|
showToast(t("messagesStudentFeeUpdated"), TOAST_VARIANT.SUCCESS);
|
|
543
|
-
|
|
543
|
+
if (state.keepPosting) {
|
|
544
|
+
const today = new Date();
|
|
545
|
+
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
|
|
546
|
+
dispatch({
|
|
547
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
548
|
+
payload: { key: "computerNumber", value: "" },
|
|
549
|
+
});
|
|
550
|
+
dispatch({
|
|
551
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
552
|
+
payload: { key: "studentFeesSingleEntry", value: [] },
|
|
553
|
+
});
|
|
554
|
+
dispatch({
|
|
555
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
556
|
+
payload: { key: "amountPaid", value: 0 },
|
|
557
|
+
});
|
|
558
|
+
dispatch({
|
|
559
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
560
|
+
payload: { key: "paidAt", value: todayStr },
|
|
561
|
+
});
|
|
562
|
+
dispatch({
|
|
563
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
564
|
+
payload: { key: "remarks", value: "" },
|
|
565
|
+
});
|
|
566
|
+
dispatch({
|
|
567
|
+
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
568
|
+
payload: { key: "status", value: PAYMENT_STATUS.PAID },
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
resetFormAndCloseDrawer();
|
|
573
|
+
}
|
|
544
574
|
listFetchNow === null || listFetchNow === void 0 ? void 0 : listFetchNow();
|
|
545
575
|
}
|
|
546
576
|
catch (_b) {
|
|
@@ -564,6 +594,7 @@ export const useStudentFeeModule = () => {
|
|
|
564
594
|
state.paidAt,
|
|
565
595
|
state.remarks,
|
|
566
596
|
state.status,
|
|
597
|
+
state.keepPosting,
|
|
567
598
|
]);
|
|
568
599
|
// ============================================================================
|
|
569
600
|
// 1.4.6 HEADER & ROW ACTIONS
|
|
@@ -6,10 +6,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
6
6
|
* Filter UI for the student-fee list. Supports filterEnabled (radio) and
|
|
7
7
|
* filterStatus (payment status combobox).
|
|
8
8
|
*/
|
|
9
|
-
import { useEffect, useMemo, useRef
|
|
9
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import { STUDENT_FEE_ACTION_TYPES, useStudentFeeModule } from "./context";
|
|
11
11
|
import { useTranslations } from "next-intl";
|
|
12
12
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
13
|
+
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
13
14
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
14
15
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
15
16
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
@@ -26,8 +27,7 @@ export const StudentFeeSingle = () => {
|
|
|
26
27
|
const workspace = getCachedWorkspaceSync();
|
|
27
28
|
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 : "";
|
|
28
29
|
const t = useTranslations("studentFee");
|
|
29
|
-
const
|
|
30
|
-
const debouncedComputerNumber = useDebounce(computerNumber, 800);
|
|
30
|
+
const debouncedComputerNumber = useDebounce(state.computerNumber, 800);
|
|
31
31
|
const { fetchNow: fetchByComputerNumber, data: feeByComputerNumber, loading: fetchingByCN, } = useFetch(STUDENT_FEE_API_ROUTES.BY_COMPUTER_NUMBER, {
|
|
32
32
|
method: API_METHODS.GET,
|
|
33
33
|
});
|
|
@@ -81,7 +81,7 @@ export const StudentFeeSingle = () => {
|
|
|
81
81
|
payload: { key: "status", value: PAYMENT_STATUS.PAID },
|
|
82
82
|
});
|
|
83
83
|
}, [feeByComputerNumber, dispatch, accumulatedAmount, state.paidAt]);
|
|
84
|
-
const isStale = computerNumber !== debouncedComputerNumber;
|
|
84
|
+
const isStale = state.computerNumber !== debouncedComputerNumber;
|
|
85
85
|
const hasData = !!feeByComputerNumber &&
|
|
86
86
|
!!debouncedComputerNumber &&
|
|
87
87
|
!isStale &&
|
|
@@ -118,11 +118,12 @@ export const StudentFeeSingle = () => {
|
|
|
118
118
|
const d = new Date(rawDate);
|
|
119
119
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
120
120
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
const accumulatedFine = useMemo(() => {
|
|
122
|
+
var _a;
|
|
123
|
+
if (!((_a = response === null || response === void 0 ? void 0 : response.studentFees) === null || _a === void 0 ? void 0 : _a.length))
|
|
124
|
+
return 0;
|
|
125
|
+
return response.studentFees.reduce((sum, f) => { var _a; return sum + ((_a = f.fine) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
126
|
+
}, [response]);
|
|
126
127
|
const handleUpdateAmountPaid = (value) => {
|
|
127
128
|
const parsed = parseFloat(value);
|
|
128
129
|
if (isNaN(parsed))
|
|
@@ -152,7 +153,7 @@ export const StudentFeeSingle = () => {
|
|
|
152
153
|
},
|
|
153
154
|
value: state.status,
|
|
154
155
|
});
|
|
155
|
-
return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "computerNumber", info: t("formComputerNumberInfo"), label: t("formComputerNumberLabel"), onChange: (e) =>
|
|
156
|
+
return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedCheckbox, { checked: state.keepPosting, id: "keepPosting", info: t("formKeepPostingInfo"), label: t("formKeepPostingLabel"), onCheckedChange: (checked) => handleChange("keepPosting", !!checked) }), _jsx(EnhancedInput, { id: "computerNumber", info: t("formComputerNumberInfo"), label: t("formComputerNumberLabel"), onChange: (e) => handleChange("computerNumber", e.target.value), placeholder: t("formComputerNumberPlaceholder"), type: "number", required: true, value: state.computerNumber }), fetchingByCN && debouncedComputerNumber ? (_jsx("div", { className: "flex items-center justify-center py-4", children: _jsx(Loader2, { className: "text-muted-foreground h-5 w-5 animate-spin" }) })) : null, fee && profile ? (_jsxs(_Fragment, { children: [_jsx(EnhancedInput, { readOnly: true, id: "studentProfileId-readonly", label: t("formStudentLabel"), value: studentName }), _jsx(EnhancedInput, { readOnly: true, id: "feeStructureId-readonly", label: t("formFeeStructureLabel"), value: feeStructureName }), _jsx(EnhancedInput, { readOnly: true, id: "discountCodeId-readonly", label: t("formDiscountCodeLabel"), value: discountCodeLabel }), _jsx(EnhancedInput, { readOnly: true, id: "discountAmount-readonly", label: t("formDiscountAmountLabel"), value: (_h = fee === null || fee === void 0 ? void 0 : fee.discountAmount) !== null && _h !== void 0 ? _h : 0, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "accumulatedFine-readonly", info: t("formAccumulatedFineInfo"), label: t("formAccumulatedFineLabel"), value: accumulatedFine, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "amount-readonly", info: t("formTotalAmountInfo"), label: t("formTotalAmountLabel"), value: accumulatedAmount + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0), type: "number", step: "0.01" }), _jsx(EnhancedInput, { id: "amountPaid", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: state.amountPaid || 0, onChange: (e) => handleUpdateAmountPaid(e.target.value), type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "amountDue-readonly", info: t("formAmountDueInfo"), label: t("formAmountDueLabel"), value: (accumulatedAmount !== null && accumulatedAmount !== void 0 ? accumulatedAmount : 0) +
|
|
156
157
|
(accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0) -
|
|
157
158
|
Number(state.amountPaid || 0), type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "dueDate-readonly", label: t("formDueDateLabel"), value: formatDisplayDate(fee === null || fee === void 0 ? void 0 : fee.dueDate), type: "date" }), _jsx(EnhancedInput, { 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: state.paidAt || "" }), statusCombo, _jsx(EnhancedTextarea, { id: "remarks", label: t("formRemarksLabel"), value: state.remarks || "", onChange: (e) => handleChange("remarks", e.target.value) })] })) : null] }));
|
|
158
159
|
};
|