@appcorp/fusion-storybook 0.5.39 → 0.6.1
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/attendance-register/documents/download.d.ts +2 -0
- package/attendance-register/documents/download.js +13 -0
- package/attendance-register/documents/image-text.d.ts +37 -0
- package/attendance-register/documents/image-text.js +103 -0
- package/attendance-register/documents/pdf.d.ts +40 -0
- package/attendance-register/documents/pdf.js +425 -0
- package/attendance-register/documents/zip-files.d.ts +2 -0
- package/attendance-register/documents/zip-files.js +5 -0
- package/attendance-register/documents/zip.d.ts +13 -0
- package/attendance-register/documents/zip.js +29 -0
- package/attendance-register/domain/calendar.d.ts +28 -0
- package/attendance-register/domain/calendar.js +150 -0
- package/attendance-register/domain/locale.d.ts +26 -0
- package/attendance-register/domain/locale.js +87 -0
- package/attendance-register/domain/register.d.ts +50 -0
- package/attendance-register/domain/register.js +116 -0
- package/attendance-register/domain/student-import.d.ts +51 -0
- package/attendance-register/domain/student-import.js +231 -0
- package/attendance-register/domain/week.d.ts +40 -0
- package/attendance-register/domain/week.js +90 -0
- package/attendance-register/index.d.ts +21 -0
- package/attendance-register/index.js +19 -0
- package/attendance-register/react/register-preview.d.ts +34 -0
- package/attendance-register/react/register-preview.js +88 -0
- package/attendance-register/react/use-attendance-register.d.ts +33 -0
- package/attendance-register/react/use-attendance-register.js +106 -0
- package/attendance-register/types.d.ts +90 -0
- package/attendance-register/types.js +22 -0
- package/base-modules/admission/context/use-admission-module.d.ts +3 -0
- package/base-modules/admission/context/use-admission-module.js +41 -5
- package/base-modules/attendance/page.d.ts +2 -0
- package/base-modules/attendance/page.js +21 -1
- package/base-modules/student-profile/context/use-student-profile-module.js +4 -0
- package/base-modules/workspace/context.d.ts +6 -36
- package/base-modules/workspace/context.js +1 -20
- package/base-modules/workspace/view.js +12 -9
- package/constants.d.ts +2 -0
- package/constants.js +2 -0
- package/package.json +3 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/user-management.d.ts +2 -12
- package/utils/student-usage-api.d.ts +6 -0
- package/utils/student-usage-api.js +16 -0
- package/utils/student-usage.d.ts +20 -0
- package/utils/student-usage.js +40 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { MONTHS, } from "../types";
|
|
4
|
+
import { getDaysInMonth, getNextMonth, getWeekGroups, getWorkingDays, parseNoSchoolDays, } from "../domain/calendar";
|
|
5
|
+
import { DEFAULT_REGISTER_LOCALE } from "../domain/locale";
|
|
6
|
+
import { getDefaultWeekendDays } from "../domain/week";
|
|
7
|
+
import { formatClassLabel, getRegisterSummary } from "../domain/register";
|
|
8
|
+
function currentMonth() {
|
|
9
|
+
return MONTHS[new Date().getMonth()];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Headless register state shared by both apps. It owns only register concerns;
|
|
13
|
+
* contact details, analytics and API fetching stay in the consuming repo.
|
|
14
|
+
*/
|
|
15
|
+
export function useAttendanceRegister({ initialState, onChange, }) {
|
|
16
|
+
const [state, setState] = useState(initialState);
|
|
17
|
+
const onChangeRef = useRef(onChange);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
onChangeRef.current = onChange;
|
|
20
|
+
}, [onChange]);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
var _a;
|
|
23
|
+
(_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, state);
|
|
24
|
+
}, [state]);
|
|
25
|
+
const updateField = useCallback((key, value) => {
|
|
26
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { [key]: value })));
|
|
27
|
+
}, []);
|
|
28
|
+
const setStudents = useCallback((students) => {
|
|
29
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { students })));
|
|
30
|
+
}, []);
|
|
31
|
+
const removeStudent = useCallback((id) => {
|
|
32
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { students: previous.students.filter((student) => student.id !== id) })));
|
|
33
|
+
}, []);
|
|
34
|
+
const updateStudent = useCallback((id, patch) => {
|
|
35
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { students: previous.students.map((student) => student.id === id ? Object.assign(Object.assign({}, student), patch) : student) })));
|
|
36
|
+
}, []);
|
|
37
|
+
const clearStudents = useCallback(() => {
|
|
38
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { students: [] })));
|
|
39
|
+
}, []);
|
|
40
|
+
const resetRegister = useCallback(() => {
|
|
41
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { className: "", section: "", grade: "", month: currentMonth(), year: new Date().getFullYear(), format: "a4", layout: "monthly", density: "standard", weekStartsOn: "monday", weekendDays: getDefaultWeekendDays(previous.country), noSchoolDaysInput: "", students: [], locale: DEFAULT_REGISTER_LOCALE })));
|
|
42
|
+
}, []);
|
|
43
|
+
const advanceMonth = useCallback(() => {
|
|
44
|
+
const next = getNextMonth(state.month, state.year);
|
|
45
|
+
setState((previous) => (Object.assign(Object.assign({}, previous), { month: next.month, year: next.year, noSchoolDaysInput: "" })));
|
|
46
|
+
return next;
|
|
47
|
+
}, [state.month, state.year]);
|
|
48
|
+
const days = useMemo(() => getDaysInMonth(state.month, state.year, state.weekendDays, state.locale), [state.month, state.year, state.weekendDays, state.locale]);
|
|
49
|
+
const weeks = useMemo(() => getWeekGroups(state.month, state.year, state.weekStartsOn, state.weekendDays, state.locale), [state.month, state.year, state.weekStartsOn, state.weekendDays, state.locale]);
|
|
50
|
+
const parsedNoSchool = useMemo(() => parseNoSchoolDays(state.noSchoolDaysInput, days.length, {
|
|
51
|
+
monthIndex: MONTHS.indexOf(state.month),
|
|
52
|
+
year: state.year,
|
|
53
|
+
}), [state.noSchoolDaysInput, days.length, state.month, state.year]);
|
|
54
|
+
const workingDays = useMemo(() => getWorkingDays(days, parsedNoSchool.days), [days, parsedNoSchool.days]);
|
|
55
|
+
const config = useMemo(() => ({
|
|
56
|
+
className: state.className.trim(),
|
|
57
|
+
section: state.section.trim(),
|
|
58
|
+
grade: state.grade.trim(),
|
|
59
|
+
month: state.month,
|
|
60
|
+
year: state.year,
|
|
61
|
+
format: state.format,
|
|
62
|
+
layout: state.layout,
|
|
63
|
+
density: state.density,
|
|
64
|
+
weekStartsOn: state.weekStartsOn,
|
|
65
|
+
weekendDays: state.weekendDays,
|
|
66
|
+
noSchoolDays: parsedNoSchool.days,
|
|
67
|
+
students: state.students,
|
|
68
|
+
schoolName: state.schoolName.trim(),
|
|
69
|
+
locale: state.locale,
|
|
70
|
+
}), [state, parsedNoSchool.days]);
|
|
71
|
+
const summary = useMemo(() => getRegisterSummary(config), [config]);
|
|
72
|
+
const classLabel = state.className.trim() ? formatClassLabel(config) : "Add a class name";
|
|
73
|
+
const canExportLocal = state.schoolName.trim().length >= 2 &&
|
|
74
|
+
state.className.trim().length > 0 &&
|
|
75
|
+
state.students.length > 0 &&
|
|
76
|
+
parsedNoSchool.invalid.length === 0;
|
|
77
|
+
const localError = state.schoolName.trim().length < 2
|
|
78
|
+
? "Enter a school name (at least 2 characters)."
|
|
79
|
+
: !state.className.trim()
|
|
80
|
+
? "Enter a class name."
|
|
81
|
+
: state.students.length === 0
|
|
82
|
+
? "Add at least one student."
|
|
83
|
+
: parsedNoSchool.invalid.length > 0
|
|
84
|
+
? "Fix the no-school day numbers first."
|
|
85
|
+
: "";
|
|
86
|
+
return {
|
|
87
|
+
state,
|
|
88
|
+
setState,
|
|
89
|
+
updateField,
|
|
90
|
+
setStudents,
|
|
91
|
+
removeStudent,
|
|
92
|
+
updateStudent,
|
|
93
|
+
clearStudents,
|
|
94
|
+
resetRegister,
|
|
95
|
+
advanceMonth,
|
|
96
|
+
days,
|
|
97
|
+
weeks,
|
|
98
|
+
parsedNoSchool,
|
|
99
|
+
workingDays,
|
|
100
|
+
config,
|
|
101
|
+
summary,
|
|
102
|
+
classLabel,
|
|
103
|
+
canExportLocal,
|
|
104
|
+
localError,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared attendance-register domain types.
|
|
3
|
+
*
|
|
4
|
+
* These types are intentionally free of React, Next.js, next-intl and auth
|
|
5
|
+
* concerns so the public schoolkit tool and the fusion SaaS can both use them.
|
|
6
|
+
*/
|
|
7
|
+
export interface Student {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
rollNumber: string;
|
|
11
|
+
/** Optional school-issued identifier. Names are not unique; this is. */
|
|
12
|
+
admissionNumber?: string;
|
|
13
|
+
}
|
|
14
|
+
export type PaperFormat = "a4" | "a3" | "letter" | "legal";
|
|
15
|
+
export type RegisterLayout = "monthly" | "weekly";
|
|
16
|
+
export type WeekStart = "monday" | "sunday";
|
|
17
|
+
export type RegisterDensity = "standard" | "compact";
|
|
18
|
+
/** Short marks printed in the register when recorded attendance is included. */
|
|
19
|
+
export type AttendanceMark = "P" | "A" | "L" | "E" | "H";
|
|
20
|
+
/** JavaScript weekday indices: 0 = Sunday … 6 = Saturday. */
|
|
21
|
+
export declare const DEFAULT_WEEKEND_DAYS: readonly number[];
|
|
22
|
+
export interface RegisterConfig {
|
|
23
|
+
className: string;
|
|
24
|
+
section: string;
|
|
25
|
+
grade: string;
|
|
26
|
+
month: string;
|
|
27
|
+
year: number;
|
|
28
|
+
format: PaperFormat;
|
|
29
|
+
layout: RegisterLayout;
|
|
30
|
+
/** Compact rows fit more students per page; standard rows leave more room to write. */
|
|
31
|
+
density: RegisterDensity;
|
|
32
|
+
weekStartsOn: WeekStart;
|
|
33
|
+
/** Weekday indices treated as closed, e.g. [0, 6] or [5, 6]. */
|
|
34
|
+
weekendDays: number[];
|
|
35
|
+
noSchoolDays: number[];
|
|
36
|
+
students: Student[];
|
|
37
|
+
schoolName: string;
|
|
38
|
+
/** Locale used for month and weekday labels, e.g. "es". */
|
|
39
|
+
locale: string;
|
|
40
|
+
/** Optional marks keyed by student id and day number. */
|
|
41
|
+
attendance?: Record<string, Record<number, AttendanceMark>>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A reusable roster plus its print settings. This is the neutral shape both
|
|
45
|
+
* schoolkit's saved classes and fusion's class-section groups map into.
|
|
46
|
+
*/
|
|
47
|
+
export interface RegisterRoster {
|
|
48
|
+
id?: string;
|
|
49
|
+
className: string;
|
|
50
|
+
section: string;
|
|
51
|
+
grade: string;
|
|
52
|
+
students: Student[];
|
|
53
|
+
weekendDays: number[];
|
|
54
|
+
locale: string;
|
|
55
|
+
format: PaperFormat;
|
|
56
|
+
layout: RegisterLayout;
|
|
57
|
+
density: RegisterDensity;
|
|
58
|
+
weekStartsOn: WeekStart;
|
|
59
|
+
}
|
|
60
|
+
/** Month-specific state shared by both register builders. */
|
|
61
|
+
export interface RegisterFormState {
|
|
62
|
+
schoolName: string;
|
|
63
|
+
country: string;
|
|
64
|
+
locale: string;
|
|
65
|
+
className: string;
|
|
66
|
+
section: string;
|
|
67
|
+
grade: string;
|
|
68
|
+
month: string;
|
|
69
|
+
year: number;
|
|
70
|
+
format: PaperFormat;
|
|
71
|
+
layout: RegisterLayout;
|
|
72
|
+
density: RegisterDensity;
|
|
73
|
+
weekStartsOn: WeekStart;
|
|
74
|
+
weekendDays: number[];
|
|
75
|
+
noSchoolDaysInput: string;
|
|
76
|
+
students: Student[];
|
|
77
|
+
}
|
|
78
|
+
export interface AttendanceDay {
|
|
79
|
+
day: number;
|
|
80
|
+
weekday: string;
|
|
81
|
+
isWeekend: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface WeekGroup {
|
|
84
|
+
weekNumber: number;
|
|
85
|
+
startDay: number;
|
|
86
|
+
endDay: number;
|
|
87
|
+
/** Seven slots, Monday-first or Sunday-first. Null means outside the month. */
|
|
88
|
+
slots: (AttendanceDay | null)[];
|
|
89
|
+
}
|
|
90
|
+
export declare const MONTHS: string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared attendance-register domain types.
|
|
3
|
+
*
|
|
4
|
+
* These types are intentionally free of React, Next.js, next-intl and auth
|
|
5
|
+
* concerns so the public schoolkit tool and the fusion SaaS can both use them.
|
|
6
|
+
*/
|
|
7
|
+
/** JavaScript weekday indices: 0 = Sunday … 6 = Saturday. */
|
|
8
|
+
export const DEFAULT_WEEKEND_DAYS = [0, 6];
|
|
9
|
+
export const MONTHS = [
|
|
10
|
+
"January",
|
|
11
|
+
"February",
|
|
12
|
+
"March",
|
|
13
|
+
"April",
|
|
14
|
+
"May",
|
|
15
|
+
"June",
|
|
16
|
+
"July",
|
|
17
|
+
"August",
|
|
18
|
+
"September",
|
|
19
|
+
"October",
|
|
20
|
+
"November",
|
|
21
|
+
"December",
|
|
22
|
+
];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AdmissionAIBE, AdmissionBE, DiscountCodeBE } from "../../../type";
|
|
2
|
+
import { type StudentUsage } from "../../../utils/student-usage";
|
|
2
3
|
import { type RowAction, type TableRow } from "@appcorp/shadcn/components/enhanced-table";
|
|
3
4
|
export declare const useAdmissionModule: () => {
|
|
4
5
|
applyFilters: () => void;
|
|
@@ -36,6 +37,8 @@ export declare const useAdmissionModule: () => {
|
|
|
36
37
|
}[];
|
|
37
38
|
listLoading: boolean;
|
|
38
39
|
rowActions: RowAction[];
|
|
40
|
+
studentUsage: StudentUsage | null;
|
|
41
|
+
refreshStudentUsage: () => Promise<void>;
|
|
39
42
|
updateLoading: boolean;
|
|
40
43
|
uploadAdmissionDocuments: (files: File[]) => Promise<string[]>;
|
|
41
44
|
state: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useTheme } from "next-themes";
|
|
4
4
|
import { useTranslations } from "next-intl";
|
|
5
5
|
import { isCreatedOrUpdated } from "@react-pakistan/util-functions/general/is-created-or-updated";
|
|
@@ -17,6 +17,8 @@ import { getCachedWorkspaceSync } from "../../workspace/cache";
|
|
|
17
17
|
import { downloadAdmissionFormPDF, } from "../../../utils/admission-pdf";
|
|
18
18
|
import { compressPdf, DocumentTooLargeError, isPdfFile, MAX_DOCUMENT_SIZE_BYTES, } from "../../../utils/compress-pdf";
|
|
19
19
|
import { uploadFiles } from "../../../utils/upload-file";
|
|
20
|
+
import { emitStudentUsageChanged, onStudentUsageChanged, } from "../../../utils/student-usage";
|
|
21
|
+
import { fetchStudentUsage } from "../../../utils/student-usage-api";
|
|
20
22
|
import { wakeStorageServer } from "../../../utils/wake-storage";
|
|
21
23
|
import { normalizeIdNumber } from "../../../utils/id-number";
|
|
22
24
|
import { isGovernmentIdType, } from "../../../utils/government-id";
|
|
@@ -34,6 +36,7 @@ export const useAdmissionModule = () => {
|
|
|
34
36
|
const t = useTranslations("admission");
|
|
35
37
|
const { theme } = useTheme();
|
|
36
38
|
const workspace = getCachedWorkspaceSync();
|
|
39
|
+
const [studentUsage, setStudentUsage] = useState(null);
|
|
37
40
|
const listFetchNowRef = useRef(null);
|
|
38
41
|
const debouncedQuery = useDebounce(state.searchQuery, 800);
|
|
39
42
|
// Discount codes are school-scoped; fetch once (not per render) so both the
|
|
@@ -347,6 +350,13 @@ export const useAdmissionModule = () => {
|
|
|
347
350
|
});
|
|
348
351
|
return uploaded.map((file) => file.url);
|
|
349
352
|
}, [workspace === null || workspace === void 0 ? void 0 : workspace.id]);
|
|
353
|
+
const refreshStudentUsage = useCallback(async () => {
|
|
354
|
+
if (!(workspace === null || workspace === void 0 ? void 0 : workspace.id))
|
|
355
|
+
return;
|
|
356
|
+
const usage = await fetchStudentUsage(workspace.id);
|
|
357
|
+
if (usage)
|
|
358
|
+
setStudentUsage(usage);
|
|
359
|
+
}, [workspace === null || workspace === void 0 ? void 0 : workspace.id]);
|
|
350
360
|
// ============================================================================
|
|
351
361
|
// 1.4.5 API HOOKS
|
|
352
362
|
// ============================================================================
|
|
@@ -635,6 +645,8 @@ export const useAdmissionModule = () => {
|
|
|
635
645
|
}),
|
|
636
646
|
});
|
|
637
647
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
648
|
+
emitStudentUsageChanged();
|
|
649
|
+
await refreshStudentUsage();
|
|
638
650
|
// `fetchData` returns the error body as `data` on failure — check the
|
|
639
651
|
// error first so we never show both toasts.
|
|
640
652
|
if (error) {
|
|
@@ -644,7 +656,7 @@ export const useAdmissionModule = () => {
|
|
|
644
656
|
if (data) {
|
|
645
657
|
showToast(t("messagesAdmitSuccess"), TOAST_VARIANT.SUCCESS);
|
|
646
658
|
}
|
|
647
|
-
}, [t, showToast, (_k = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _k === void 0 ? void 0 : _k.id]);
|
|
659
|
+
}, [t, showToast, (_k = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _k === void 0 ? void 0 : _k.id, refreshStudentUsage]);
|
|
648
660
|
// ============================================================================
|
|
649
661
|
// 1.4.7 NETWORK ACTIONS
|
|
650
662
|
// ============================================================================
|
|
@@ -972,8 +984,10 @@ export const useAdmissionModule = () => {
|
|
|
972
984
|
order: 5,
|
|
973
985
|
},
|
|
974
986
|
{
|
|
975
|
-
enabled: (row) => (row === null || row === void 0 ? void 0 : row.status) === ADMISSION_STATUS.APPROVED
|
|
976
|
-
|
|
987
|
+
enabled: (row) => (row === null || row === void 0 ? void 0 : row.status) === ADMISSION_STATUS.APPROVED &&
|
|
988
|
+
!(studentUsage === null || studentUsage === void 0 ? void 0 : studentUsage.reached),
|
|
989
|
+
// eslint-disable-next-line react-hooks/refs -- invoked on click, not during render
|
|
990
|
+
handleOnClick: (row) => handleAddStudent(row),
|
|
977
991
|
label: t("actionsButtonAddStudent"),
|
|
978
992
|
order: 6,
|
|
979
993
|
},
|
|
@@ -986,7 +1000,8 @@ export const useAdmissionModule = () => {
|
|
|
986
1000
|
{
|
|
987
1001
|
enabled: (row) => hasGeminiSecrets &&
|
|
988
1002
|
(row === null || row === void 0 ? void 0 : row.status) === ADMISSION_STATUS.PENDING,
|
|
989
|
-
|
|
1003
|
+
// eslint-disable-next-line react-hooks/refs -- invoked on click, not during render
|
|
1004
|
+
handleOnClick: (row) => handleAnalyze(row),
|
|
990
1005
|
label: t("actionsButtonAnalyzeWithAi"),
|
|
991
1006
|
order: 8,
|
|
992
1007
|
},
|
|
@@ -1008,6 +1023,7 @@ export const useAdmissionModule = () => {
|
|
|
1008
1023
|
handleAnalyze,
|
|
1009
1024
|
handleDelete,
|
|
1010
1025
|
hasGeminiSecrets,
|
|
1026
|
+
studentUsage === null || studentUsage === void 0 ? void 0 : studentUsage.reached,
|
|
1011
1027
|
t,
|
|
1012
1028
|
]);
|
|
1013
1029
|
const applyFilters = useCallback(() => {
|
|
@@ -1041,6 +1057,24 @@ export const useAdmissionModule = () => {
|
|
|
1041
1057
|
useEffect(() => {
|
|
1042
1058
|
listFetchNowRef.current = listFetchNow;
|
|
1043
1059
|
}, [listFetchNow]);
|
|
1060
|
+
useEffect(() => {
|
|
1061
|
+
if (!(workspace === null || workspace === void 0 ? void 0 : workspace.id))
|
|
1062
|
+
return;
|
|
1063
|
+
let active = true;
|
|
1064
|
+
const load = async () => {
|
|
1065
|
+
const usage = await fetchStudentUsage(workspace.id);
|
|
1066
|
+
if (active && usage)
|
|
1067
|
+
setStudentUsage(usage);
|
|
1068
|
+
};
|
|
1069
|
+
void load();
|
|
1070
|
+
const unsubscribe = onStudentUsageChanged(() => {
|
|
1071
|
+
void load();
|
|
1072
|
+
});
|
|
1073
|
+
return () => {
|
|
1074
|
+
active = false;
|
|
1075
|
+
unsubscribe();
|
|
1076
|
+
};
|
|
1077
|
+
}, [workspace === null || workspace === void 0 ? void 0 : workspace.id]);
|
|
1044
1078
|
useEffect(() => {
|
|
1045
1079
|
var _a;
|
|
1046
1080
|
if (!(workspace === null || workspace === void 0 ? void 0 : workspace.id))
|
|
@@ -1079,6 +1113,8 @@ export const useAdmissionModule = () => {
|
|
|
1079
1113
|
headerActions,
|
|
1080
1114
|
listLoading,
|
|
1081
1115
|
rowActions,
|
|
1116
|
+
studentUsage,
|
|
1117
|
+
refreshStudentUsage,
|
|
1082
1118
|
updateLoading,
|
|
1083
1119
|
uploadAdmissionDocuments });
|
|
1084
1120
|
};
|
|
@@ -78,6 +78,26 @@ const GenericAttendancePage = createGenericModulePage();
|
|
|
78
78
|
const AttendancePageInner = (props) => {
|
|
79
79
|
const context = useAttendanceModule();
|
|
80
80
|
const t = useTranslations("attendance");
|
|
81
|
+
const pageContext = useMemo(() => {
|
|
82
|
+
var _a;
|
|
83
|
+
if (!props.registerHref)
|
|
84
|
+
return context;
|
|
85
|
+
return Object.assign(Object.assign({}, context), { headerActions: [
|
|
86
|
+
...context.headerActions,
|
|
87
|
+
{
|
|
88
|
+
enabled: true,
|
|
89
|
+
handleOnClick: () => {
|
|
90
|
+
window.location.assign(props.registerHref);
|
|
91
|
+
},
|
|
92
|
+
label: (_a = props.labelRegister) !== null && _a !== void 0 ? _a : "Attendance Register",
|
|
93
|
+
order: context.headerActions.length,
|
|
94
|
+
},
|
|
95
|
+
] });
|
|
96
|
+
}, [
|
|
97
|
+
context,
|
|
98
|
+
props.labelRegister,
|
|
99
|
+
props.registerHref,
|
|
100
|
+
]);
|
|
81
101
|
const statusLabels = useMemo(() => ({
|
|
82
102
|
PRESENT: t("formOptionPresent"),
|
|
83
103
|
ABSENT: t("formOptionAbsent"),
|
|
@@ -175,6 +195,6 @@ const AttendancePageInner = (props) => {
|
|
|
175
195
|
if (!hasPermission) {
|
|
176
196
|
return _jsx(RbacNoAccess, { moduleName: "Attendance" });
|
|
177
197
|
}
|
|
178
|
-
return (_jsx("div", { className: "p-4", children: _jsx(GenericAttendancePage, { overrideConfig: attendanceConfig, context:
|
|
198
|
+
return (_jsx("div", { className: "p-4", children: _jsx(GenericAttendancePage, { overrideConfig: attendanceConfig, context: pageContext, tableBodyCols: tableBodyCols }) }));
|
|
179
199
|
};
|
|
180
200
|
export const AttendancePage = (props) => (_jsx(AttendanceProvider, { children: _jsx(AttendancePageInner, Object.assign({}, props)) }));
|
|
@@ -13,6 +13,7 @@ import { toE164Phone } from "../../../utils/to-e164-phone";
|
|
|
13
13
|
import { STUDENT_PROFILE_API_ROUTES } from "../../../constants";
|
|
14
14
|
import { studentProfileFormValidation } from "../validate";
|
|
15
15
|
import { getCachedWorkspaceSync } from "../../workspace/cache";
|
|
16
|
+
import { emitStudentUsageChanged } from "../../../utils/student-usage";
|
|
16
17
|
import { useStudentProfileContext, STUDENT_PROFILE_ACTION_TYPES, STUDENT_PROFILE_DRAWER, } from "./module-base";
|
|
17
18
|
export const useStudentProfileModule = () => {
|
|
18
19
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -184,6 +185,7 @@ export const useStudentProfileModule = () => {
|
|
|
184
185
|
showToast(isCreated ? t("messagesCreateSuccess") : t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
|
|
185
186
|
resetFormAndCloseDrawer();
|
|
186
187
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
188
|
+
emitStudentUsageChanged();
|
|
187
189
|
}
|
|
188
190
|
}, [dispatch, resetFormAndCloseDrawer, showToast, t]);
|
|
189
191
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
@@ -236,6 +238,7 @@ export const useStudentProfileModule = () => {
|
|
|
236
238
|
if (data) {
|
|
237
239
|
showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
|
|
238
240
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
241
|
+
emitStudentUsageChanged();
|
|
239
242
|
}
|
|
240
243
|
}, [showToast, t]);
|
|
241
244
|
const { byIdFetchNow, byIdLoading, deleteFetchNow, deleteLoading, listFetchNow, listLoading, updateFetchNow, updateLoading, } = useModuleEntityV2({
|
|
@@ -442,6 +445,7 @@ export const useStudentProfileModule = () => {
|
|
|
442
445
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
443
446
|
if (data) {
|
|
444
447
|
showToast(t("messagesReAdmitSuccess"), TOAST_VARIANT.SUCCESS);
|
|
448
|
+
emitStudentUsageChanged();
|
|
445
449
|
}
|
|
446
450
|
if (error) {
|
|
447
451
|
showToast(t("messagesReAdmitFailed"), TOAST_VARIANT.ERROR);
|
|
@@ -22,12 +22,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
22
22
|
agreedPrice: number;
|
|
23
23
|
billingDate: null;
|
|
24
24
|
billingInterval: string;
|
|
25
|
-
classesCount: number;
|
|
26
|
-
coursesCount: number;
|
|
27
25
|
description: string;
|
|
28
26
|
dueDateLength: number;
|
|
29
27
|
enabled: boolean;
|
|
30
|
-
familiesCount: number;
|
|
31
28
|
id: string;
|
|
32
29
|
logo: string;
|
|
33
30
|
logoFile: File | null;
|
|
@@ -41,11 +38,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
41
38
|
planId: string;
|
|
42
39
|
planStartDate: null;
|
|
43
40
|
secrets: {};
|
|
44
|
-
staffAccountsCount: number;
|
|
45
|
-
storageUsedMB: number;
|
|
46
41
|
studentsCount: number;
|
|
42
|
+
studentLimit: number | null;
|
|
47
43
|
subdomain: string;
|
|
48
|
-
teachersCount: number;
|
|
49
44
|
disableSaveButton: boolean;
|
|
50
45
|
drawer: null;
|
|
51
46
|
errors: Record<string, string>;
|
|
@@ -54,12 +49,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
54
49
|
agreedPrice: number;
|
|
55
50
|
billingDate: null;
|
|
56
51
|
billingInterval: string;
|
|
57
|
-
classesCount: number;
|
|
58
|
-
coursesCount: number;
|
|
59
52
|
description: string;
|
|
60
53
|
dueDateLength: number;
|
|
61
54
|
enabled: boolean;
|
|
62
|
-
familiesCount: number;
|
|
63
55
|
id: string;
|
|
64
56
|
logo: string;
|
|
65
57
|
logoFile: File | null;
|
|
@@ -73,11 +65,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
73
65
|
planId: string;
|
|
74
66
|
planStartDate: null;
|
|
75
67
|
secrets: {};
|
|
76
|
-
staffAccountsCount: number;
|
|
77
|
-
storageUsedMB: number;
|
|
78
68
|
studentsCount: number;
|
|
69
|
+
studentLimit: number | null;
|
|
79
70
|
subdomain: string;
|
|
80
|
-
teachersCount: number;
|
|
81
71
|
disableSaveButton: boolean;
|
|
82
72
|
drawer: null;
|
|
83
73
|
errors: Record<string, string>;
|
|
@@ -88,12 +78,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
88
78
|
agreedPrice: number;
|
|
89
79
|
billingDate: null;
|
|
90
80
|
billingInterval: string;
|
|
91
|
-
classesCount: number;
|
|
92
|
-
coursesCount: number;
|
|
93
81
|
description: string;
|
|
94
82
|
dueDateLength: number;
|
|
95
83
|
enabled: boolean;
|
|
96
|
-
familiesCount: number;
|
|
97
84
|
id: string;
|
|
98
85
|
logo: string;
|
|
99
86
|
logoFile: File | null;
|
|
@@ -107,11 +94,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
107
94
|
planId: string;
|
|
108
95
|
planStartDate: null;
|
|
109
96
|
secrets: {};
|
|
110
|
-
staffAccountsCount: number;
|
|
111
|
-
storageUsedMB: number;
|
|
112
97
|
studentsCount: number;
|
|
98
|
+
studentLimit: number | null;
|
|
113
99
|
subdomain: string;
|
|
114
|
-
teachersCount: number;
|
|
115
100
|
disableSaveButton: boolean;
|
|
116
101
|
drawer: null;
|
|
117
102
|
errors: Record<string, string>;
|
|
@@ -120,12 +105,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
120
105
|
agreedPrice: number;
|
|
121
106
|
billingDate: null;
|
|
122
107
|
billingInterval: string;
|
|
123
|
-
classesCount: number;
|
|
124
|
-
coursesCount: number;
|
|
125
108
|
description: string;
|
|
126
109
|
dueDateLength: number;
|
|
127
110
|
enabled: boolean;
|
|
128
|
-
familiesCount: number;
|
|
129
111
|
id: string;
|
|
130
112
|
logo: string;
|
|
131
113
|
logoFile: File | null;
|
|
@@ -139,11 +121,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
139
121
|
planId: string;
|
|
140
122
|
planStartDate: null;
|
|
141
123
|
secrets: {};
|
|
142
|
-
staffAccountsCount: number;
|
|
143
|
-
storageUsedMB: number;
|
|
144
124
|
studentsCount: number;
|
|
125
|
+
studentLimit: number | null;
|
|
145
126
|
subdomain: string;
|
|
146
|
-
teachersCount: number;
|
|
147
127
|
disableSaveButton: boolean;
|
|
148
128
|
drawer: null;
|
|
149
129
|
errors: Record<string, string>;
|
|
@@ -152,12 +132,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
152
132
|
agreedPrice: number;
|
|
153
133
|
billingDate: null;
|
|
154
134
|
billingInterval: string;
|
|
155
|
-
classesCount: number;
|
|
156
|
-
coursesCount: number;
|
|
157
135
|
description: string;
|
|
158
136
|
dueDateLength: number;
|
|
159
137
|
enabled: boolean;
|
|
160
|
-
familiesCount: number;
|
|
161
138
|
id: string;
|
|
162
139
|
logo: string;
|
|
163
140
|
logoFile: File | null;
|
|
@@ -171,11 +148,9 @@ export declare const WORKSPACE_ACTION_TYPES: {
|
|
|
171
148
|
planId: string;
|
|
172
149
|
planStartDate: null;
|
|
173
150
|
secrets: {};
|
|
174
|
-
staffAccountsCount: number;
|
|
175
|
-
storageUsedMB: number;
|
|
176
151
|
studentsCount: number;
|
|
152
|
+
studentLimit: number | null;
|
|
177
153
|
subdomain: string;
|
|
178
|
-
teachersCount: number;
|
|
179
154
|
disableSaveButton: boolean;
|
|
180
155
|
drawer: null;
|
|
181
156
|
errors: Record<string, string>;
|
|
@@ -206,12 +181,9 @@ export declare const useWorkspaceModule: () => {
|
|
|
206
181
|
agreedPrice: number;
|
|
207
182
|
billingDate: null;
|
|
208
183
|
billingInterval: string;
|
|
209
|
-
classesCount: number;
|
|
210
|
-
coursesCount: number;
|
|
211
184
|
description: string;
|
|
212
185
|
dueDateLength: number;
|
|
213
186
|
enabled: boolean;
|
|
214
|
-
familiesCount: number;
|
|
215
187
|
id: string;
|
|
216
188
|
logo: string;
|
|
217
189
|
logoFile: File | null;
|
|
@@ -225,11 +197,9 @@ export declare const useWorkspaceModule: () => {
|
|
|
225
197
|
planId: string;
|
|
226
198
|
planStartDate: null;
|
|
227
199
|
secrets: {};
|
|
228
|
-
staffAccountsCount: number;
|
|
229
|
-
storageUsedMB: number;
|
|
230
200
|
studentsCount: number;
|
|
201
|
+
studentLimit: number | null;
|
|
231
202
|
subdomain: string;
|
|
232
|
-
teachersCount: number;
|
|
233
203
|
disableSaveButton: boolean;
|
|
234
204
|
drawer: null;
|
|
235
205
|
errors: Record<string, string>;
|
|
@@ -51,12 +51,9 @@ const workspaceConfig = {
|
|
|
51
51
|
agreedPrice: 0,
|
|
52
52
|
billingDate: null,
|
|
53
53
|
billingInterval: "",
|
|
54
|
-
classesCount: 0,
|
|
55
|
-
coursesCount: 0,
|
|
56
54
|
description: "",
|
|
57
55
|
dueDateLength: 0,
|
|
58
56
|
enabled: true,
|
|
59
|
-
familiesCount: 0,
|
|
60
57
|
id: "",
|
|
61
58
|
logo: "",
|
|
62
59
|
logoFile: null,
|
|
@@ -66,11 +63,9 @@ const workspaceConfig = {
|
|
|
66
63
|
planId: "",
|
|
67
64
|
planStartDate: null,
|
|
68
65
|
secrets: {},
|
|
69
|
-
staffAccountsCount: 0,
|
|
70
|
-
storageUsedMB: 0,
|
|
71
66
|
studentsCount: 0,
|
|
67
|
+
studentLimit: null,
|
|
72
68
|
subdomain: "",
|
|
73
|
-
teachersCount: 0,
|
|
74
69
|
// UI State
|
|
75
70
|
disableSaveButton: false,
|
|
76
71
|
drawer: null,
|
|
@@ -162,12 +157,9 @@ export const useWorkspaceModule = () => {
|
|
|
162
157
|
agreedPrice: state.agreedPrice,
|
|
163
158
|
billingDate: state.billingDate,
|
|
164
159
|
billingInterval: state.billingInterval,
|
|
165
|
-
classesCount: state.classesCount,
|
|
166
|
-
coursesCount: state.coursesCount,
|
|
167
160
|
description: state.description,
|
|
168
161
|
dueDateLength: state.dueDateLength,
|
|
169
162
|
enabled: state.enabled,
|
|
170
|
-
familiesCount: state.familiesCount,
|
|
171
163
|
id: state.id,
|
|
172
164
|
logo: state.logo,
|
|
173
165
|
name: state.name,
|
|
@@ -175,22 +167,15 @@ export const useWorkspaceModule = () => {
|
|
|
175
167
|
planId: state.planId,
|
|
176
168
|
planStartDate: state.planStartDate,
|
|
177
169
|
secrets: state.secrets,
|
|
178
|
-
staffAccountsCount: state.staffAccountsCount,
|
|
179
|
-
storageUsedMB: state.storageUsedMB,
|
|
180
|
-
studentsCount: state.studentsCount,
|
|
181
170
|
subdomain: state.subdomain,
|
|
182
|
-
teachersCount: state.teachersCount,
|
|
183
171
|
}), [
|
|
184
172
|
state.agreedCurrency,
|
|
185
173
|
state.agreedPrice,
|
|
186
174
|
state.billingDate,
|
|
187
175
|
state.billingInterval,
|
|
188
|
-
state.classesCount,
|
|
189
|
-
state.coursesCount,
|
|
190
176
|
state.description,
|
|
191
177
|
state.dueDateLength,
|
|
192
178
|
state.enabled,
|
|
193
|
-
state.familiesCount,
|
|
194
179
|
state.id,
|
|
195
180
|
state.logo,
|
|
196
181
|
state.name,
|
|
@@ -198,11 +183,7 @@ export const useWorkspaceModule = () => {
|
|
|
198
183
|
state.planId,
|
|
199
184
|
state.planStartDate,
|
|
200
185
|
state.secrets,
|
|
201
|
-
state.staffAccountsCount,
|
|
202
|
-
state.storageUsedMB,
|
|
203
|
-
state.studentsCount,
|
|
204
186
|
state.subdomain,
|
|
205
|
-
state.teachersCount,
|
|
206
187
|
]);
|
|
207
188
|
// ============================================================================
|
|
208
189
|
// 1.5.3 UTILITIES
|