@appcorp/fusion-storybook 0.2.34 → 0.2.37
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/context.d.ts +2 -1
- 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/constants.d.ts +3 -0
- package/base-modules/fee-structure/constants.js +3 -0
- package/base-modules/fee-structure/context.d.ts +2 -1
- package/base-modules/fee-structure/more-actions.js +198 -10
- package/base-modules/rbac/context.d.ts +2 -1
- package/base-modules/school/context.d.ts +5 -1
- package/base-modules/section/context.d.ts +2 -1
- 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/context.d.ts +2 -1
- 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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
import { FEE_TYPE } from "../../type";
|
|
10
10
|
export declare const pageLimit: number;
|
|
11
11
|
export declare const FEE_STRUCTURE_API_ROUTES: {
|
|
12
|
+
readonly LIST: "/api/v1/fee-structure";
|
|
12
13
|
readonly UNIT: "/api/v1/fee-structure";
|
|
14
|
+
readonly BULK: "/api/v1/fee-structure/bulk";
|
|
15
|
+
readonly BULK_STATUS: (jobId: string) => string;
|
|
13
16
|
};
|
|
14
17
|
export declare const FEE_TYPE_OPTIONS: {
|
|
15
18
|
label: string;
|
|
@@ -15,7 +15,10 @@ export const pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
|
15
15
|
// API ROUTES
|
|
16
16
|
// ============================================================================
|
|
17
17
|
export const FEE_STRUCTURE_API_ROUTES = {
|
|
18
|
+
LIST: "/api/v1/fee-structure",
|
|
18
19
|
UNIT: "/api/v1/fee-structure",
|
|
20
|
+
BULK: "/api/v1/fee-structure/bulk",
|
|
21
|
+
BULK_STATUS: (jobId) => `/api/v1/fee-structure/bulk/${jobId}`,
|
|
19
22
|
};
|
|
20
23
|
// ============================================================================
|
|
21
24
|
// FEE TYPE OPTIONS
|
|
@@ -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;
|
|
@@ -1,27 +1,212 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { downloadFromUrl } from "@react-pakistan/util-functions";
|
|
4
|
+
import { showErrorToast, showSuccessToast, showInfoToast, } from "@appcorp/shadcn/lib/toast-utils";
|
|
5
|
+
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
4
6
|
import converter from "json-2-csv";
|
|
5
7
|
import { Timeline } from "../../components/timeline";
|
|
6
|
-
import { downloadFromUrl } from "@react-pakistan/util-functions";
|
|
7
8
|
import { useTranslations } from "next-intl";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import { feeStructureFormValidation } from "./validate";
|
|
10
|
+
import { FEE_STRUCTURE_API_ROUTES, pageLimit } from "./constants";
|
|
11
|
+
import { invalidateFeeStructuresCache } from "./cache";
|
|
12
|
+
import { FEE_STRUCTURE_ACTION_TYPES, useFeeStructureContext } from "./context";
|
|
13
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
14
|
+
const workspace = getCachedWorkspaceSync();
|
|
15
|
+
const POLL_INTERVAL_MS = 2000;
|
|
16
|
+
const POLL_TIMEOUT_MS = 300000;
|
|
17
|
+
const handleGetAllRecords = async (schoolId, pageLimit) => {
|
|
18
|
+
const response = await fetch(`${FEE_STRUCTURE_API_ROUTES.UNIT}?pageLimit=${pageLimit}¤tPage=1&schoolId=${schoolId}`);
|
|
11
19
|
const result = await response.json();
|
|
12
20
|
const csv = await converter.json2csv(result.items || [], {});
|
|
13
21
|
const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
|
|
14
22
|
await downloadFromUrl(blob, "fee-structure.csv");
|
|
15
23
|
};
|
|
24
|
+
async function submitBulkJob(csvData, method, signal) {
|
|
25
|
+
var _a;
|
|
26
|
+
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
27
|
+
if (!schoolId)
|
|
28
|
+
throw new Error("School ID not found");
|
|
29
|
+
const res = await fetch(FEE_STRUCTURE_API_ROUTES.BULK, {
|
|
30
|
+
method,
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify({ schoolId, csvData }),
|
|
35
|
+
signal,
|
|
36
|
+
});
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
const errorData = (await res.json().catch(() => ({})));
|
|
39
|
+
throw new Error(errorData.error || `Bulk operation failed with status ${res.status}`);
|
|
40
|
+
}
|
|
41
|
+
const data = (await res.json());
|
|
42
|
+
return data.jobId;
|
|
43
|
+
}
|
|
44
|
+
async function pollBulkJob(jobId, signal, onProgress) {
|
|
45
|
+
const startTime = Date.now();
|
|
46
|
+
let lastProgressToast = 0;
|
|
47
|
+
while (true) {
|
|
48
|
+
if (signal.aborted)
|
|
49
|
+
throw new Error("Polling cancelled");
|
|
50
|
+
if (Date.now() - startTime > POLL_TIMEOUT_MS) {
|
|
51
|
+
throw new Error("Bulk operation timed out");
|
|
52
|
+
}
|
|
53
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
54
|
+
if (signal.aborted)
|
|
55
|
+
throw new Error("Polling cancelled");
|
|
56
|
+
const res = await fetch(FEE_STRUCTURE_API_ROUTES.BULK_STATUS(jobId), {
|
|
57
|
+
signal,
|
|
58
|
+
});
|
|
59
|
+
if (!res.ok)
|
|
60
|
+
continue;
|
|
61
|
+
const data = (await res.json());
|
|
62
|
+
if (data.status === "completed" || data.status === "failed") {
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
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 FeeStructureMoreActions = () => {
|
|
17
81
|
const t = useTranslations("feeStructure");
|
|
18
|
-
const
|
|
82
|
+
const { dispatch } = useFeeStructureContext();
|
|
83
|
+
const abortRef = useRef(null);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
return () => {
|
|
86
|
+
var _a;
|
|
87
|
+
(_a = abortRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
90
|
+
const handleBulkFlow = useCallback(async (files, method) => {
|
|
91
|
+
var _a, _b, _c, _d, _e;
|
|
92
|
+
const closeDrawer = () => {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: FEE_STRUCTURE_ACTION_TYPES.SET_DRAWER,
|
|
95
|
+
payload: { drawer: null },
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
(_a = abortRef.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
abortRef.current = controller;
|
|
101
|
+
const { signal } = controller;
|
|
102
|
+
const label = method === "POST" ? "create" : "update";
|
|
103
|
+
const file = files[0];
|
|
104
|
+
const text = await file.text();
|
|
105
|
+
const records = converter.csv2json(text);
|
|
106
|
+
if (!Array.isArray(records) || records.length === 0) {
|
|
107
|
+
showErrorToast("CSV file is empty or invalid");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const validationErrors = [];
|
|
111
|
+
for (let i = 0; i < records.length; i++) {
|
|
112
|
+
const row = records[i];
|
|
113
|
+
const msgs = [];
|
|
114
|
+
if (method === "POST") {
|
|
115
|
+
const result = feeStructureFormValidation.safeParse(Object.assign(Object.assign({}, row), { amount: Number(row.amount) }));
|
|
116
|
+
if (!result.success) {
|
|
117
|
+
msgs.push(...result.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
if (!((_b = row.id) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
122
|
+
msgs.push("id is required for update");
|
|
123
|
+
}
|
|
124
|
+
if (msgs.length > 0) {
|
|
125
|
+
validationErrors.push({ row: i + 1, messages: msgs });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (validationErrors.length > 0) {
|
|
129
|
+
const summary = validationErrors
|
|
130
|
+
.slice(0, 5)
|
|
131
|
+
.map((e) => `Row ${e.row}: ${e.messages.join("; ")}`)
|
|
132
|
+
.join("\n");
|
|
133
|
+
const remaining = validationErrors.length - 5;
|
|
134
|
+
showErrorToast(`Validation failed for ${validationErrors.length} row(s).\n${summary}${remaining > 0 ? `\n...and ${remaining} more` : ""}`);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
showInfoToast(`Bulk ${label} job queued (${records.length} records). Processing...`);
|
|
139
|
+
let jobId;
|
|
140
|
+
try {
|
|
141
|
+
jobId = await submitBulkJob(text, method, signal);
|
|
142
|
+
}
|
|
143
|
+
catch (submitError) {
|
|
144
|
+
showErrorToast(`Failed to submit ${label} job: ${submitError instanceof Error ? submitError.message : "Unknown error"}`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
148
|
+
showInfoToast(`Processing ${processed}/${total} fee structures...`);
|
|
149
|
+
});
|
|
150
|
+
if (signal.aborted)
|
|
151
|
+
return;
|
|
152
|
+
if (status.status === "completed") {
|
|
153
|
+
const r = status.results;
|
|
154
|
+
if (r && ((_c = r.errors) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
155
|
+
const summary = formatErrorSummary(r.errors);
|
|
156
|
+
showSuccessToast(`Created ${r.created} | Updated ${r.updated} | Skipped ${r.skipped}\n${summary}`);
|
|
157
|
+
}
|
|
158
|
+
else if (r) {
|
|
159
|
+
showSuccessToast(`Created ${r.created} | Updated ${r.updated} | Skipped ${r.skipped}`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
showSuccessToast("Bulk operation completed successfully");
|
|
163
|
+
}
|
|
164
|
+
invalidateFeeStructuresCache();
|
|
165
|
+
const schoolId = ((_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id) || "";
|
|
166
|
+
fetch(`${FEE_STRUCTURE_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
167
|
+
headers: {
|
|
168
|
+
"Content-Type": "application/json",
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
.then(async (res) => {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
if (!res.ok)
|
|
174
|
+
return;
|
|
175
|
+
const data = await res.json();
|
|
176
|
+
dispatch({
|
|
177
|
+
type: FEE_STRUCTURE_ACTION_TYPES.SET_ITEMS,
|
|
178
|
+
payload: {
|
|
179
|
+
items: (_a = data.items) !== null && _a !== void 0 ? _a : [],
|
|
180
|
+
count: (_b = data.count) !== null && _b !== void 0 ? _b : 0,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
})
|
|
184
|
+
.catch(() => { });
|
|
185
|
+
closeDrawer();
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const r = status.results;
|
|
189
|
+
const detail = ((_e = r === null || r === void 0 ? void 0 : r.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
190
|
+
? formatErrorSummary(r.errors)
|
|
191
|
+
: "Unknown error";
|
|
192
|
+
showErrorToast(`Bulk ${label} failed.\n${detail}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
if (error.message === "Polling cancelled")
|
|
197
|
+
return;
|
|
198
|
+
showErrorToast(`Bulk ${label} failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
199
|
+
}
|
|
200
|
+
}, [dispatch]);
|
|
201
|
+
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
202
|
+
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
19
203
|
const create = [
|
|
20
204
|
{
|
|
21
205
|
id: "1",
|
|
22
206
|
title: t("downloadEmptyCsvTemplate"),
|
|
23
207
|
handleOnClick: async () => {
|
|
24
|
-
|
|
208
|
+
var _a;
|
|
209
|
+
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1);
|
|
25
210
|
},
|
|
26
211
|
},
|
|
27
212
|
{ id: "2", title: t("addYourDataToTheCsv") },
|
|
@@ -36,11 +221,14 @@ export const FeeStructureMoreActions = () => {
|
|
|
36
221
|
title: t("downloadPopulatedCsvTemplate"),
|
|
37
222
|
handleOnClick: async () => {
|
|
38
223
|
var _a;
|
|
39
|
-
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "");
|
|
224
|
+
await handleGetAllRecords(((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "", 1000);
|
|
40
225
|
},
|
|
41
226
|
},
|
|
42
227
|
{ id: "2", title: t("updateYourDataInTheCsv") },
|
|
43
|
-
{
|
|
228
|
+
{
|
|
229
|
+
id: "3",
|
|
230
|
+
title: t("uploadTheCompletedCsvToTheSystem"),
|
|
231
|
+
},
|
|
44
232
|
];
|
|
45
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Timeline, { events: create, heading: t("bulkCreate") }), _jsx(Timeline, { events: update, heading: t("bulkUpdate") })] }));
|
|
233
|
+
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 })] }));
|
|
46
234
|
};
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -145,7 +145,7 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
|
|
|
145
145
|
studentProfileId: string;
|
|
146
146
|
filterEnabled: boolean | undefined;
|
|
147
147
|
filterStatus: PAYMENT_STATUS | "";
|
|
148
|
-
}, useStudentFeeContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
148
|
+
}, useStudentFeeContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
149
149
|
items: StudentFeeBE[];
|
|
150
150
|
count: number;
|
|
151
151
|
currentPage: number;
|
|
@@ -151,7 +151,7 @@ export declare const STUDENT_PROFILE_ACTION_TYPES: {
|
|
|
151
151
|
filterEnabled: boolean | undefined;
|
|
152
152
|
filterGender: string | undefined;
|
|
153
153
|
filterStatus: string | undefined;
|
|
154
|
-
}, useStudentProfileContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
154
|
+
}, useStudentProfileContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
155
155
|
items: StudentProfileBE[];
|
|
156
156
|
count: number;
|
|
157
157
|
currentPage: number;
|
|
@@ -84,7 +84,7 @@ export declare const SUBJECT_ACTION_TYPES: {
|
|
|
84
84
|
id: string;
|
|
85
85
|
name: string;
|
|
86
86
|
schoolId: string;
|
|
87
|
-
}, useSubjectContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
87
|
+
}, useSubjectContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
88
88
|
items: SubjectBE[];
|
|
89
89
|
count: number;
|
|
90
90
|
currentPage: number;
|
|
@@ -129,6 +129,7 @@ export declare const useSubjectModule: () => {
|
|
|
129
129
|
listLoading: boolean;
|
|
130
130
|
rowActions: RowAction[];
|
|
131
131
|
updateLoading: boolean;
|
|
132
|
+
handleCloseDrawer?: () => void;
|
|
132
133
|
state: {
|
|
133
134
|
items: SubjectBE[];
|
|
134
135
|
count: number;
|
|
@@ -152,7 +152,7 @@ export declare const TEACHER_ACTION_TYPES: {
|
|
|
152
152
|
teacherCode: string;
|
|
153
153
|
userId: string | null;
|
|
154
154
|
filterEnabled: boolean | undefined;
|
|
155
|
-
}, useTeacherContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
155
|
+
}, useTeacherContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
156
156
|
items: TeacherBE[];
|
|
157
157
|
count: number;
|
|
158
158
|
currentPage: number;
|
|
@@ -217,6 +217,7 @@ export declare const useTeacherModule: () => {
|
|
|
217
217
|
rowActions: RowAction[];
|
|
218
218
|
toggleStatus: (row?: TableRow) => void;
|
|
219
219
|
updateLoading: boolean;
|
|
220
|
+
handleCloseDrawer?: () => void;
|
|
220
221
|
state: {
|
|
221
222
|
items: TeacherBE[];
|
|
222
223
|
count: number;
|
|
@@ -91,7 +91,7 @@ export declare const USER_ACTION_TYPES: {
|
|
|
91
91
|
enabled: boolean;
|
|
92
92
|
userRole: USER_ROLE | null;
|
|
93
93
|
filterEnabled: boolean | undefined;
|
|
94
|
-
}, useUserContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
94
|
+
}, useUserContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
95
95
|
items: UserBE[];
|
|
96
96
|
count: number;
|
|
97
97
|
currentPage: number;
|
|
@@ -122,7 +122,7 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
122
122
|
disableSaveButton: boolean;
|
|
123
123
|
drawer: null;
|
|
124
124
|
errors: Record<string, string>;
|
|
125
|
-
}, useWorkspaceContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
125
|
+
}, useWorkspaceContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
126
126
|
agreedCurrency: string;
|
|
127
127
|
agreedPrice: number;
|
|
128
128
|
billingDate: null;
|
|
@@ -164,6 +164,9 @@ export declare const useWorkspaceModule: () => {
|
|
|
164
164
|
handleView: () => void;
|
|
165
165
|
plans: Plan[];
|
|
166
166
|
updateLoading: boolean;
|
|
167
|
+
handleSearch?: (query: string) => void;
|
|
168
|
+
handlePageChange?: (page: number) => void;
|
|
169
|
+
handlePageLimitChange?: (limit: number) => void;
|
|
167
170
|
state: {
|
|
168
171
|
agreedCurrency: string;
|
|
169
172
|
agreedPrice: number;
|
|
@@ -107,7 +107,7 @@ export declare const WORKSPACE_USER_ACTION_TYPES: {
|
|
|
107
107
|
workspaceId: string;
|
|
108
108
|
role: RoleBE | undefined;
|
|
109
109
|
workspace: WorkspaceBE | undefined;
|
|
110
|
-
}, useWorkspaceUserContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").
|
|
110
|
+
}, useWorkspaceUserContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
111
111
|
items: WorkspaceUserBE[];
|
|
112
112
|
count: number;
|
|
113
113
|
currentPage: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appcorp/fusion-storybook",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.37",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build-storybook": "storybook build",
|
|
6
6
|
"build:next": "next build",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@radix-ui/react-slider": "^1.3.6",
|
|
60
60
|
"@radix-ui/react-slot": "^1.2.4",
|
|
61
61
|
"@radix-ui/react-toast": "^1.2.15",
|
|
62
|
-
"@react-pakistan/util-functions": "^1.25.
|
|
62
|
+
"@react-pakistan/util-functions": "^1.25.89",
|
|
63
63
|
"@storybook/addon-a11y": "^10.3.4",
|
|
64
64
|
"@storybook/addon-docs": "^10.3.4",
|
|
65
65
|
"@storybook/addon-onboarding": "^10.3.4",
|