From 4c381af88c874dd58ec1123838ac3366145307a5 Mon Sep 17 00:00:00 2001 From: yael-miller Date: Mon, 16 Feb 2026 12:43:54 +0000 Subject: [PATCH 1/5] add Student Event Report create form with dynamic fields --- client/src/App.jsx | 6 +- client/src/domainTranslations.js | 18 +- client/src/entities/student-event-report.jsx | 169 +++++++++++++++++++ client/src/utils/appPermissions.js | 4 + 4 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 client/src/entities/student-event-report.jsx diff --git a/client/src/App.jsx b/client/src/App.jsx index 30399a52..a11f0ef0 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -40,6 +40,7 @@ import teacher from "src/entities/teacher"; import transportation from 'src/entities/transportation'; import absenceType from 'src/entities/absenceType'; import studentKlassesReport from "src/entities/student-klasses-report"; +import studentEventReport from "src/entities/student-event-report"; import reportMonth from "src/entities/report-month"; import teacherReportStatus from "src/entities/teacher-report-status"; import teacherGradeReportStatus from "src/entities/teacher-grade-report-status"; @@ -68,7 +69,7 @@ import paymentTrack from '@shared/components/common-entities/payment-track'; import yemotCall from '@shared/components/common-entities/yemot-call'; import { isShowUsersData, isEditPagesData, isEditPaymentTracksData, isAdmin } from "@shared/utils/permissionsUtil"; -import { isLessonSignature, isOnlyInLessonReport, isTeacherView, isTransportation, isAbsenceType } from 'src/utils/appPermissions'; +import { isLessonSignature, isOnlyInLessonReport, isTeacherView, isTransportation, isAbsenceType, isStudentView } from 'src/utils/appPermissions'; import YemotSimulator from "@shared/components/views/YemotSimulator"; import { RegisterPage } from '@shared/components/layout/RegisterPage'; import { LoginPage } from '@shared/components/layout/LoginPage'; @@ -110,6 +111,7 @@ import LocalAtmIcon from '@mui/icons-material/LocalAtm'; import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings'; import DirectionsBusIcon from '@mui/icons-material/DirectionsBus'; import CelebrationIcon from '@mui/icons-material/Celebration'; +import EventNoteIcon from '@mui/icons-material/EventNote'; const i18nProvider = getI18nProvider(domainTranslations); @@ -168,7 +170,7 @@ const App = () => ( - + {(isStudentView(permissions) || isAdmin(permissions)) && } diff --git a/client/src/domainTranslations.js b/client/src/domainTranslations.js index 45972b2b..42181dc8 100644 --- a/client/src/domainTranslations.js +++ b/client/src/domainTranslations.js @@ -141,7 +141,22 @@ export default { reason: 'סיבה', comment: 'הערה', isApproved: 'מאושר', - absenceTypeId: 'סוג אירוע', + absenceTypeId: 'סוג אירוע', + } + }, + student_event_report: { + name: 'דיווח אירוע לתלמידה', + fields: { + ...generalResourceFieldsTranslation, + studentReferenceId: 'תלמידה', + klassReferenceId: 'כיתה', + absenceTypeId: 'סוג אירוע', + reportDate: 'תאריך', + absnceCount: 'כמות', + senderName: 'שם שולח', + reason: 'סיבה', + year: 'שנה', + isApproved: 'מאושר' } }, lesson: { @@ -213,6 +228,7 @@ export default { name: 'אירוע |||| אירועים', fields: { ...generalResourceFieldsTranslation, + absenceTypeId: 'סוג אירוע', name: 'שם האירוע', quota: 'מכסה שנתית', requiredLabels: 'שדות חובה לדיווח', diff --git a/client/src/entities/student-event-report.jsx b/client/src/entities/student-event-report.jsx new file mode 100644 index 00000000..8de14d99 --- /dev/null +++ b/client/src/entities/student-event-report.jsx @@ -0,0 +1,169 @@ +import React from 'react'; +import { + TextInput, + NumberInput, + DateInput, + BooleanInput, + required, + useNotify, + useRedirect, + useDataProvider, + useGetOne, + Create, + SimpleForm, + FormDataConsumer, + Loading, +} from 'react-admin'; + +import { filterByUserIdAndYear } from '@shared/components/fields/CommonReferenceInputFilter'; +import CommonReferenceInput from '@shared/components/fields/CommonReferenceInput'; +import { defaultYearFilter, yearChoices } from '@shared/utils/yearFilter'; +import CommonAutocompleteInput from '@shared/components/fields/CommonAutocompleteInput'; +import { handleActionSuccess, handleError } from '@shared/utils/notifyUtil'; + + +const DynamicFields = ({ absenceTypeId }) => { + const { data, isLoading } = useGetOne( + 'absence_type', + { id: absenceTypeId }, + { enabled: !!absenceTypeId } + ); + + if (isLoading) return ; + if (!data?.requiredLabels?.length) return null; + + return ( +
+ {data.requiredLabels.map((label, index) => ( + + ))} +
+ ); +}; + +const formatPayload = (values) => { + const extraInfo = Object.keys(values) + .filter(key => key.startsWith('dynamic_') && values[key]) + .map(key => { + const label = key.replace('dynamic_', ''); + return `${label}: ${values[key]}`; + }) + .join(' | '); + + const { ...cleanValues } = values; + Object.keys(cleanValues).forEach(key => { + if (key.startsWith('dynamic_')) delete cleanValues[key]; + }); + + return { + ...cleanValues, + userId: cleanValues.userId, + year: parseInt(cleanValues.year), + reportDate: cleanValues.reportDate ? new Date(cleanValues.reportDate).toISOString() : new Date().toISOString(), + absnceCount: parseFloat(cleanValues.absnceCount) || 1, + absnceCode: 0, + klassId: 0, + lessonId: 0, + isApproved: true, + reason: cleanValues.reason ? `${cleanValues.reason} [${extraInfo}]` : extraInfo, + }; +}; + +const StudentEventReportCreate = (props) => { + const dataProvider = useDataProvider(); + const notify = useNotify(); + const redirect = useRedirect(); + + const handleSave = async (values) => { + try { + const { data: absenceType } = await dataProvider.getOne('absence_type', { + id: values.absenceTypeId + }); + + const quota = absenceType?.quota; + + if (quota !== undefined && quota !== null) { + const { data: existingAbsences } = await dataProvider.getList('known_absence', { + pagination: { page: 1, perPage: 1000 }, + filter: { + studentReferenceId: values.studentReferenceId, + absenceTypeId: values.absenceTypeId, + year: values.year + }, + }); + + const currentTotal = existingAbsences.reduce((sum, item) => sum + (parseFloat(item.absnceCount) || 0), 0); + const requestedAmount = parseFloat(values.absnceCount || 1); + + if (currentTotal + requestedAmount > quota) { + notify( + `חריגה מהמכסה! המכסה היא ${quota}. נוצלו ${currentTotal}, ניסיון להוסיף ${requestedAmount}.`, + { type: 'error', autoHideDuration: 10000 } + ); + return; + } + } + + const formattedData = formatPayload(values); + const response = await dataProvider.create('known_absence', { data: formattedData }); + handleActionSuccess(notify)(response); + redirect('/known_absence'); + + } catch (error) { + handleError(notify)(err); + } + }; + + return ( + + + + + + + + + + + {({ formData }) => ( + + )} + + + + + + + + + + + ); +}; + +export default { + create: StudentEventReportCreate, + list: StudentEventReportCreate, +}; \ No newline at end of file diff --git a/client/src/utils/appPermissions.js b/client/src/utils/appPermissions.js index c938a286..4fd1d87f 100644 --- a/client/src/utils/appPermissions.js +++ b/client/src/utils/appPermissions.js @@ -12,6 +12,7 @@ export const appPermissions = { teacherView: 'teacherView', transportation: 'transportation', absenceType: 'absenceType', + studentView: 'studentView', }; export const isScannerUpload = (permissions) => hasPermissionLogic(permissions, appPermissions.scannerUpload); @@ -47,3 +48,6 @@ export const useIsTransportation = () => useHasPermission(appPermissions.transpo export const isAbsenceType = (permissions) => hasPermissionLogic(permissions, appPermissions.absenceType); export const useIsisAbsenceType = () => useHasPermission(appPermissions.absenceType); +export const isStudentView = (permissions) => hasPermissionLogic(permissions, appPermissions.studentView); +export const useIsisStudentView = () => useHasPermission(appPermissions.studentView); + From 6ba2dc05320c44ad4e6cbd948ff472d8fe2ed7a5 Mon Sep 17 00:00:00 2001 From: yael-miller Date: Thu, 19 Feb 2026 16:32:58 +0000 Subject: [PATCH 2/5] Implementing authorization logic and updating the identity of a logged-in student in the report form. --- client/src/App.jsx | 12 +- client/src/GeneralLayout.jsx | 16 +-- client/src/RootDashboard.jsx | 15 ++- .../components/StudentView/StudentAccess.jsx | 118 ++++++++++++++++++ .../StudentView}/student-event-report.jsx | 61 +++------ 5 files changed, 166 insertions(+), 56 deletions(-) create mode 100644 client/src/components/StudentView/StudentAccess.jsx rename client/src/{entities => components/StudentView}/student-event-report.jsx (77%) diff --git a/client/src/App.jsx b/client/src/App.jsx index a11f0ef0..52d44214 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -40,7 +40,7 @@ import teacher from "src/entities/teacher"; import transportation from 'src/entities/transportation'; import absenceType from 'src/entities/absenceType'; import studentKlassesReport from "src/entities/student-klasses-report"; -import studentEventReport from "src/entities/student-event-report"; +import StudentEventReport from "src/components/StudentView/student-event-report"; import reportMonth from "src/entities/report-month"; import teacherReportStatus from "src/entities/teacher-report-status"; import teacherGradeReportStatus from "src/entities/teacher-grade-report-status"; @@ -111,7 +111,6 @@ import LocalAtmIcon from '@mui/icons-material/LocalAtm'; import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings'; import DirectionsBusIcon from '@mui/icons-material/DirectionsBus'; import CelebrationIcon from '@mui/icons-material/Celebration'; -import EventNoteIcon from '@mui/icons-material/EventNote'; const i18nProvider = getI18nProvider(domainTranslations); @@ -125,6 +124,7 @@ const App = () => ( {permissions => { const onlyInLesson = isOnlyInLessonReport(permissions) && !isAdmin(permissions); const teacherView = isTeacherView(permissions) && !isAdmin(permissions); + const studentView = isStudentView(permissions) && !isAdmin(permissions); if (onlyInLesson) { return ( <> @@ -153,8 +153,11 @@ const App = () => ( ); } - - + if (studentView) { + return( + <> + ); + } return ( <> @@ -170,7 +173,6 @@ const App = () => ( - {(isStudentView(permissions) || isAdmin(permissions)) && } diff --git a/client/src/GeneralLayout.jsx b/client/src/GeneralLayout.jsx index 9d1d69a1..46d84a56 100644 --- a/client/src/GeneralLayout.jsx +++ b/client/src/GeneralLayout.jsx @@ -19,11 +19,11 @@ import ViewListIcon from '@mui/icons-material/ViewList'; import BaseLayout from "@shared/components/layout/Layout"; import BaseDashboard from '@shared/components/views/Dashboard'; -import { isInLessonReport, isScannerUpload, isOnlyInLessonReport, isTeacherView } from './utils/appPermissions'; +import { isInLessonReport, isScannerUpload, isOnlyInLessonReport, isTeacherView, isStudentView } from './utils/appPermissions'; import { useDashboardItems } from './settings/settingsUtil'; -const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions); -const shouldShowLessonReports = (permissions) => isInLessonReport(permissions) || isTeacherView(permissions); +const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions) && !isStudentView(permissions); +const shouldShowLessonReports = (permissions) => (isInLessonReport(permissions) || isTeacherView(permissions)) && !isStudentView(permissions); const customMenuItems = [ // static items: render only when NOT restricted to lesson-report-only @@ -36,18 +36,18 @@ const customMenuItems = [ // lesson report links: show when user has lesson-report permission OR when they're in-only mode ({ permissions }) => (shouldShowLessonReports(permissions)) && } />, ({ permissions }) => (shouldShowLessonReports(permissions)) && } />, - ({ permissions }) => isStandardView(permissions) && } />, - ({ permissions }) => isStandardView(permissions) && } />, - ({ permissions }) => isStandardView(permissions) && } />, + ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && } />, + ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && } />, + ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && } />, ]; const menuGroups = [ - ({ permissions }) => (isStandardView(permissions)) && ({ + ({ permissions }) => ((isStandardView(permissions)) && (!isStudentView(permissions))) && ({ name: 'data', icon: , routes: [ } /> ] }), - ({ permissions }) => !isOnlyInLessonReport(permissions) && ({ + ({ permissions }) => (!isOnlyInLessonReport(permissions) && (!isStudentView(permissions))) && ({ name: 'report', icon: , routes: [ ({ permissions }) => !isTeacherView(permissions) && } />, } />, diff --git a/client/src/RootDashboard.jsx b/client/src/RootDashboard.jsx index 9e7a81bb..aafd6c73 100644 --- a/client/src/RootDashboard.jsx +++ b/client/src/RootDashboard.jsx @@ -1,10 +1,14 @@ import React from 'react'; import { Dashboard } from 'src/GeneralLayout'; -import { useIsTeacherView } from 'src/utils/appPermissions'; +import { useIsTeacherView, useIsisStudentView } from 'src/utils/appPermissions'; import { TeacherGuard } from 'src/components/TeacherView/TeacherAccess'; +import { StudentGuard } from './components/StudentView/StudentAccess'; +import StudentEventReport from './components/StudentView/student-event-report'; export const RootDashboard = (props) => { const isTeacherView = useIsTeacherView(); + const isStudentView = useIsisStudentView(); + if (isTeacherView) { return ( @@ -14,6 +18,13 @@ export const RootDashboard = (props) => { ); } else { - return ; + if (isStudentView) { + return ( + + + + ); + } + else return ; } } diff --git a/client/src/components/StudentView/StudentAccess.jsx b/client/src/components/StudentView/StudentAccess.jsx new file mode 100644 index 00000000..bb1ccbfa --- /dev/null +++ b/client/src/components/StudentView/StudentAccess.jsx @@ -0,0 +1,118 @@ +import React from "react"; +import { useDataProvider, SimpleForm, TextInput, useNotify, Toolbar, SaveButton, useResetStore } from "react-admin"; +import { useObjectStore } from "src/utils/storeUtil"; +import Button from "@mui/material/Button"; +import Card from "@mui/material/Card"; +import CardContent from "@mui/material/CardContent"; +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import Avatar from "@mui/material/Avatar"; +import LockOutlinedIcon from "@mui/icons-material/LockOutlined"; +import LogoutIcon from "@mui/icons-material/Logout"; +import Paper from "@mui/material/Paper"; + +export const StudentGuard = ({ children }) => { + const dataProvider = useDataProvider(); + const notify = useNotify(); + const reset = useResetStore(); + const { value: student, set: setStudent, clear } = useObjectStore("student"); + + const handleLogout = () => { + clear(); + reset(); + }; + + if (student) { + return ( + + + + שלום התלמידה {student.name} + + + + {children} + + ); + } + + const handleSubmit = async (values) => { + const { tz } = values; + const result = await dataProvider.getList("student", { + pagination: { page: 1, perPage: 1 }, + filter: { tz }, + }); + const student = result.data[0] || null; + + if (student) { + setStudent(student); + } else { + notify("Student not found", { type: "warning" }); + } + }; + + return ( + + + + + + + + כניסת תלמידה + + + + + + + } + > + + + + + + ); +}; diff --git a/client/src/entities/student-event-report.jsx b/client/src/components/StudentView/student-event-report.jsx similarity index 77% rename from client/src/entities/student-event-report.jsx rename to client/src/components/StudentView/student-event-report.jsx index 8de14d99..83c8f786 100644 --- a/client/src/entities/student-event-report.jsx +++ b/client/src/components/StudentView/student-event-report.jsx @@ -6,7 +6,7 @@ import { BooleanInput, required, useNotify, - useRedirect, + useResetStore, useDataProvider, useGetOne, Create, @@ -14,13 +14,12 @@ import { FormDataConsumer, Loading, } from 'react-admin'; - import { filterByUserIdAndYear } from '@shared/components/fields/CommonReferenceInputFilter'; import CommonReferenceInput from '@shared/components/fields/CommonReferenceInput'; import { defaultYearFilter, yearChoices } from '@shared/utils/yearFilter'; import CommonAutocompleteInput from '@shared/components/fields/CommonAutocompleteInput'; import { handleActionSuccess, handleError } from '@shared/utils/notifyUtil'; - +import { useObjectStore } from "src/utils/storeUtil"; const DynamicFields = ({ absenceTypeId }) => { const { data, isLoading } = useGetOne( @@ -47,7 +46,7 @@ const DynamicFields = ({ absenceTypeId }) => { ); }; -const formatPayload = (values) => { +const formatPayload = (values, userId) => { const extraInfo = Object.keys(values) .filter(key => key.startsWith('dynamic_') && values[key]) .map(key => { @@ -63,7 +62,7 @@ const formatPayload = (values) => { return { ...cleanValues, - userId: cleanValues.userId, + userId: userId, year: parseInt(cleanValues.year), reportDate: cleanValues.reportDate ? new Date(cleanValues.reportDate).toISOString() : new Date().toISOString(), absnceCount: parseFloat(cleanValues.absnceCount) || 1, @@ -75,10 +74,11 @@ const formatPayload = (values) => { }; }; -const StudentEventReportCreate = (props) => { +const StudentEventReport = (props) => { const dataProvider = useDataProvider(); const notify = useNotify(); - const redirect = useRedirect(); + const reset = useResetStore(); + const { value: student, clear } = useObjectStore("student"); const handleSave = async (values) => { try { @@ -92,7 +92,7 @@ const StudentEventReportCreate = (props) => { const { data: existingAbsences } = await dataProvider.getList('known_absence', { pagination: { page: 1, perPage: 1000 }, filter: { - studentReferenceId: values.studentReferenceId, + studentReferenceId: student.id, absenceTypeId: values.absenceTypeId, year: values.year }, @@ -110,48 +110,30 @@ const StudentEventReportCreate = (props) => { } } - const formattedData = formatPayload(values); + + const formattedData = { + ...formatPayload(values, student.userId), + studentReferenceId: student.id + }; const response = await dataProvider.create('known_absence', { data: formattedData }); handleActionSuccess(notify)(response); - redirect('/known_absence'); - + clear(); + reset(); } catch (error) { - handleError(notify)(err); + handleError(notify)(error); } }; return ( - + - - - - - - - + + {({ formData }) => ( )} - @@ -163,7 +145,4 @@ const StudentEventReportCreate = (props) => { ); }; -export default { - create: StudentEventReportCreate, - list: StudentEventReportCreate, -}; \ No newline at end of file +export default StudentEventReport; \ No newline at end of file From 91ef040af6d705eb2a230376f6058af2b037d050 Mon Sep 17 00:00:00 2001 From: yael-miller Date: Fri, 20 Feb 2026 01:23:38 +0000 Subject: [PATCH 3/5] Fix small notes in student view --- client/src/GeneralLayout.jsx | 6 +- client/src/RootDashboard.jsx | 21 ++++--- .../StudentView/student-event-report.jsx | 59 +++++++++---------- client/src/domainTranslations.js | 15 ----- client/src/utils/appPermissions.js | 4 +- 5 files changed, 43 insertions(+), 62 deletions(-) diff --git a/client/src/GeneralLayout.jsx b/client/src/GeneralLayout.jsx index 46d84a56..aa82b766 100644 --- a/client/src/GeneralLayout.jsx +++ b/client/src/GeneralLayout.jsx @@ -36,9 +36,9 @@ const customMenuItems = [ // lesson report links: show when user has lesson-report permission OR when they're in-only mode ({ permissions }) => (shouldShowLessonReports(permissions)) && } />, ({ permissions }) => (shouldShowLessonReports(permissions)) && } />, - ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && } />, - ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && } />, - ({ permissions }) => (isStandardView(permissions) && (!isStudentView(permissions))) && } />, + ({ permissions }) => isStandardView(permissions) && } />, + ({ permissions }) => isStandardView(permissions) && } />, + ({ permissions }) => isStandardView(permissions) && } />, ]; const menuGroups = [ diff --git a/client/src/RootDashboard.jsx b/client/src/RootDashboard.jsx index aafd6c73..aad18c49 100644 --- a/client/src/RootDashboard.jsx +++ b/client/src/RootDashboard.jsx @@ -1,13 +1,13 @@ import React from 'react'; import { Dashboard } from 'src/GeneralLayout'; -import { useIsTeacherView, useIsisStudentView } from 'src/utils/appPermissions'; +import { useIsTeacherView, useIsStudentView } from 'src/utils/appPermissions'; import { TeacherGuard } from 'src/components/TeacherView/TeacherAccess'; import { StudentGuard } from './components/StudentView/StudentAccess'; import StudentEventReport from './components/StudentView/student-event-report'; export const RootDashboard = (props) => { const isTeacherView = useIsTeacherView(); - const isStudentView = useIsisStudentView(); + const isStudentView = useIsStudentView(); if (isTeacherView) { return ( @@ -17,14 +17,13 @@ export const RootDashboard = (props) => { ); } - else { - if (isStudentView) { - return ( - - - - ); - } - else return ; + else if (isStudentView) { + return ( + + + + ); } + else return ; + } diff --git a/client/src/components/StudentView/student-event-report.jsx b/client/src/components/StudentView/student-event-report.jsx index 83c8f786..3324315c 100644 --- a/client/src/components/StudentView/student-event-report.jsx +++ b/client/src/components/StudentView/student-event-report.jsx @@ -21,21 +21,15 @@ import CommonAutocompleteInput from '@shared/components/fields/CommonAutocomplet import { handleActionSuccess, handleError } from '@shared/utils/notifyUtil'; import { useObjectStore } from "src/utils/storeUtil"; -const DynamicFields = ({ absenceTypeId }) => { - const { data, isLoading } = useGetOne( - 'absence_type', - { id: absenceTypeId }, - { enabled: !!absenceTypeId } - ); +const DynamicFields = ({ absenceType, isLoading }) => { if (isLoading) return ; - if (!data?.requiredLabels?.length) return null; - + if (!absenceType?.requiredLabels?.length) return null; return (
- {data.requiredLabels.map((label, index) => ( + {absenceType.requiredLabels.map((label, index) => ( { ); }; -const formatPayload = (values, userId) => { +const formatPayload = (values, userId, studentId, absenceType) => { + const allowedLabels = absenceType?.requiredLabels || []; + const extraInfo = Object.keys(values) - .filter(key => key.startsWith('dynamic_') && values[key]) + .filter(key => { + if (!key.startsWith('dynamic_')) return false; + const label = key.replace('dynamic_', ''); + return allowedLabels.includes(label) && values[key]; + }) .map(key => { const label = key.replace('dynamic_', ''); return `${label}: ${values[key]}`; }) .join(' | '); - const { ...cleanValues } = values; + const cleanValues = { ...values }; Object.keys(cleanValues).forEach(key => { if (key.startsWith('dynamic_')) delete cleanValues[key]; }); @@ -63,12 +63,10 @@ const formatPayload = (values, userId) => { return { ...cleanValues, userId: userId, - year: parseInt(cleanValues.year), + studentReferenceId: studentId, + year: parseInt(defaultYearFilter.year), reportDate: cleanValues.reportDate ? new Date(cleanValues.reportDate).toISOString() : new Date().toISOString(), absnceCount: parseFloat(cleanValues.absnceCount) || 1, - absnceCode: 0, - klassId: 0, - lessonId: 0, isApproved: true, reason: cleanValues.reason ? `${cleanValues.reason} [${extraInfo}]` : extraInfo, }; @@ -79,16 +77,18 @@ const StudentEventReport = (props) => { const notify = useNotify(); const reset = useResetStore(); const { value: student, clear } = useObjectStore("student"); + const [selectedAbsenceTypeId, setSelectedAbsenceTypeId] = React.useState(null); + const { data: absenceType, isLoading } = useGetOne( + 'absence_type', + { id: selectedAbsenceTypeId }, + { enabled: !!selectedAbsenceTypeId } + ); const handleSave = async (values) => { try { - const { data: absenceType } = await dataProvider.getOne('absence_type', { - id: values.absenceTypeId - }); - const quota = absenceType?.quota; - if (quota !== undefined && quota !== null) { + if (quota) { const { data: existingAbsences } = await dataProvider.getList('known_absence', { pagination: { page: 1, perPage: 1000 }, filter: { @@ -110,11 +110,7 @@ const StudentEventReport = (props) => { } } - - const formattedData = { - ...formatPayload(values, student.userId), - studentReferenceId: student.id - }; + const formattedData = formatPayload(values, student.userId, student.id, absenceType) const response = await dataProvider.create('known_absence', { data: formattedData }); handleActionSuccess(notify)(response); clear(); @@ -128,17 +124,18 @@ const StudentEventReport = (props) => { - + { const value = e?.target ? e.target.value : e; setSelectedAbsenceTypeId(value); }} /> - {({ formData }) => ( - + {() => ( + )} - + diff --git a/client/src/domainTranslations.js b/client/src/domainTranslations.js index 42181dc8..9f0cc81e 100644 --- a/client/src/domainTranslations.js +++ b/client/src/domainTranslations.js @@ -144,21 +144,6 @@ export default { absenceTypeId: 'סוג אירוע', } }, - student_event_report: { - name: 'דיווח אירוע לתלמידה', - fields: { - ...generalResourceFieldsTranslation, - studentReferenceId: 'תלמידה', - klassReferenceId: 'כיתה', - absenceTypeId: 'סוג אירוע', - reportDate: 'תאריך', - absnceCount: 'כמות', - senderName: 'שם שולח', - reason: 'סיבה', - year: 'שנה', - isApproved: 'מאושר' - } - }, lesson: { name: 'שיעור |||| שיעורים', fields: { diff --git a/client/src/utils/appPermissions.js b/client/src/utils/appPermissions.js index 4fd1d87f..b7c25e46 100644 --- a/client/src/utils/appPermissions.js +++ b/client/src/utils/appPermissions.js @@ -46,8 +46,8 @@ export const isTransportation = (permissions) => hasPermissionLogic(permissions, export const useIsTransportation = () => useHasPermission(appPermissions.transportation); export const isAbsenceType = (permissions) => hasPermissionLogic(permissions, appPermissions.absenceType); -export const useIsisAbsenceType = () => useHasPermission(appPermissions.absenceType); +export const useIsAbsenceType = () => useHasPermission(appPermissions.absenceType); export const isStudentView = (permissions) => hasPermissionLogic(permissions, appPermissions.studentView); -export const useIsisStudentView = () => useHasPermission(appPermissions.studentView); +export const useIsStudentView = () => useHasPermission(appPermissions.studentView); From 46c5d6edad37c5b2d7d66e705f04bfc38c074863 Mon Sep 17 00:00:00 2001 From: yael-miller Date: Sat, 21 Feb 2026 22:20:11 +0000 Subject: [PATCH 4/5] fix: StudentEventReport runtime error --- client/src/GeneralLayout.jsx | 2 +- client/src/components/StudentView/student-event-report.jsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/GeneralLayout.jsx b/client/src/GeneralLayout.jsx index aa82b766..4d2ac280 100644 --- a/client/src/GeneralLayout.jsx +++ b/client/src/GeneralLayout.jsx @@ -23,7 +23,7 @@ import { isInLessonReport, isScannerUpload, isOnlyInLessonReport, isTeacherView, import { useDashboardItems } from './settings/settingsUtil'; const isStandardView = (permissions) => !isOnlyInLessonReport(permissions) && !isTeacherView(permissions) && !isStudentView(permissions); -const shouldShowLessonReports = (permissions) => (isInLessonReport(permissions) || isTeacherView(permissions)) && !isStudentView(permissions); +const shouldShowLessonReports = (permissions) => (isInLessonReport(permissions) || isTeacherView(permissions)); const customMenuItems = [ // static items: render only when NOT restricted to lesson-report-only diff --git a/client/src/components/StudentView/student-event-report.jsx b/client/src/components/StudentView/student-event-report.jsx index 3324315c..79f1dfb0 100644 --- a/client/src/components/StudentView/student-event-report.jsx +++ b/client/src/components/StudentView/student-event-report.jsx @@ -65,7 +65,7 @@ const formatPayload = (values, userId, studentId, absenceType) => { userId: userId, studentReferenceId: studentId, year: parseInt(defaultYearFilter.year), - reportDate: cleanValues.reportDate ? new Date(cleanValues.reportDate).toISOString() : new Date().toISOString(), + reportDate: cleanValues.reportDate, absnceCount: parseFloat(cleanValues.absnceCount) || 1, isApproved: true, reason: cleanValues.reason ? `${cleanValues.reason} [${extraInfo}]` : extraInfo, @@ -125,7 +125,7 @@ const StudentEventReport = (props) => { { const value = e?.target ? e.target.value : e; setSelectedAbsenceTypeId(value); }} /> + onChange={(e) => setSelectedAbsenceTypeId(e?.target?.value ?? e)} /> {() => ( From 45f4b4efa1406ba020efc2701725e1f1a894880e Mon Sep 17 00:00:00 2001 From: yael-miller Date: Sun, 22 Feb 2026 08:25:33 +0000 Subject: [PATCH 5/5] Permisions --- client/src/GeneralLayout.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/GeneralLayout.jsx b/client/src/GeneralLayout.jsx index 4d2ac280..151421b1 100644 --- a/client/src/GeneralLayout.jsx +++ b/client/src/GeneralLayout.jsx @@ -42,7 +42,7 @@ const customMenuItems = [ ]; const menuGroups = [ - ({ permissions }) => ((isStandardView(permissions)) && (!isStudentView(permissions))) && ({ + ({ permissions }) => (isStandardView(permissions)) && ({ name: 'data', icon: , routes: [ } /> ]