@appcorp/fusion-storybook 0.5.13 → 0.5.17
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/class/context/use-class-module.d.ts +55 -0
- package/base-modules/class/context/use-class-module.js +421 -0
- package/base-modules/class/context.d.ts +27 -52
- package/base-modules/class/context.js +18 -415
- package/base-modules/class/filter.js +16 -6
- package/base-modules/class/form.js +19 -3
- package/base-modules/class/more-actions.js +48 -10
- package/base-modules/class/page.js +15 -5
- package/base-modules/class/validate.d.ts +2 -2
- package/base-modules/class/validate.js +7 -3
- package/base-modules/class/view.js +2 -4
- package/base-modules/discount-code/context/use-discount-code-module.d.ts +65 -0
- package/base-modules/discount-code/context/use-discount-code-module.js +402 -0
- package/base-modules/discount-code/context.d.ts +32 -80
- package/base-modules/discount-code/context.js +14 -430
- package/base-modules/discount-code/filter.d.ts +1 -10
- package/base-modules/discount-code/filter.js +34 -8
- package/base-modules/discount-code/form.js +9 -35
- package/base-modules/discount-code/page.js +39 -19
- package/base-modules/discount-code/validate.d.ts +2 -1
- package/base-modules/discount-code/validate.js +10 -3
- package/base-modules/discount-code/view.js +15 -4
- package/base-modules/enrollment/context.d.ts +6 -0
- package/base-modules/enrollment/context.js +69 -25
- package/base-modules/enrollment/date.d.ts +8 -0
- package/base-modules/enrollment/date.js +21 -0
- package/base-modules/enrollment/filter.js +1 -1
- package/base-modules/enrollment/form.js +55 -24
- package/base-modules/enrollment/more-actions.js +47 -10
- package/base-modules/enrollment/page.js +11 -14
- package/base-modules/enrollment/validate.d.ts +1 -0
- package/base-modules/enrollment/validate.js +3 -1
- package/base-modules/enrollment/view.js +11 -19
- package/base-modules/expense/context/expense-api-provider.js +22 -9
- package/base-modules/expense/context/shared.d.ts +35 -0
- package/base-modules/expense/context/shared.js +11 -3
- package/base-modules/expense/context/use-expense-module.d.ts +7 -1
- package/base-modules/expense/context/use-expense-module.js +58 -55
- package/base-modules/expense/filter.js +25 -57
- package/base-modules/expense/form.js +17 -74
- package/base-modules/expense/page.js +60 -29
- package/base-modules/expense/validate.d.ts +17 -11
- package/base-modules/expense/validate.js +35 -14
- package/constants.d.ts +1 -3
- package/constants.js +0 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/resolve-rbac-permissions.js +10 -6
- package/base-modules/discount-code/more-actions.d.ts +0 -9
- package/base-modules/discount-code/more-actions.js +0 -13
- package/base-modules/expense/more-actions.d.ts +0 -1
- package/base-modules/expense/more-actions.js +0 -265
|
@@ -14,33 +14,46 @@ import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
|
14
14
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
15
15
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
16
16
|
import { API_METHODS } from "@react-pakistan/util-functions/constants/api-methods";
|
|
17
|
-
import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
|
|
18
17
|
import { useEnrollmentModule } from "./context";
|
|
19
18
|
import { CLASS_API_ROUTES, SECTION_API_ROUTES, STUDENT_PROFILE_API_ROUTES, } from "../../constants";
|
|
20
19
|
import { useTranslations } from "next-intl";
|
|
21
20
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
22
|
-
import { useEffect } from "react";
|
|
21
|
+
import { useEffect, useMemo } from "react";
|
|
23
22
|
import { getTranslatedError } from "../../utils/get-translated-error";
|
|
24
23
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
24
|
+
import { toDateInput } from "./date";
|
|
25
25
|
// ============================================================================
|
|
26
26
|
// COMPONENT
|
|
27
27
|
// ============================================================================
|
|
28
28
|
export const EnrollmentForm = () => {
|
|
29
29
|
var _a, _b, _c, _d;
|
|
30
|
-
const { state
|
|
30
|
+
const { state, handleChange } = useEnrollmentModule();
|
|
31
|
+
const { class: selectedClass, classId, enabled, enrollmentDate, errors, section: selectedSection, sectionId, studentProfile: selectedStudent, studentProfileId, } = state;
|
|
31
32
|
const workspace = getCachedWorkspaceSync();
|
|
32
33
|
const t = useTranslations("enrollment");
|
|
33
34
|
const { fetchNow: studentProfileFetchNow, data: studentProfileData } = useFetch(STUDENT_PROFILE_API_ROUTES.UNIT, {
|
|
34
35
|
method: API_METHODS.GET,
|
|
35
|
-
params: {
|
|
36
|
+
params: {
|
|
37
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
38
|
+
filterEnabled: "true",
|
|
39
|
+
pageLimit: 200,
|
|
40
|
+
},
|
|
36
41
|
});
|
|
37
42
|
const { fetchNow: classFetchNow, data: classData } = useFetch(CLASS_API_ROUTES.UNIT, {
|
|
38
43
|
method: API_METHODS.GET,
|
|
39
|
-
params: {
|
|
44
|
+
params: {
|
|
45
|
+
schoolId: (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
|
|
46
|
+
filterEnabled: "true",
|
|
47
|
+
pageLimit: 200,
|
|
48
|
+
},
|
|
40
49
|
});
|
|
41
50
|
const { fetchNow: sectionFetchNow, data: sectionData } = useFetch(SECTION_API_ROUTES.UNIT, {
|
|
42
51
|
method: API_METHODS.GET,
|
|
43
|
-
params: {
|
|
52
|
+
params: {
|
|
53
|
+
schoolId: (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id,
|
|
54
|
+
filterEnabled: "true",
|
|
55
|
+
pageLimit: 200,
|
|
56
|
+
},
|
|
44
57
|
});
|
|
45
58
|
useEffect(() => {
|
|
46
59
|
if (workspace === null || workspace === void 0 ? void 0 : workspace.id) {
|
|
@@ -50,19 +63,45 @@ export const EnrollmentForm = () => {
|
|
|
50
63
|
}
|
|
51
64
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
65
|
}, [workspace === null || workspace === void 0 ? void 0 : workspace.id]);
|
|
66
|
+
const studentOptions = useMemo(() => {
|
|
67
|
+
const items = ((studentProfileData === null || studentProfileData === void 0 ? void 0 : studentProfileData.items) || []).slice();
|
|
68
|
+
if (selectedStudent &&
|
|
69
|
+
!items.some((item) => item.id === selectedStudent.id)) {
|
|
70
|
+
items.unshift(selectedStudent);
|
|
71
|
+
}
|
|
72
|
+
return items.map((item) => {
|
|
73
|
+
var _a, _b, _c, _d, _e;
|
|
74
|
+
return ({
|
|
75
|
+
value: item.id,
|
|
76
|
+
label: `${(_b = (_a = item.familyMember) === null || _a === void 0 ? void 0 : _a.firstName) !== null && _b !== void 0 ? _b : ""} ${(_d = (_c = item.familyMember) === null || _c === void 0 ? void 0 : _c.lastName) !== null && _d !== void 0 ? _d : ""} - ${((_e = item.computerNumber) !== null && _e !== void 0 ? _e : "").split(":")[1] || item.computerNumber || ""}`,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}, [studentProfileData, selectedStudent]);
|
|
80
|
+
const classOptions = useMemo(() => {
|
|
81
|
+
const items = ((classData === null || classData === void 0 ? void 0 : classData.items) || []).slice();
|
|
82
|
+
if (selectedClass && !items.some((item) => item.id === selectedClass.id)) {
|
|
83
|
+
items.unshift(selectedClass);
|
|
84
|
+
}
|
|
85
|
+
return items.map((item) => ({
|
|
86
|
+
value: item.id,
|
|
87
|
+
label: `${item.name} (${item.code})`,
|
|
88
|
+
}));
|
|
89
|
+
}, [classData, selectedClass]);
|
|
90
|
+
const sectionOptions = useMemo(() => {
|
|
91
|
+
const items = ((sectionData === null || sectionData === void 0 ? void 0 : sectionData.items) || []).slice();
|
|
92
|
+
if (selectedSection &&
|
|
93
|
+
!items.some((item) => item.id === selectedSection.id)) {
|
|
94
|
+
items.unshift(selectedSection);
|
|
95
|
+
}
|
|
96
|
+
return items.map((item) => ({ value: item.id, label: item.name }));
|
|
97
|
+
}, [sectionData, selectedSection]);
|
|
53
98
|
const { enhancedComboboxElement: studentProfileIdCombo } = useEnhancedCombobox({
|
|
54
99
|
emptyText: t("formNoStudentEmpty"),
|
|
55
100
|
id: "studentProfileId",
|
|
56
101
|
info: t("formStudentInfo"),
|
|
57
102
|
label: t("formStudentLabel"),
|
|
58
103
|
onValueChange: (value) => handleChange("studentProfileId", value),
|
|
59
|
-
options:
|
|
60
|
-
var _a, _b, _c;
|
|
61
|
-
return ({
|
|
62
|
-
value: s.id,
|
|
63
|
-
label: `${(_a = s.familyMember) === null || _a === void 0 ? void 0 : _a.firstName} ${(_b = s.familyMember) === null || _b === void 0 ? void 0 : _b.lastName} - ${((_c = s.computerNumber) !== null && _c !== void 0 ? _c : "").split(":")[1] || s.computerNumber || ""}`,
|
|
64
|
-
});
|
|
65
|
-
}),
|
|
104
|
+
options: studentOptions,
|
|
66
105
|
placeholder: t("formStudentPlaceholder"),
|
|
67
106
|
required: true,
|
|
68
107
|
searchEndpoint: STUDENT_PROFILE_API_ROUTES.UNIT,
|
|
@@ -84,10 +123,7 @@ export const EnrollmentForm = () => {
|
|
|
84
123
|
info: t("formClassInfo"),
|
|
85
124
|
label: t("formClassLabel"),
|
|
86
125
|
onValueChange: (value) => handleChange("classId", value),
|
|
87
|
-
options:
|
|
88
|
-
value: c.id,
|
|
89
|
-
label: `${c.name} (${c.code})`,
|
|
90
|
-
})),
|
|
126
|
+
options: classOptions,
|
|
91
127
|
placeholder: t("formClassPlaceholder"),
|
|
92
128
|
required: true,
|
|
93
129
|
searchEndpoint: CLASS_API_ROUTES.UNIT,
|
|
@@ -107,10 +143,7 @@ export const EnrollmentForm = () => {
|
|
|
107
143
|
info: t("formSectionInfo"),
|
|
108
144
|
label: t("formSectionLabel"),
|
|
109
145
|
onValueChange: (value) => handleChange("sectionId", value),
|
|
110
|
-
options:
|
|
111
|
-
value: s.id,
|
|
112
|
-
label: s.name,
|
|
113
|
-
})),
|
|
146
|
+
options: sectionOptions,
|
|
114
147
|
placeholder: t("formSectionPlaceholder"),
|
|
115
148
|
required: true,
|
|
116
149
|
searchEndpoint: SECTION_API_ROUTES.UNIT,
|
|
@@ -124,7 +157,5 @@ export const EnrollmentForm = () => {
|
|
|
124
157
|
},
|
|
125
158
|
value: sectionId || "",
|
|
126
159
|
});
|
|
127
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "enrollmentDate", t }), id: "enrollmentDate", info: t("formEnrollmentDateInfo"), label: t("formEnrollmentDateLabel"), onChange: (e) => handleChange("enrollmentDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: t("formEnrollmentDatePlaceholder"), required: true, type: "date", value: enrollmentDate
|
|
128
|
-
? formatDate(enrollmentDate, DATE_FORMATS.YYYY_MM_DD)
|
|
129
|
-
: "" }), _jsx(Separator, {}), studentProfileIdCombo, classIdCombo, sectionIdCombo, _jsx(EnhancedCheckbox, { checked: enabled, id: "enabled", info: t("formActiveEnrollmentInfo"), label: t("formActiveEnrollmentLabel"), onCheckedChange: (checked) => handleChange("enabled", checked) })] }));
|
|
160
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "enrollmentDate", t }), id: "enrollmentDate", info: t("formEnrollmentDateInfo"), label: t("formEnrollmentDateLabel"), onChange: (e) => handleChange("enrollmentDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: t("formEnrollmentDatePlaceholder"), required: true, type: "date", value: toDateInput(enrollmentDate) }), _jsx(Separator, {}), studentProfileIdCombo, classIdCombo, sectionIdCombo, _jsx(EnhancedCheckbox, { checked: enabled, id: "enabled", info: t("formActiveEnrollmentInfo"), label: t("formActiveEnrollmentLabel"), onCheckedChange: (checked) => handleChange("enabled", checked) })] }));
|
|
130
161
|
};
|
|
@@ -10,18 +10,54 @@ import { pageLimit } from "./constants";
|
|
|
10
10
|
import { ENROLLMENT_API_ROUTES } from "../../constants";
|
|
11
11
|
import { ENROLLMENT_ACTION_TYPES, useEnrollmentContext } from "./context";
|
|
12
12
|
import { useRef, useEffect, useCallback } from "react";
|
|
13
|
-
const workspace = getCachedWorkspaceSync();
|
|
14
13
|
const POLL_INTERVAL_MS = 2000;
|
|
15
14
|
const POLL_TIMEOUT_MS = 300000;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const TEMPLATE_HEADERS = [
|
|
16
|
+
"id",
|
|
17
|
+
"studentProfileId",
|
|
18
|
+
"classId",
|
|
19
|
+
"sectionId",
|
|
20
|
+
"enrollmentDate",
|
|
21
|
+
"enabled",
|
|
22
|
+
];
|
|
23
|
+
const CREATE_TEMPLATE_HEADERS = [
|
|
24
|
+
"studentProfileId",
|
|
25
|
+
"classId",
|
|
26
|
+
"sectionId",
|
|
27
|
+
"enrollmentDate",
|
|
28
|
+
"enabled",
|
|
29
|
+
];
|
|
30
|
+
const toCsvRow = (row) => {
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
return ({
|
|
33
|
+
id: (_a = row.id) !== null && _a !== void 0 ? _a : "",
|
|
34
|
+
studentProfileId: (_b = row.studentProfileId) !== null && _b !== void 0 ? _b : "",
|
|
35
|
+
classId: (_c = row.classId) !== null && _c !== void 0 ? _c : "",
|
|
36
|
+
sectionId: (_d = row.sectionId) !== null && _d !== void 0 ? _d : "",
|
|
37
|
+
enrollmentDate: row.enrollmentDate
|
|
38
|
+
? new Date(String(row.enrollmentDate)).toISOString().slice(0, 10)
|
|
39
|
+
: "",
|
|
40
|
+
enabled: row.enabled === false ? "false" : "true",
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const downloadCsv = async (csv, filename) => {
|
|
20
44
|
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
21
|
-
await downloadFromUrl(blob,
|
|
45
|
+
await downloadFromUrl(blob, filename);
|
|
46
|
+
};
|
|
47
|
+
const downloadCreateTemplate = async () => {
|
|
48
|
+
await downloadCsv(CREATE_TEMPLATE_HEADERS.join(",") + "\n", "enrollment-template.csv");
|
|
49
|
+
};
|
|
50
|
+
const downloadUpdateTemplate = async (schoolId) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const response = await fetch(`${ENROLLMENT_API_ROUTES.UNIT}?pageLimit=1000¤tPage=1&schoolId=${schoolId}`);
|
|
53
|
+
const result = (await response.json());
|
|
54
|
+
const rows = ((_a = result.items) !== null && _a !== void 0 ? _a : []).map(toCsvRow);
|
|
55
|
+
const csv = await converter.json2csv(rows, { keys: TEMPLATE_HEADERS });
|
|
56
|
+
await downloadCsv(csv, "enrollment.csv");
|
|
22
57
|
};
|
|
23
58
|
async function submitBulkJob(csvData, method, signal) {
|
|
24
59
|
var _a;
|
|
60
|
+
const workspace = getCachedWorkspaceSync();
|
|
25
61
|
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
26
62
|
if (!schoolId)
|
|
27
63
|
throw new Error("School ID not found");
|
|
@@ -80,7 +116,9 @@ function formatErrorSummary(t, errors) {
|
|
|
80
116
|
return lines.join("\n");
|
|
81
117
|
}
|
|
82
118
|
export const EnrollmentMoreActions = () => {
|
|
119
|
+
var _a;
|
|
83
120
|
const t = useTranslations("enrollment");
|
|
121
|
+
const workspace = getCachedWorkspaceSync();
|
|
84
122
|
const { dispatch } = useEnrollmentContext();
|
|
85
123
|
const abortRef = useRef(null);
|
|
86
124
|
// Abort any in-flight polling on unmount
|
|
@@ -229,7 +267,7 @@ export const EnrollmentMoreActions = () => {
|
|
|
229
267
|
error: error instanceof Error ? error.message : t("unknownError"),
|
|
230
268
|
}));
|
|
231
269
|
}
|
|
232
|
-
}, [dispatch, t]);
|
|
270
|
+
}, [dispatch, t, (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id]);
|
|
233
271
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
234
272
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
235
273
|
const create = [
|
|
@@ -237,8 +275,7 @@ export const EnrollmentMoreActions = () => {
|
|
|
237
275
|
id: "1",
|
|
238
276
|
title: t("downloadEmptyCsvTemplate"),
|
|
239
277
|
handleOnClick: async () => {
|
|
240
|
-
|
|
241
|
-
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1);
|
|
278
|
+
await downloadCreateTemplate();
|
|
242
279
|
},
|
|
243
280
|
},
|
|
244
281
|
{ id: "2", title: t("addYourDataToTheCsv") },
|
|
@@ -253,7 +290,7 @@ export const EnrollmentMoreActions = () => {
|
|
|
253
290
|
title: t("downloadPopulatedCsvTemplate"),
|
|
254
291
|
handleOnClick: async () => {
|
|
255
292
|
var _a;
|
|
256
|
-
await
|
|
293
|
+
await downloadUpdateTemplate(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "");
|
|
257
294
|
},
|
|
258
295
|
},
|
|
259
296
|
{ id: "2", title: t("updateYourDataInTheCsv") },
|
|
@@ -16,15 +16,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
16
16
|
import { useMemo } from "react";
|
|
17
17
|
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
18
18
|
import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
|
|
19
|
-
import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
|
|
20
19
|
import { VALUE_DELIMITER } from "@react-pakistan/util-functions/constants/select-value-delimiter";
|
|
21
|
-
import { useEnrollmentModule, EnrollmentProvider
|
|
20
|
+
import { useEnrollmentModule, EnrollmentProvider } from "./context";
|
|
22
21
|
import { EnrollmentFilter } from "./filter";
|
|
23
22
|
import { EnrollmentForm } from "./form";
|
|
24
23
|
import { EnrollmentMoreActions } from "./more-actions";
|
|
25
24
|
import { EnrollmentView } from "./view";
|
|
26
25
|
import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
|
|
27
26
|
import { RbacNoAccess } from "../../components/rbac-no-access";
|
|
27
|
+
import { formatEnrollmentDate } from "./date";
|
|
28
28
|
// ============================================================================
|
|
29
29
|
// TABLE COLUMN CONFIGURATION (static — no runtime deps)
|
|
30
30
|
// ============================================================================
|
|
@@ -34,9 +34,11 @@ const tableBodyCols = [
|
|
|
34
34
|
componentType: COMPONENT_TYPE.TEXT,
|
|
35
35
|
key: "studentProfile",
|
|
36
36
|
textFormatter: (_, row) => {
|
|
37
|
-
var _a, _b, _c, _d, _e
|
|
37
|
+
var _a, _b, _c, _d, _e;
|
|
38
38
|
const cn = (_b = (_a = row.studentProfile) === null || _a === void 0 ? void 0 : _a.computerNumber) !== null && _b !== void 0 ? _b : "";
|
|
39
|
-
|
|
39
|
+
const member = (_c = row.studentProfile) === null || _c === void 0 ? void 0 : _c.familyMember;
|
|
40
|
+
const name = `${(_d = member === null || member === void 0 ? void 0 : member.firstName) !== null && _d !== void 0 ? _d : ""} ${(_e = member === null || member === void 0 ? void 0 : member.lastName) !== null && _e !== void 0 ? _e : ""}`.trim();
|
|
41
|
+
return `${name || "—"} - ${cn.split(VALUE_DELIMITER.COLON)[1] || cn || "—"}`;
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
44
|
{
|
|
@@ -55,10 +57,7 @@ const tableBodyCols = [
|
|
|
55
57
|
{
|
|
56
58
|
componentType: COMPONENT_TYPE.TEXT,
|
|
57
59
|
key: "enrollmentDate",
|
|
58
|
-
textFormatter: (_, row) =>
|
|
59
|
-
const val = row.enrollmentDate;
|
|
60
|
-
return val ? formatDate(val, DATE_FORMATS.LOCALE_DATE) : "N/A";
|
|
61
|
-
},
|
|
60
|
+
textFormatter: (_, row) => formatEnrollmentDate(row.enrollmentDate),
|
|
62
61
|
},
|
|
63
62
|
{ componentType: COMPONENT_TYPE.BOOLEAN, key: "enabled" },
|
|
64
63
|
{ componentType: COMPONENT_TYPE.ACTIONS },
|
|
@@ -72,7 +71,7 @@ const createComponentInstances = () => ({
|
|
|
72
71
|
moreActions: _jsx(EnrollmentMoreActions, {}),
|
|
73
72
|
view: _jsx(EnrollmentView, {}),
|
|
74
73
|
});
|
|
75
|
-
const createEnrollmentConfig = ({
|
|
74
|
+
const createEnrollmentConfig = ({ onClearFilters, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderClass, tableColumnHeaderEnabled, tableColumnHeaderEnrollmentDate, tableColumnHeaderId, tableColumnHeaderSection, tableColumnHeaderStudent, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
|
|
76
75
|
const components = createComponentInstances();
|
|
77
76
|
return {
|
|
78
77
|
moduleName: "enrollment",
|
|
@@ -102,9 +101,7 @@ const createEnrollmentConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave
|
|
|
102
101
|
tableDescription,
|
|
103
102
|
tableTitle,
|
|
104
103
|
viewContent: components.view,
|
|
105
|
-
onClearFilters:
|
|
106
|
-
dispatch({ type: ENROLLMENT_ACTION_TYPES.RESET_FORM });
|
|
107
|
-
},
|
|
104
|
+
onClearFilters: onClearFilters,
|
|
108
105
|
};
|
|
109
106
|
};
|
|
110
107
|
// ============================================================================
|
|
@@ -114,7 +111,7 @@ const GenericEnrollmentPage = createGenericModulePage();
|
|
|
114
111
|
const EnrollmentPageInner = (props) => {
|
|
115
112
|
const context = useEnrollmentModule();
|
|
116
113
|
const enrollmentConfig = useMemo(() => createEnrollmentConfig({
|
|
117
|
-
|
|
114
|
+
onClearFilters: context.clearFilters,
|
|
118
115
|
drawerButtonCancel: props.drawerButtonCancel,
|
|
119
116
|
drawerButtonSave: props.drawerButtonSave,
|
|
120
117
|
drawerFormTitle: props.drawerFormTitle,
|
|
@@ -136,7 +133,7 @@ const EnrollmentPageInner = (props) => {
|
|
|
136
133
|
tableSearchPlaceholder: props.tableSearchPlaceholder,
|
|
137
134
|
tableTitle: props.tableTitle,
|
|
138
135
|
}), [
|
|
139
|
-
context.
|
|
136
|
+
context.clearFilters,
|
|
140
137
|
props.drawerButtonCancel,
|
|
141
138
|
props.drawerButtonSave,
|
|
142
139
|
props.drawerFormTitle,
|
|
@@ -9,6 +9,7 @@ export declare const VALIDATION_KEYS: {
|
|
|
9
9
|
readonly studentProfileIdRequired: "validationEnrollmentStudentProfileIdRequired";
|
|
10
10
|
readonly sectionIdRequired: "validationEnrollmentSectionIdRequired";
|
|
11
11
|
readonly enrollmentDateRequired: "validationEnrollmentEnrollmentDateRequired";
|
|
12
|
+
readonly invalidDate: "validationEnrollmentInvalidDate";
|
|
12
13
|
};
|
|
13
14
|
export declare const enrollmentFormValidation: z.ZodObject<{
|
|
14
15
|
classId: z.ZodString;
|
|
@@ -12,6 +12,7 @@ export const VALIDATION_KEYS = {
|
|
|
12
12
|
studentProfileIdRequired: "validationEnrollmentStudentProfileIdRequired",
|
|
13
13
|
sectionIdRequired: "validationEnrollmentSectionIdRequired",
|
|
14
14
|
enrollmentDateRequired: "validationEnrollmentEnrollmentDateRequired",
|
|
15
|
+
invalidDate: "validationEnrollmentInvalidDate",
|
|
15
16
|
};
|
|
16
17
|
// ============================================================================
|
|
17
18
|
// VALIDATION SCHEMA
|
|
@@ -22,6 +23,7 @@ export const enrollmentFormValidation = z.object({
|
|
|
22
23
|
sectionId: z.string().min(1, VALIDATION_KEYS.sectionIdRequired),
|
|
23
24
|
enrollmentDate: z
|
|
24
25
|
.string()
|
|
25
|
-
.min(1, VALIDATION_KEYS.enrollmentDateRequired)
|
|
26
|
+
.min(1, VALIDATION_KEYS.enrollmentDateRequired)
|
|
27
|
+
.refine((value) => !Number.isNaN(new Date(value).getTime()), VALIDATION_KEYS.invalidDate),
|
|
26
28
|
enabled: z.boolean().optional(),
|
|
27
29
|
});
|
|
@@ -14,31 +14,23 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@app
|
|
|
14
14
|
import { Badge } from "@appcorp/shadcn/components/ui/badge";
|
|
15
15
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
16
16
|
import { BookOpen, CheckCircle2, XCircle } from "lucide-react";
|
|
17
|
-
import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
|
|
18
17
|
import { useEnrollmentModule } from "./context";
|
|
19
|
-
import { getCachedClassesSync } from "../class/cache";
|
|
20
|
-
import { getCachedStudentProfilesSync } from "../student-profile/cache";
|
|
21
|
-
import { getCachedSectionsSync } from "../section/cache";
|
|
22
18
|
import { useTranslations } from "next-intl";
|
|
19
|
+
import { formatEnrollmentDate } from "./date";
|
|
23
20
|
// ============================================================================
|
|
24
21
|
// COMPONENT
|
|
25
22
|
// ============================================================================
|
|
26
23
|
export const EnrollmentView = memo(() => {
|
|
27
|
-
var _a, _b, _c;
|
|
28
|
-
const { state
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
const { state } = useEnrollmentModule();
|
|
26
|
+
const { class: cls, classId, enrollmentDate, enabled, section, sectionId, studentProfile, studentProfileId, } = state;
|
|
29
27
|
const t = useTranslations("enrollment");
|
|
30
|
-
|
|
31
|
-
const studentName =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const sectionName = section
|
|
36
|
-
|
|
37
|
-
? `${section.class.code}-${section.name}`
|
|
38
|
-
: section.name
|
|
39
|
-
: (sectionId !== null && sectionId !== void 0 ? sectionId : "—");
|
|
40
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionEnrollmentDetails") })] }), _jsx(CardDescription, { children: t("viewSectionCompleteEnrollmentInformation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStudent") }), _jsx("p", { className: "text-base", children: studentName })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formClassLabel") }), _jsx("p", { className: "text-base", children: className })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formSectionLabel") }), _jsx("p", { className: "text-base", children: sectionName })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldEnrollmentDate") }), _jsx("p", { className: "text-base", children: enrollmentDate
|
|
41
|
-
? formatDate(enrollmentDate, DATE_FORMATS.LOCALE_DATE)
|
|
42
|
-
: "—" })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldStatus") })] }), _jsx(CardDescription, { children: t("viewFieldEnrollmentAvailability") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("div", { className: "grid grid-cols-1 gap-6", children: _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStatus") }), _jsx(Badge, { variant: enabled ? "default" : "destructive", className: "gap-1", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-3 w-3" }), " ", t("badgeActive")] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-3 w-3" }), " ", t("badgeInactive")] })) })] }) }) })] })] }));
|
|
28
|
+
// The single GET includes the relations; fall back to the id.
|
|
29
|
+
const studentName = studentProfile
|
|
30
|
+
? `${(_b = (_a = studentProfile.familyMember) === null || _a === void 0 ? void 0 : _a.firstName) !== null && _b !== void 0 ? _b : ""} ${(_d = (_c = studentProfile.familyMember) === null || _c === void 0 ? void 0 : _c.lastName) !== null && _d !== void 0 ? _d : ""}`.trim() || studentProfile.studentCode
|
|
31
|
+
: studentProfileId || "—";
|
|
32
|
+
const className = cls ? `${cls.name} (${cls.code})` : classId || "—";
|
|
33
|
+
const sectionName = section ? section.name : sectionId || "—";
|
|
34
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionEnrollmentDetails") })] }), _jsx(CardDescription, { children: t("viewSectionCompleteEnrollmentInformation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStudent") }), _jsx("p", { className: "text-base", children: studentName })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formClassLabel") }), _jsx("p", { className: "text-base", children: className })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formSectionLabel") }), _jsx("p", { className: "text-base", children: sectionName })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldEnrollmentDate") }), _jsx("p", { className: "text-base", children: formatEnrollmentDate(enrollmentDate) })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(BookOpen, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldStatus") })] }), _jsx(CardDescription, { children: t("viewFieldEnrollmentAvailability") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("div", { className: "grid grid-cols-1 gap-6", children: _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldStatus") }), _jsx(Badge, { variant: enabled ? "default" : "destructive", className: "gap-1", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-3 w-3" }), " ", t("badgeActive")] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-3 w-3" }), " ", t("badgeInactive")] })) })] }) }) })] })] }));
|
|
43
35
|
});
|
|
44
36
|
EnrollmentView.displayName = "EnrollmentView";
|
|
@@ -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";
|
|
@@ -72,7 +72,22 @@ export const ExpenseApiProvider = ({ children, }) => {
|
|
|
72
72
|
// ==========================================================================
|
|
73
73
|
// API PARAMETERS
|
|
74
74
|
// ==========================================================================
|
|
75
|
-
const listParams = useMemo(() => (Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {}))
|
|
75
|
+
const listParams = useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.appliedFilterEnabled !== undefined
|
|
76
|
+
? { filterEnabled: String(state.appliedFilterEnabled) }
|
|
77
|
+
: {})), (state.appliedFilterCategory
|
|
78
|
+
? { category: state.appliedFilterCategory }
|
|
79
|
+
: {})), (state.appliedFilterStatus
|
|
80
|
+
? { status: state.appliedFilterStatus }
|
|
81
|
+
: {})), (state.appliedFilterFromDate
|
|
82
|
+
? { fromDate: state.appliedFilterFromDate }
|
|
83
|
+
: {})), (state.appliedFilterToDate
|
|
84
|
+
? { toDate: state.appliedFilterToDate }
|
|
85
|
+
: {}))), [
|
|
86
|
+
state.appliedFilterCategory,
|
|
87
|
+
state.appliedFilterEnabled,
|
|
88
|
+
state.appliedFilterFromDate,
|
|
89
|
+
state.appliedFilterStatus,
|
|
90
|
+
state.appliedFilterToDate,
|
|
76
91
|
state.currentPage,
|
|
77
92
|
state.pageLimit,
|
|
78
93
|
debouncedQuery,
|
|
@@ -100,8 +115,8 @@ export const ExpenseApiProvider = ({ children, }) => {
|
|
|
100
115
|
vendorContact: state.vendorContact || null,
|
|
101
116
|
vendorName: state.vendorName || null,
|
|
102
117
|
}), [state, schoolId]);
|
|
103
|
-
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
104
|
-
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
118
|
+
const byIdParams = useMemo(() => ({ id: state.id, schoolId }), [state.id, schoolId]);
|
|
119
|
+
const deleteParams = useMemo(() => ({ id: state.id, schoolId }), [state.id, schoolId]);
|
|
105
120
|
// ==========================================================================
|
|
106
121
|
// API CALLBACKS
|
|
107
122
|
// ==========================================================================
|
|
@@ -123,7 +138,6 @@ export const ExpenseApiProvider = ({ children, }) => {
|
|
|
123
138
|
}, [dispatch, showToast, t]);
|
|
124
139
|
const listFetchNowRef = useRef(null);
|
|
125
140
|
const updateCallback = useCallback(({ data, error }) => {
|
|
126
|
-
var _a;
|
|
127
141
|
if (error) {
|
|
128
142
|
showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
129
143
|
return;
|
|
@@ -131,11 +145,12 @@ export const ExpenseApiProvider = ({ children, }) => {
|
|
|
131
145
|
if (data) {
|
|
132
146
|
const isCreated = isCreatedOrUpdated(data);
|
|
133
147
|
showToast(isCreated ? t("messagesExpenseCreated") : t("messagesExpenseUpdated"), TOAST_VARIANT.SUCCESS);
|
|
148
|
+
// `useModuleEntityV2` schedules the list refresh.
|
|
134
149
|
resetFormAndCloseDrawer();
|
|
135
|
-
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
136
150
|
}
|
|
137
151
|
}, [showToast, t, resetFormAndCloseDrawer]);
|
|
138
152
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
153
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
139
154
|
if (error) {
|
|
140
155
|
showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
141
156
|
return;
|
|
@@ -145,20 +160,18 @@ export const ExpenseApiProvider = ({ children, }) => {
|
|
|
145
160
|
dispatch({
|
|
146
161
|
type: EXPENSE_ACTION_TYPES.SET_FORM_DATA,
|
|
147
162
|
payload: {
|
|
148
|
-
form: Object.assign(Object.assign({}, expense), { expenseDate: normalizeDate(expense.expenseDate), paymentDate: normalizeDate(expense.paymentDate), paymentMethod: expense.paymentMethod || "",
|
|
163
|
+
form: Object.assign(Object.assign({}, expense), { approvedBy: (_a = expense.approvedBy) !== null && _a !== void 0 ? _a : "", description: (_b = expense.description) !== null && _b !== void 0 ? _b : "", expenseDate: normalizeDate(expense.expenseDate), invoiceNumber: (_c = expense.invoiceNumber) !== null && _c !== void 0 ? _c : "", paidBy: (_d = expense.paidBy) !== null && _d !== void 0 ? _d : "", paymentDate: normalizeDate(expense.paymentDate), paymentMethod: expense.paymentMethod || "", receiptNumber: (_e = expense.receiptNumber) !== null && _e !== void 0 ? _e : "", remarks: (_f = expense.remarks) !== null && _f !== void 0 ? _f : "", transactionId: (_g = expense.transactionId) !== null && _g !== void 0 ? _g : "", vendorContact: (_h = expense.vendorContact) !== null && _h !== void 0 ? _h : "", vendorName: (_j = expense.vendorName) !== null && _j !== void 0 ? _j : "" }),
|
|
149
164
|
},
|
|
150
165
|
});
|
|
151
166
|
}
|
|
152
167
|
}, [dispatch, showToast, t]);
|
|
153
168
|
const deleteCallback = useCallback(({ data, error }) => {
|
|
154
|
-
var _a;
|
|
155
169
|
if (error) {
|
|
156
170
|
showToast(t("messagesNetworkError"), TOAST_VARIANT.ERROR);
|
|
157
171
|
return;
|
|
158
172
|
}
|
|
159
173
|
if (data) {
|
|
160
174
|
showToast(t("messagesExpenseDeleted"), TOAST_VARIANT.SUCCESS);
|
|
161
|
-
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
162
175
|
}
|
|
163
176
|
}, [showToast, t]);
|
|
164
177
|
// ==========================================================================
|
|
@@ -55,6 +55,13 @@ export declare const EXPENSE_ACTION_TYPES: {
|
|
|
55
55
|
filterCategory: EXPENSE_CATEGORY | "";
|
|
56
56
|
filterEnabled: boolean | undefined;
|
|
57
57
|
filterStatus: EXPENSE_STATUS | "";
|
|
58
|
+
filterFromDate: string;
|
|
59
|
+
filterToDate: string;
|
|
60
|
+
appliedFilterCategory: EXPENSE_CATEGORY | "";
|
|
61
|
+
appliedFilterEnabled: boolean | undefined;
|
|
62
|
+
appliedFilterStatus: EXPENSE_STATUS | "";
|
|
63
|
+
appliedFilterFromDate: string;
|
|
64
|
+
appliedFilterToDate: string;
|
|
58
65
|
school: SchoolBE | undefined;
|
|
59
66
|
}>, initialExpenseState: {
|
|
60
67
|
items: ExpenseBE[];
|
|
@@ -88,6 +95,13 @@ export declare const EXPENSE_ACTION_TYPES: {
|
|
|
88
95
|
filterCategory: EXPENSE_CATEGORY | "";
|
|
89
96
|
filterEnabled: boolean | undefined;
|
|
90
97
|
filterStatus: EXPENSE_STATUS | "";
|
|
98
|
+
filterFromDate: string;
|
|
99
|
+
filterToDate: string;
|
|
100
|
+
appliedFilterCategory: EXPENSE_CATEGORY | "";
|
|
101
|
+
appliedFilterEnabled: boolean | undefined;
|
|
102
|
+
appliedFilterStatus: EXPENSE_STATUS | "";
|
|
103
|
+
appliedFilterFromDate: string;
|
|
104
|
+
appliedFilterToDate: string;
|
|
91
105
|
school: SchoolBE | undefined;
|
|
92
106
|
}, ExpenseProvider: import("react").FC<{
|
|
93
107
|
children: React.ReactNode;
|
|
@@ -123,6 +137,13 @@ export declare const EXPENSE_ACTION_TYPES: {
|
|
|
123
137
|
filterCategory: EXPENSE_CATEGORY | "";
|
|
124
138
|
filterEnabled: boolean | undefined;
|
|
125
139
|
filterStatus: EXPENSE_STATUS | "";
|
|
140
|
+
filterFromDate: string;
|
|
141
|
+
filterToDate: string;
|
|
142
|
+
appliedFilterCategory: EXPENSE_CATEGORY | "";
|
|
143
|
+
appliedFilterEnabled: boolean | undefined;
|
|
144
|
+
appliedFilterStatus: EXPENSE_STATUS | "";
|
|
145
|
+
appliedFilterFromDate: string;
|
|
146
|
+
appliedFilterToDate: string;
|
|
126
147
|
school: SchoolBE | undefined;
|
|
127
148
|
}, action: any) => {
|
|
128
149
|
items: ExpenseBE[];
|
|
@@ -156,6 +177,13 @@ export declare const EXPENSE_ACTION_TYPES: {
|
|
|
156
177
|
filterCategory: EXPENSE_CATEGORY | "";
|
|
157
178
|
filterEnabled: boolean | undefined;
|
|
158
179
|
filterStatus: EXPENSE_STATUS | "";
|
|
180
|
+
filterFromDate: string;
|
|
181
|
+
filterToDate: string;
|
|
182
|
+
appliedFilterCategory: EXPENSE_CATEGORY | "";
|
|
183
|
+
appliedFilterEnabled: boolean | undefined;
|
|
184
|
+
appliedFilterStatus: EXPENSE_STATUS | "";
|
|
185
|
+
appliedFilterFromDate: string;
|
|
186
|
+
appliedFilterToDate: string;
|
|
159
187
|
school: SchoolBE | undefined;
|
|
160
188
|
}, useExpenseContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
161
189
|
items: ExpenseBE[];
|
|
@@ -189,5 +217,12 @@ export declare const EXPENSE_ACTION_TYPES: {
|
|
|
189
217
|
filterCategory: EXPENSE_CATEGORY | "";
|
|
190
218
|
filterEnabled: boolean | undefined;
|
|
191
219
|
filterStatus: EXPENSE_STATUS | "";
|
|
220
|
+
filterFromDate: string;
|
|
221
|
+
filterToDate: string;
|
|
222
|
+
appliedFilterCategory: EXPENSE_CATEGORY | "";
|
|
223
|
+
appliedFilterEnabled: boolean | undefined;
|
|
224
|
+
appliedFilterStatus: EXPENSE_STATUS | "";
|
|
225
|
+
appliedFilterFromDate: string;
|
|
226
|
+
appliedFilterToDate: string;
|
|
192
227
|
school: SchoolBE | undefined;
|
|
193
228
|
}>;
|
|
@@ -39,7 +39,7 @@ const expenseConfig = {
|
|
|
39
39
|
id: "",
|
|
40
40
|
invoiceNumber: "",
|
|
41
41
|
paidBy: "",
|
|
42
|
-
paymentDate:
|
|
42
|
+
paymentDate: "",
|
|
43
43
|
paymentMethod: PAYMENT_METHOD.CASH,
|
|
44
44
|
receiptNumber: "",
|
|
45
45
|
remarks: "",
|
|
@@ -49,10 +49,18 @@ const expenseConfig = {
|
|
|
49
49
|
transactionId: "",
|
|
50
50
|
vendorContact: "",
|
|
51
51
|
vendorName: "",
|
|
52
|
-
//
|
|
52
|
+
// Staged filters: the drawer edits `filter*`; Apply copies them to
|
|
53
|
+
// `appliedFilter*`, which drives the request.
|
|
53
54
|
filterCategory: "",
|
|
54
|
-
filterEnabled:
|
|
55
|
+
filterEnabled: true,
|
|
55
56
|
filterStatus: "",
|
|
57
|
+
filterFromDate: "",
|
|
58
|
+
filterToDate: "",
|
|
59
|
+
appliedFilterCategory: "",
|
|
60
|
+
appliedFilterEnabled: true,
|
|
61
|
+
appliedFilterStatus: "",
|
|
62
|
+
appliedFilterFromDate: "",
|
|
63
|
+
appliedFilterToDate: "",
|
|
56
64
|
// Relations
|
|
57
65
|
school: undefined,
|
|
58
66
|
},
|
|
@@ -11,7 +11,6 @@ export declare const useExpenseModule: () => {
|
|
|
11
11
|
handleDelete: (row?: TableRow) => void;
|
|
12
12
|
handleEdit: (row?: TableRow) => void;
|
|
13
13
|
handleFilters: () => void;
|
|
14
|
-
handleMoreActions: () => void;
|
|
15
14
|
handlePageChange: (page: number | unknown) => void;
|
|
16
15
|
handlePageLimitChange: (k: string, value: object) => void;
|
|
17
16
|
handleSearch: (query: string) => void;
|
|
@@ -60,6 +59,13 @@ export declare const useExpenseModule: () => {
|
|
|
60
59
|
filterCategory: import("../../../types").EXPENSE_CATEGORY | "";
|
|
61
60
|
filterEnabled: boolean | undefined;
|
|
62
61
|
filterStatus: import("../../../types").EXPENSE_STATUS | "";
|
|
62
|
+
filterFromDate: string;
|
|
63
|
+
filterToDate: string;
|
|
64
|
+
appliedFilterCategory: import("../../../types").EXPENSE_CATEGORY | "";
|
|
65
|
+
appliedFilterEnabled: boolean | undefined;
|
|
66
|
+
appliedFilterStatus: import("../../../types").EXPENSE_STATUS | "";
|
|
67
|
+
appliedFilterFromDate: string;
|
|
68
|
+
appliedFilterToDate: string;
|
|
63
69
|
school: import("../../../types").SchoolBE | undefined;
|
|
64
70
|
};
|
|
65
71
|
dispatch: React.Dispatch<any>;
|