@appcorp/fusion-storybook 0.2.33 → 0.2.36
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/admission/context.d.ts +1 -1
- package/base-modules/attendance/context.d.ts +2 -1
- package/base-modules/campus/context.d.ts +2 -1
- package/base-modules/campus/page.js +1 -1
- package/base-modules/class/context.d.ts +2 -1
- package/base-modules/course/context.d.ts +2 -1
- package/base-modules/discount-code/context.d.ts +2 -1
- package/base-modules/enrollment/constants.d.ts +3 -0
- package/base-modules/enrollment/constants.js +3 -0
- package/base-modules/enrollment/context.d.ts +2 -1
- package/base-modules/enrollment/context.js +1 -1
- package/base-modules/enrollment/more-actions.js +204 -26
- package/base-modules/expense/context.d.ts +2 -1
- package/base-modules/family/context.d.ts +1 -1
- package/base-modules/family-member/context.d.ts +1 -1
- package/base-modules/fee-structure/context.d.ts +2 -1
- package/base-modules/rbac/context.d.ts +2 -1
- package/base-modules/school/context.d.ts +5 -1
- package/base-modules/section/constants.d.ts +3 -0
- package/base-modules/section/constants.js +3 -0
- package/base-modules/section/context.d.ts +2 -1
- package/base-modules/section/context.js +2 -2
- package/base-modules/section/more-actions.js +202 -23
- package/base-modules/student-fee/context/shared.d.ts +1 -1
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +1 -0
- package/base-modules/student-profile/context/module-base.d.ts +1 -1
- package/base-modules/student-profile/context/use-student-profile-module.d.ts +1 -0
- package/base-modules/subject/constants.d.ts +3 -0
- package/base-modules/subject/constants.js +3 -0
- package/base-modules/subject/context.d.ts +2 -1
- package/base-modules/subject/context.js +2 -2
- package/base-modules/subject/more-actions.js +202 -23
- package/base-modules/teacher/context.d.ts +2 -1
- package/base-modules/user/context/use-user-module.d.ts +1 -0
- package/base-modules/user/context.d.ts +1 -1
- package/base-modules/workspace/context.d.ts +4 -1
- package/base-modules/workspace-user/context.d.ts +1 -1
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -227,7 +227,7 @@ export declare const ADMISSION_ACTION_TYPES: {
|
|
|
227
227
|
filterAdmissionStatus: string | undefined;
|
|
228
228
|
filterStartDate: string | undefined;
|
|
229
229
|
filterEndDate: string | undefined;
|
|
230
|
-
}, useAdmissionContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
230
|
+
}, useAdmissionContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
231
231
|
items: AdmissionBE[];
|
|
232
232
|
count: number;
|
|
233
233
|
currentPage: number;
|
|
@@ -96,7 +96,7 @@ export declare const ATTENDANCE_ACTION_TYPES: {
|
|
|
96
96
|
studentProfileId: string;
|
|
97
97
|
school: SchoolBE | undefined;
|
|
98
98
|
studentProfile: StudentProfileBE | undefined;
|
|
99
|
-
}, useAttendanceContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
99
|
+
}, useAttendanceContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
100
100
|
items: AttendanceBE[];
|
|
101
101
|
count: number;
|
|
102
102
|
currentPage: number;
|
|
@@ -144,6 +144,7 @@ export declare const useAttendanceModule: () => {
|
|
|
144
144
|
listLoading: boolean;
|
|
145
145
|
rowActions: RowAction[];
|
|
146
146
|
updateLoading: boolean;
|
|
147
|
+
handleCloseDrawer?: () => void;
|
|
147
148
|
state: {
|
|
148
149
|
items: AttendanceBE[];
|
|
149
150
|
count: number;
|
|
@@ -100,7 +100,7 @@ export declare const CAMPUS_ACTION_TYPES: {
|
|
|
100
100
|
schoolId: string;
|
|
101
101
|
state: string | null;
|
|
102
102
|
filterEnabled: boolean | undefined;
|
|
103
|
-
}, useCampusContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
103
|
+
}, useCampusContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
104
104
|
items: CampusBE[];
|
|
105
105
|
count: number;
|
|
106
106
|
currentPage: number;
|
|
@@ -150,6 +150,7 @@ export declare const useCampusModule: () => {
|
|
|
150
150
|
rowActions: RowAction[];
|
|
151
151
|
toggleStatus: (row?: TableRow) => void;
|
|
152
152
|
updateLoading: boolean;
|
|
153
|
+
handleCloseDrawer?: () => void;
|
|
153
154
|
state: {
|
|
154
155
|
items: CampusBE[];
|
|
155
156
|
count: number;
|
|
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { useMemo } from "react";
|
|
14
14
|
import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
|
|
15
15
|
import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
|
|
16
|
-
import { useCampusModule, CampusProvider, CAMPUS_ACTION_TYPES } from "./context";
|
|
16
|
+
import { useCampusModule, CampusProvider, CAMPUS_ACTION_TYPES, } from "./context";
|
|
17
17
|
import { CampusFilter } from "./filter";
|
|
18
18
|
import { CampusForm } from "./form";
|
|
19
19
|
import { CampusMoreActions } from "./more-actions";
|
|
@@ -84,7 +84,7 @@ export declare const CLASS_ACTION_TYPES: {
|
|
|
84
84
|
name: string;
|
|
85
85
|
schoolId: string;
|
|
86
86
|
filterEnabled: boolean | undefined;
|
|
87
|
-
}, useClassContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
87
|
+
}, useClassContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
88
88
|
items: ClassBE[];
|
|
89
89
|
count: number;
|
|
90
90
|
currentPage: number;
|
|
@@ -131,6 +131,7 @@ export declare const useClassModule: () => {
|
|
|
131
131
|
rowActions: RowAction[];
|
|
132
132
|
toggleStatus: (row?: TableRow) => void;
|
|
133
133
|
updateLoading: boolean;
|
|
134
|
+
handleCloseDrawer?: () => void;
|
|
134
135
|
state: {
|
|
135
136
|
items: ClassBE[];
|
|
136
137
|
count: number;
|
|
@@ -100,7 +100,7 @@ export declare const COURSE_ACTION_TYPES: {
|
|
|
100
100
|
subjectLabel: string;
|
|
101
101
|
teacherId: string;
|
|
102
102
|
teacherLabel: string;
|
|
103
|
-
}, useCourseContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
103
|
+
}, useCourseContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
104
104
|
items: CourseBE[];
|
|
105
105
|
count: number;
|
|
106
106
|
currentPage: number;
|
|
@@ -149,6 +149,7 @@ export declare const useCourseModule: () => {
|
|
|
149
149
|
listLoading: boolean;
|
|
150
150
|
rowActions: RowAction[];
|
|
151
151
|
updateLoading: boolean;
|
|
152
|
+
handleCloseDrawer?: () => void;
|
|
152
153
|
state: {
|
|
153
154
|
items: CourseBE[];
|
|
154
155
|
count: number;
|
|
@@ -88,7 +88,7 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
|
|
|
88
88
|
disableSaveButton: boolean;
|
|
89
89
|
drawer: null;
|
|
90
90
|
modal: null;
|
|
91
|
-
}, useDiscountCodeStateContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
91
|
+
}, useDiscountCodeStateContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
92
92
|
code: string;
|
|
93
93
|
description: string;
|
|
94
94
|
discountType: string;
|
|
@@ -142,6 +142,7 @@ export declare const useDiscountCodeModule: () => {
|
|
|
142
142
|
order: number;
|
|
143
143
|
}[];
|
|
144
144
|
updateLoading: boolean;
|
|
145
|
+
handleCloseDrawer?: () => void;
|
|
145
146
|
state: {
|
|
146
147
|
code: string;
|
|
147
148
|
description: string;
|
|
@@ -7,5 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const pageLimit: number;
|
|
9
9
|
export declare const ENROLLMENT_API_ROUTES: {
|
|
10
|
+
readonly LIST: "/api/v1/enrollment";
|
|
10
11
|
readonly UNIT: "/api/v1/enrollment";
|
|
12
|
+
readonly BULK: "/api/v1/enrollment/bulk";
|
|
13
|
+
readonly BULK_STATUS: (jobId: string) => string;
|
|
11
14
|
};
|
|
@@ -13,5 +13,8 @@ export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
|
13
13
|
// API ROUTES
|
|
14
14
|
// ============================================================================
|
|
15
15
|
export const ENROLLMENT_API_ROUTES = {
|
|
16
|
+
LIST: "/api/v1/enrollment",
|
|
16
17
|
UNIT: "/api/v1/enrollment",
|
|
18
|
+
BULK: "/api/v1/enrollment/bulk",
|
|
19
|
+
BULK_STATUS: (jobId) => `/api/v1/enrollment/bulk/${jobId}`,
|
|
17
20
|
};
|
|
@@ -88,7 +88,7 @@ export declare const ENROLLMENT_ACTION_TYPES: {
|
|
|
88
88
|
studentProfileId: string;
|
|
89
89
|
section: SectionBE | undefined;
|
|
90
90
|
studentProfile: StudentProfileBE | undefined;
|
|
91
|
-
}, useEnrollmentContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
91
|
+
}, useEnrollmentContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
92
92
|
items: EnrollmentBE[];
|
|
93
93
|
count: number;
|
|
94
94
|
currentPage: number;
|
|
@@ -134,6 +134,7 @@ export declare const useEnrollmentModule: () => {
|
|
|
134
134
|
listLoading: boolean;
|
|
135
135
|
rowActions: RowAction[];
|
|
136
136
|
updateLoading: boolean;
|
|
137
|
+
handleCloseDrawer?: () => void;
|
|
137
138
|
state: {
|
|
138
139
|
items: EnrollmentBE[];
|
|
139
140
|
count: number;
|
|
@@ -349,7 +349,7 @@ export const useEnrollmentModule = () => {
|
|
|
349
349
|
// ==========================================================================
|
|
350
350
|
const headerActions = useMemo(() => [
|
|
351
351
|
{
|
|
352
|
-
enabled:
|
|
352
|
+
enabled: true,
|
|
353
353
|
handleOnClick: handleMoreActions,
|
|
354
354
|
label: t("actionsButtonMoreActions"),
|
|
355
355
|
order: 0,
|
|
@@ -1,43 +1,224 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* Bulk create and bulk update workflows for the enrollment module.
|
|
7
|
-
*/
|
|
8
|
-
import { API_METHODS, downloadFromUrl } from "@react-pakistan/util-functions";
|
|
3
|
+
import { downloadFromUrl } from "@react-pakistan/util-functions";
|
|
4
|
+
import { showErrorToast, showSuccessToast, showInfoToast, } from "@appcorp/shadcn/lib/toast-utils";
|
|
9
5
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
10
6
|
import converter from "json-2-csv";
|
|
11
7
|
import { Timeline } from "../../components/timeline";
|
|
12
8
|
import { useTranslations } from "next-intl";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
import { ENROLLMENT_API_ROUTES, pageLimit } from "./constants";
|
|
10
|
+
import { invalidateEnrollmentsCache } from "./cache";
|
|
11
|
+
import { ENROLLMENT_ACTION_TYPES, useEnrollmentContext } from "./context";
|
|
12
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
13
|
+
const workspace = getCachedWorkspaceSync();
|
|
14
|
+
const POLL_INTERVAL_MS = 2000;
|
|
15
|
+
const POLL_TIMEOUT_MS = 300000;
|
|
16
|
+
const handleGetAllRecords = async (schoolId, pageLimit) => {
|
|
17
|
+
const response = await fetch(`${ENROLLMENT_API_ROUTES.UNIT}?pageLimit=${pageLimit}¤tPage=1&schoolId=${schoolId}`);
|
|
18
|
+
const result = await response.json();
|
|
19
|
+
const csv = await converter.json2csv(result.items || [], {});
|
|
20
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
21
|
+
await downloadFromUrl(blob, "enrollment.csv");
|
|
22
|
+
};
|
|
23
|
+
async function submitBulkJob(csvData, method, signal) {
|
|
24
|
+
var _a;
|
|
25
|
+
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
26
|
+
if (!schoolId)
|
|
27
|
+
throw new Error("School ID not found");
|
|
28
|
+
const res = await fetch(ENROLLMENT_API_ROUTES.BULK, {
|
|
29
|
+
method,
|
|
30
|
+
headers: {
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify({ schoolId, csvData }),
|
|
34
|
+
signal,
|
|
35
|
+
});
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
const errorData = (await res.json().catch(() => ({})));
|
|
38
|
+
throw new Error(errorData.error || `Bulk operation failed with status ${res.status}`);
|
|
39
|
+
}
|
|
40
|
+
const data = (await res.json());
|
|
41
|
+
return data.jobId;
|
|
42
|
+
}
|
|
43
|
+
async function pollBulkJob(jobId, signal, onProgress) {
|
|
44
|
+
const startTime = Date.now();
|
|
45
|
+
let lastProgressToast = 0;
|
|
46
|
+
while (true) {
|
|
47
|
+
if (signal.aborted)
|
|
48
|
+
throw new Error("Polling cancelled");
|
|
49
|
+
if (Date.now() - startTime > POLL_TIMEOUT_MS) {
|
|
50
|
+
throw new Error("Bulk operation timed out");
|
|
51
|
+
}
|
|
52
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
53
|
+
if (signal.aborted)
|
|
54
|
+
throw new Error("Polling cancelled");
|
|
55
|
+
const res = await fetch(ENROLLMENT_API_ROUTES.BULK_STATUS(jobId), {
|
|
56
|
+
signal,
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok)
|
|
59
|
+
continue;
|
|
60
|
+
const data = (await res.json());
|
|
61
|
+
if (data.status === "completed" || data.status === "failed") {
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
// Show progress toast every 10 seconds while running
|
|
65
|
+
if (data.status === "running" && Date.now() - lastProgressToast > 10000) {
|
|
66
|
+
lastProgressToast = Date.now();
|
|
67
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(data.processed, data.total);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function formatErrorSummary(errors) {
|
|
72
|
+
if (!(errors === null || errors === void 0 ? void 0 : errors.length))
|
|
73
|
+
return "";
|
|
74
|
+
const lines = errors.slice(0, 5).map((e) => `Row ${e.row}: ${e.error}`);
|
|
75
|
+
const remaining = errors.length - 5;
|
|
76
|
+
if (remaining > 0)
|
|
77
|
+
lines.push(`...and ${remaining} more`);
|
|
78
|
+
return lines.join("\n");
|
|
79
|
+
}
|
|
16
80
|
export const EnrollmentMoreActions = () => {
|
|
17
81
|
const t = useTranslations("enrollment");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
82
|
+
const { dispatch } = useEnrollmentContext();
|
|
83
|
+
const abortRef = useRef(null);
|
|
84
|
+
// Abort any in-flight polling on unmount
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
return () => {
|
|
87
|
+
var _a;
|
|
88
|
+
(_a = abortRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
91
|
+
const handleBulkFlow = useCallback(async (files, method) => {
|
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
93
|
+
const closeDrawer = () => {
|
|
94
|
+
dispatch({
|
|
95
|
+
type: ENROLLMENT_ACTION_TYPES.SET_DRAWER,
|
|
96
|
+
payload: { drawer: null },
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
// Cancel previous in-flight request
|
|
100
|
+
(_a = abortRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
101
|
+
const controller = new AbortController();
|
|
102
|
+
abortRef.current = controller;
|
|
103
|
+
const { signal } = controller;
|
|
104
|
+
const label = method === "POST" ? "create" : "update";
|
|
105
|
+
// Read + parse CSV
|
|
106
|
+
const file = files[0];
|
|
107
|
+
const text = await file.text();
|
|
108
|
+
const records = converter.csv2json(text);
|
|
109
|
+
if (!Array.isArray(records) || records.length === 0) {
|
|
110
|
+
showErrorToast("CSV file is empty or invalid");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Client-side validation — basic required field check
|
|
114
|
+
const validationErrors = [];
|
|
115
|
+
for (let i = 0; i < records.length; i++) {
|
|
116
|
+
const row = records[i];
|
|
117
|
+
const msgs = [];
|
|
118
|
+
if (method === "POST") {
|
|
119
|
+
if (!((_b = row.studentProfileId) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
120
|
+
msgs.push("studentProfileId is required");
|
|
121
|
+
if (!((_c = row.sectionId) === null || _c === void 0 ? void 0 : _c.trim()))
|
|
122
|
+
msgs.push("sectionId is required");
|
|
123
|
+
if (!((_d = row.enrollmentDate) === null || _d === void 0 ? void 0 : _d.trim()))
|
|
124
|
+
msgs.push("enrollmentDate is required");
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
if (!((_e = row.id) === null || _e === void 0 ? void 0 : _e.trim()))
|
|
128
|
+
msgs.push("id is required for update");
|
|
129
|
+
}
|
|
130
|
+
if (msgs.length > 0) {
|
|
131
|
+
validationErrors.push({ row: i + 1, messages: msgs });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (validationErrors.length > 0) {
|
|
135
|
+
const summary = validationErrors
|
|
136
|
+
.slice(0, 5)
|
|
137
|
+
.map((e) => `Row ${e.row}: ${e.messages.join("; ")}`)
|
|
138
|
+
.join("\n");
|
|
139
|
+
const remaining = validationErrors.length - 5;
|
|
140
|
+
showErrorToast(`Validation failed for ${validationErrors.length} row(s).\n${summary}${remaining > 0 ? `\n...and ${remaining} more` : ""}`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
showInfoToast(`Bulk ${label} job queued (${records.length} records). Processing...`);
|
|
145
|
+
let jobId;
|
|
146
|
+
try {
|
|
147
|
+
jobId = await submitBulkJob(text, method, signal);
|
|
148
|
+
}
|
|
149
|
+
catch (submitError) {
|
|
150
|
+
showErrorToast(`Failed to submit ${label} job: ${submitError instanceof Error ? submitError.message : "Unknown error"}`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
154
|
+
showInfoToast(`Processing ${processed}/${total} enrollments...`);
|
|
155
|
+
});
|
|
156
|
+
if (signal.aborted)
|
|
157
|
+
return;
|
|
158
|
+
if (status.status === "completed") {
|
|
159
|
+
const r = status.results;
|
|
160
|
+
if (r && ((_f = r.errors) === null || _f === void 0 ? void 0 : _f.length) > 0) {
|
|
161
|
+
const summary = formatErrorSummary(r.errors);
|
|
162
|
+
showSuccessToast(`Created ${r.created} | Updated ${r.updated} | Skipped ${r.skipped}\n${summary}`);
|
|
163
|
+
}
|
|
164
|
+
else if (r) {
|
|
165
|
+
showSuccessToast(`Created ${r.created} | Updated ${r.updated} | Skipped ${r.skipped}`);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
showSuccessToast("Bulk operation completed successfully");
|
|
169
|
+
}
|
|
170
|
+
invalidateEnrollmentsCache();
|
|
171
|
+
const schoolId = ((_g = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _g === void 0 ? void 0 : _g.id) || "";
|
|
172
|
+
fetch(`${ENROLLMENT_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
173
|
+
headers: {
|
|
174
|
+
"Content-Type": "application/json",
|
|
175
|
+
},
|
|
176
|
+
})
|
|
177
|
+
.then(async (res) => {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
if (!res.ok)
|
|
180
|
+
return;
|
|
181
|
+
const data = await res.json();
|
|
182
|
+
dispatch({
|
|
183
|
+
type: ENROLLMENT_ACTION_TYPES.SET_ITEMS,
|
|
184
|
+
payload: {
|
|
185
|
+
items: (_a = data.items) !== null && _a !== void 0 ? _a : [],
|
|
186
|
+
count: (_b = data.count) !== null && _b !== void 0 ? _b : 0,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
})
|
|
190
|
+
.catch(() => { });
|
|
191
|
+
closeDrawer();
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const r = status.results;
|
|
195
|
+
const detail = ((_h = r === null || r === void 0 ? void 0 : r.errors) === null || _h === void 0 ? void 0 : _h.length)
|
|
196
|
+
? formatErrorSummary(r.errors)
|
|
197
|
+
: "Unknown error";
|
|
198
|
+
showErrorToast(`Bulk ${label} failed.\n${detail}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (error.message === "Polling cancelled")
|
|
203
|
+
return;
|
|
204
|
+
showErrorToast(`Bulk ${label} failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
205
|
+
}
|
|
206
|
+
}, [dispatch]);
|
|
207
|
+
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
208
|
+
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
26
209
|
const create = [
|
|
27
210
|
{
|
|
28
211
|
id: "1",
|
|
29
212
|
title: t("downloadEmptyCsvTemplate"),
|
|
30
213
|
handleOnClick: async () => {
|
|
31
|
-
|
|
214
|
+
var _a;
|
|
215
|
+
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1);
|
|
32
216
|
},
|
|
33
217
|
},
|
|
34
218
|
{ id: "2", title: t("addYourDataToTheCsv") },
|
|
35
219
|
{
|
|
36
220
|
id: "3",
|
|
37
221
|
title: t("uploadTheCompletedCsvToTheSystem"),
|
|
38
|
-
handleOnClick: () => {
|
|
39
|
-
// bulk csv upload — implementation pending
|
|
40
|
-
},
|
|
41
222
|
},
|
|
42
223
|
];
|
|
43
224
|
const update = [
|
|
@@ -46,17 +227,14 @@ export const EnrollmentMoreActions = () => {
|
|
|
46
227
|
title: t("downloadPopulatedCsvTemplate"),
|
|
47
228
|
handleOnClick: async () => {
|
|
48
229
|
var _a;
|
|
49
|
-
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "");
|
|
230
|
+
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1000);
|
|
50
231
|
},
|
|
51
232
|
},
|
|
52
233
|
{ id: "2", title: t("updateYourDataInTheCsv") },
|
|
53
234
|
{
|
|
54
235
|
id: "3",
|
|
55
236
|
title: t("uploadTheCompletedCsvToTheSystem"),
|
|
56
|
-
handleOnClick: () => {
|
|
57
|
-
// bulk csv upload — implementation pending
|
|
58
|
-
},
|
|
59
237
|
},
|
|
60
238
|
];
|
|
61
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Timeline, { events: create, heading: t("bulkCreate") }), _jsx(Timeline, { events: update, heading: t("bulkUpdate") })] }));
|
|
239
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Timeline, { events: create, heading: t("bulkCreate"), handleOnBulkCreate: handleBulkCreate }), _jsx(Timeline, { events: update, heading: t("bulkUpdate"), handleOnBulkCreate: handleBulkUpdate })] }));
|
|
62
240
|
};
|
|
@@ -152,7 +152,7 @@ export declare const EXPENSE_ACTION_TYPES: {
|
|
|
152
152
|
filterEnabled: boolean | undefined;
|
|
153
153
|
filterStatus: EXPENSE_STATUS | "";
|
|
154
154
|
school: SchoolBE | undefined;
|
|
155
|
-
}, useExpenseContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
155
|
+
}, useExpenseContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
156
156
|
items: ExpenseBE[];
|
|
157
157
|
count: number;
|
|
158
158
|
currentPage: number;
|
|
@@ -214,6 +214,7 @@ export declare const useExpenseModule: () => {
|
|
|
214
214
|
listLoading: boolean;
|
|
215
215
|
rowActions: RowAction[];
|
|
216
216
|
updateLoading: boolean;
|
|
217
|
+
handleCloseDrawer?: () => void;
|
|
217
218
|
state: {
|
|
218
219
|
items: ExpenseBE[];
|
|
219
220
|
count: number;
|
|
@@ -96,7 +96,7 @@ export declare const FAMILY_ACTION_TYPES: {
|
|
|
96
96
|
postalCode: string;
|
|
97
97
|
stateProvince: string;
|
|
98
98
|
userId: string;
|
|
99
|
-
}, useFamilyContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
99
|
+
}, useFamilyContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
100
100
|
items: FamilyBE[];
|
|
101
101
|
count: number;
|
|
102
102
|
currentPage: number;
|
|
@@ -128,7 +128,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
128
128
|
phone: string;
|
|
129
129
|
relationship: string;
|
|
130
130
|
role: string;
|
|
131
|
-
}, useFamilyMemberContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
131
|
+
}, useFamilyMemberContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
132
132
|
items: FamilyMemberBE[];
|
|
133
133
|
count: number;
|
|
134
134
|
currentPage: number;
|
|
@@ -96,7 +96,7 @@ export declare const FEE_STRUCTURE_ACTION_TYPES: {
|
|
|
96
96
|
id: string;
|
|
97
97
|
name: string;
|
|
98
98
|
schoolId: string;
|
|
99
|
-
}, useFeeStructureContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
99
|
+
}, useFeeStructureContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
100
100
|
items: FeeStructureBE[];
|
|
101
101
|
count: number;
|
|
102
102
|
currentPage: number;
|
|
@@ -145,6 +145,7 @@ export declare const useFeeStructureModule: () => {
|
|
|
145
145
|
rowActions: RowAction[];
|
|
146
146
|
toggleStatus: (row?: TableRow) => void;
|
|
147
147
|
updateLoading: boolean;
|
|
148
|
+
handleCloseDrawer?: () => void;
|
|
148
149
|
state: {
|
|
149
150
|
items: FeeStructureBE[];
|
|
150
151
|
count: number;
|
|
@@ -88,7 +88,7 @@ export declare const RBAC_ACTION_TYPES: {
|
|
|
88
88
|
disableSaveButton: boolean;
|
|
89
89
|
drawer: null;
|
|
90
90
|
modal: null;
|
|
91
|
-
}, useRbacContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
91
|
+
}, useRbacContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
92
92
|
description: string;
|
|
93
93
|
enabled: boolean;
|
|
94
94
|
errors: Record<string, string>;
|
|
@@ -144,6 +144,7 @@ export declare const useRbacModule: () => {
|
|
|
144
144
|
listLoading: boolean;
|
|
145
145
|
rowActions: RowAction[];
|
|
146
146
|
updateLoading: boolean;
|
|
147
|
+
handleCloseDrawer?: () => void;
|
|
147
148
|
state: {
|
|
148
149
|
description: string;
|
|
149
150
|
enabled: boolean;
|
|
@@ -98,7 +98,7 @@ export declare const SCHOOL_ACTION_TYPES: {
|
|
|
98
98
|
disableSaveButton: boolean;
|
|
99
99
|
drawer: null;
|
|
100
100
|
errors: Record<string, string>;
|
|
101
|
-
}, useSchoolContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
101
|
+
}, useSchoolContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
102
102
|
address: null;
|
|
103
103
|
city: null;
|
|
104
104
|
code: string;
|
|
@@ -132,6 +132,10 @@ export declare const useSchoolModule: () => {
|
|
|
132
132
|
order: number;
|
|
133
133
|
}[];
|
|
134
134
|
updateLoading: boolean;
|
|
135
|
+
handleSearch?: (query: string) => void;
|
|
136
|
+
handlePageChange?: (page: number) => void;
|
|
137
|
+
handlePageLimitChange?: (limit: number) => void;
|
|
138
|
+
handleCloseDrawer?: () => void;
|
|
135
139
|
state: {
|
|
136
140
|
address: null;
|
|
137
141
|
city: null;
|
|
@@ -13,5 +13,8 @@ export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
|
13
13
|
// API ROUTES
|
|
14
14
|
// ============================================================================
|
|
15
15
|
export const SECTION_API_ROUTES = {
|
|
16
|
+
LIST: "/api/v1/section",
|
|
16
17
|
UNIT: "/api/v1/section",
|
|
18
|
+
BULK: "/api/v1/section/bulk",
|
|
19
|
+
BULK_STATUS: (jobId) => `/api/v1/section/bulk/${jobId}`,
|
|
17
20
|
};
|
|
@@ -84,7 +84,7 @@ export declare const SECTION_ACTION_TYPES: {
|
|
|
84
84
|
name: string;
|
|
85
85
|
schoolId: string;
|
|
86
86
|
filterEnabled: boolean | undefined;
|
|
87
|
-
}, useSectionContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
87
|
+
}, useSectionContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
88
88
|
items: SectionBE[];
|
|
89
89
|
count: number;
|
|
90
90
|
currentPage: number;
|
|
@@ -131,6 +131,7 @@ export declare const useSectionModule: () => {
|
|
|
131
131
|
rowActions: RowAction[];
|
|
132
132
|
toggleStatus: (row?: TableRow) => void;
|
|
133
133
|
updateLoading: boolean;
|
|
134
|
+
handleCloseDrawer?: () => void;
|
|
134
135
|
state: {
|
|
135
136
|
items: SectionBE[];
|
|
136
137
|
count: number;
|
|
@@ -370,13 +370,13 @@ export const useSectionModule = () => {
|
|
|
370
370
|
// ============================================================================
|
|
371
371
|
const headerActions = useMemo(() => [
|
|
372
372
|
{
|
|
373
|
-
enabled:
|
|
373
|
+
enabled: true,
|
|
374
374
|
handleOnClick: handleMoreActions,
|
|
375
375
|
label: t("actionHeaderMoreActions"),
|
|
376
376
|
order: 0,
|
|
377
377
|
},
|
|
378
378
|
{
|
|
379
|
-
enabled:
|
|
379
|
+
enabled: true,
|
|
380
380
|
handleOnClick: handleFilters,
|
|
381
381
|
label: t("actionHeaderFilters"),
|
|
382
382
|
order: 1,
|