Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions client/src/reports/in-lesson-report/StudentList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import DeleteIcon from '@mui/icons-material/Delete';
import { CommonSliderInput } from '../../../shared/components/fields/CommonSliderInput';
import { ReportContext } from './context';
import { CommonHebrewDateField } from '@shared/components/fields/CommonHebrewDateField';
import { useIsLessonSignature } from 'src/utils/appPermissions';
import { useIsLessonSignature, useIsPerDateLessonCount } from 'src/utils/appPermissions';

export const getDefaultReportDate = () => new Date().toISOString().split('T')[0];

export const StudentList = ({ reportDates, setReportDates }) => {
const { gradeMode, isShowLate, students } = useContext(ReportContext);
const record = useRecordContext();
const hasLessonSignaturePermission = useIsLessonSignature();
const hasPerDateLessonCountPermission = useIsPerDateLessonCount();
const today = useMemo(() => new Date().toISOString().split('T')[0], []);

const columns = useMemo(() => {
Expand Down Expand Up @@ -75,11 +76,11 @@ export const StudentList = ({ reportDates, setReportDates }) => {
);

return (
<TableContainer component={Paper}>
<TableContainer component={Paper} sx={{ maxHeight: '70vh' }}>
<Table stickyHeader size="small">
<TableHead>
<TableRow>
<TableCell>
<TableCell sx={{ position: 'sticky', insetInlineStart: 0, zIndex: 3 }}>
<Button onClick={addReportDate}>הוסף תאריך חדש</Button>
</TableCell>
{reportDates.map((date, index) => (
Expand Down Expand Up @@ -110,6 +111,16 @@ export const StudentList = ({ reportDates, setReportDates }) => {
)}
</div>

{!gradeMode && hasPerDateLessonCountPermission && (
<NumberInput
source={`lessonDetails[${index}].howManyLessons`}
label="מספר שיעורים לתאריך זה"
helperText="ריק = לפי מספר השיעורים המשותף למעלה"
validate={[minValue(0), maxValue(1_000_000)]}
fullWidth
/>
)}

{hasLessonSignaturePermission && (
<>
<CommonTimeInput
Expand All @@ -135,7 +146,7 @@ export const StudentList = ({ reportDates, setReportDates }) => {
))}
</TableRow>
<TableRow>
<TableCell>
<TableCell sx={{ position: 'sticky', insetInlineStart: 0, zIndex: 3 }}>
<Text>שם התלמידה</Text>
</TableCell>
{reportDates.map((date, index) =>
Expand All @@ -153,7 +164,14 @@ export const StudentList = ({ reportDates, setReportDates }) => {
.filter((student) => student.student)
.map((student) => (
<TableRow key={student.student.id}>
<TableCell>
<TableCell
sx={{
position: 'sticky',
insetInlineStart: 0,
zIndex: 1,
backgroundColor: 'background.paper',
}}
>
<Text>{student.student.name}</Text>
</TableCell>
{reportDates.map((date, index) => (
Expand All @@ -162,7 +180,11 @@ export const StudentList = ({ reportDates, setReportDates }) => {
index={index}
columns={columns}
studentId={student.student.id}
lessonCount={record.howManyLessons}
lessonCount={
(hasPerDateLessonCountPermission &&
record.lessonDetails?.[index]?.howManyLessons) ||
record.howManyLessons
}
/>
))}
</TableRow>
Expand Down
2 changes: 1 addition & 1 deletion client/src/reports/in-lesson-report/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const InLessonReport = ({
newEntry.grade = rest[studentId]?.[`grade_${index}`] ?? 0;
newEntry.comments = rest[studentId]?.[`comments_${index}`] ?? '';
} else {
newEntry.howManyLessons = howManyLessons;
newEntry.howManyLessons = lessonDetails?.[index]?.howManyLessons ?? howManyLessons;
newEntry.absCount = round(
(rest[studentId]?.[`absence_${index}`] ?? 0) +
(rest[studentId]?.[`late_${index}`] ?? 0) * lateValue,
Expand Down
5 changes: 5 additions & 0 deletions client/src/utils/appPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const appPermissions = {
studentAttendanceByKlass: 'studentAttendanceByKlass',
seminarAttendanceYemot: 'seminarAttendanceYemot',
lessonSchedule: 'lessonSchedule',
perDateLessonCount: 'perDateLessonCount',
};

export const isScannerUpload = (permissions) => hasPermissionLogic(permissions, appPermissions.scannerUpload);
Expand Down Expand Up @@ -71,3 +72,7 @@ export const useIsSeminarAttendanceYemot = () => useHasPermission(appPermissions
export const isLessonSchedule = (permissions) =>
isAdmin(permissions) || hasPermissionLogic(permissions, appPermissions.lessonSchedule);
export const useIsLessonSchedule = () => useHasPermission(appPermissions.lessonSchedule);

export const isPerDateLessonCount = (permissions) =>
isAdmin(permissions) || hasPermissionLogic(permissions, appPermissions.perDateLessonCount);
export const useIsPerDateLessonCount = () => useHasPermission(appPermissions.perDateLessonCount);
4 changes: 2 additions & 2 deletions server/src/reports/reportGroupSessionsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const SessionsSummaryReport: React.FC<ReportGroupSessionsSummaryData> = (props)
<tr>
<th style={headerStyle}>תאריך</th>
<th style={headerStyle}>נושא</th>
{/* <th style={headerStyle}>שיעור</th> */}
<th style={headerStyle}>שיעור</th>
{!isSingleKlass && <th style={headerStyle}>כיתה</th>}
<th style={headerStyle}>מספר שיעורים</th>
<th style={headerStyle}>חתימת מורה</th>
Expand All @@ -205,7 +205,7 @@ const SessionsSummaryReport: React.FC<ReportGroupSessionsSummaryData> = (props)
<tr key={index}>
<td style={cellStyle}>{formatDate(session.date)}</td>
<td style={cellStyle}>{session.topic || '-'}</td>
{/* <td style={cellStyle}>{session.lessonName || '-'}</td> */}
<td style={cellStyle}>{session.lessonName || '-'}</td>
{!isSingleKlass && <td style={cellStyle}>{session.klassName || '-'}</td>}
<td style={cellStyle}>{session.lessonCount}</td>
<td style={cellStyle}>
Expand Down
Loading