diff --git a/client/src/App.jsx b/client/src/App.jsx index 3ab30bad..680ab58a 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -247,8 +247,18 @@ const App = () => ( )} {isPhoneCampaign(permissions) && ( <> - - + + )} { @@ -64,8 +64,7 @@ const extractBasePayload = (rootValues, reportValues, userId, studentId, absence reason: finalReason, absenceTypeId: rootValues.absenceTypeId, absnceCode: rootValues.absnceCode, - fileData: rootValues.fileData - + fileData: rootValues.fileData, }; }; @@ -233,7 +232,11 @@ const StudentEventReport = (props) => { - + diff --git a/client/src/components/fields/ThresholdColorField.jsx b/client/src/components/fields/ThresholdColorField.jsx index 8f6177cd..c85ce67a 100644 --- a/client/src/components/fields/ThresholdColorField.jsx +++ b/client/src/components/fields/ThresholdColorField.jsx @@ -4,13 +4,7 @@ import { getColorForValue } from '@shared/utils/thresholdUtil'; const defaultFormat = (v) => `${(v * 100).toFixed(1)}%`; -const ThresholdColorField = ({ - source, - label, - thresholds = [], - format = defaultFormat, - sortable = false, -}) => ( +const ThresholdColorField = ({ source, label, thresholds = [], format = defaultFormat, sortable = false }) => ( , - , -]; +const filters = [...commonAdminFilters, , ]; const filterDefaultValues = { year: defaultYearFilter.year, @@ -88,4 +84,4 @@ const entity = { importer, }; -export default getResourceComponents(entity); \ No newline at end of file +export default getResourceComponents(entity); diff --git a/client/src/entities/att-report-with-report-month.jsx b/client/src/entities/att-report-with-report-month.jsx index 45afe1e8..2fca5598 100644 --- a/client/src/entities/att-report-with-report-month.jsx +++ b/client/src/entities/att-report-with-report-month.jsx @@ -9,7 +9,7 @@ import { NumberInput, BooleanInput, NullableBooleanInput, - maxLength + maxLength, } from 'react-admin'; import PlaylistRemoveIcon from '@mui/icons-material/PlaylistRemove'; import HelpIcon from '@mui/icons-material/Help'; @@ -77,7 +77,13 @@ const filterDefaultValues = { export const Datagrid = ({ isAdmin, children, ...props }) => { const additionalBulkButtons = [ - } name="bulkChangeKlass" key="bulkChangeKlass" reloadOnEnd> + } + name="bulkChangeKlass" + key="bulkChangeKlass" + reloadOnEnd + > {isAdmin && } {isAdmin && } diff --git a/client/src/entities/att-report.jsx b/client/src/entities/att-report.jsx index 347f1b78..4ca2949b 100644 --- a/client/src/entities/att-report.jsx +++ b/client/src/entities/att-report.jsx @@ -9,7 +9,7 @@ import { ReferenceField, required, minValue, - maxLength + maxLength, } from 'react-admin'; import { useIsLessonSignature, useIsTeacherView } from 'src/utils/appPermissions'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; diff --git a/client/src/entities/grade.jsx b/client/src/entities/grade.jsx index 6739e0d1..59987fb6 100644 --- a/client/src/entities/grade.jsx +++ b/client/src/entities/grade.jsx @@ -9,7 +9,7 @@ import { ReferenceField, required, maxLength, - NullableBooleanInput + NullableBooleanInput, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; diff --git a/client/src/entities/klass.jsx b/client/src/entities/klass.jsx index f76f84f3..e0a8a7ac 100644 --- a/client/src/entities/klass.jsx +++ b/client/src/entities/klass.jsx @@ -9,7 +9,7 @@ import { NumberInput, NumberField, required, - maxLength + maxLength, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; diff --git a/client/src/entities/known-absence.jsx b/client/src/entities/known-absence.jsx index 2913e601..04ee2252 100644 --- a/client/src/entities/known-absence.jsx +++ b/client/src/entities/known-absence.jsx @@ -11,7 +11,7 @@ import { ReferenceField, required, TextField, - TextInput + TextInput, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; diff --git a/client/src/entities/lesson.jsx b/client/src/entities/lesson.jsx index 68ca7a38..8cf8d9b5 100644 --- a/client/src/entities/lesson.jsx +++ b/client/src/entities/lesson.jsx @@ -10,7 +10,7 @@ import { required, TextField, TextInput, - minValue + minValue, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField, MultiReferenceArrayField } from '@shared/components/fields/CommonReferenceField'; diff --git a/client/src/entities/report-group.jsx b/client/src/entities/report-group.jsx index 95d6f454..3b538593 100644 --- a/client/src/entities/report-group.jsx +++ b/client/src/entities/report-group.jsx @@ -6,7 +6,7 @@ import { ReferenceManyCount, DateTimeInput, required, - maxLength + maxLength, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; diff --git a/client/src/entities/report-month.jsx b/client/src/entities/report-month.jsx index d077423d..369f640b 100644 --- a/client/src/entities/report-month.jsx +++ b/client/src/entities/report-month.jsx @@ -7,7 +7,7 @@ import { ReferenceField, required, TextField, - TextInput + TextInput, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { CommonRepresentation } from '@shared/components/CommonRepresentation'; diff --git a/client/src/entities/student-klass.jsx b/client/src/entities/student-klass.jsx index ec17ace7..319f3120 100644 --- a/client/src/entities/student-klass.jsx +++ b/client/src/entities/student-klass.jsx @@ -6,7 +6,7 @@ import { ReferenceField, required, TextField, - TextInput + TextInput, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; diff --git a/client/src/entities/student-percent-report.jsx b/client/src/entities/student-percent-report.jsx index 906eaef1..f96e13b2 100644 --- a/client/src/entities/student-percent-report.jsx +++ b/client/src/entities/student-percent-report.jsx @@ -1,11 +1,4 @@ -import { - DateInput, - NumberField, - TextField, - ReferenceField, - useRecordContext, - TextInput -} from 'react-admin'; +import { DateInput, NumberField, TextField, ReferenceField, useRecordContext, TextInput } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; diff --git a/client/src/entities/student.jsx b/client/src/entities/student.jsx index 3e9b56ed..09156c4a 100644 --- a/client/src/entities/student.jsx +++ b/client/src/entities/student.jsx @@ -12,7 +12,7 @@ import { required, SelectInput, TextField, - TextInput + TextInput, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { CommonRepresentation } from '@shared/components/CommonRepresentation'; diff --git a/client/src/entities/teacher-grade-report-status.jsx b/client/src/entities/teacher-grade-report-status.jsx index 10c2cd4c..effb419d 100644 --- a/client/src/entities/teacher-grade-report-status.jsx +++ b/client/src/entities/teacher-grade-report-status.jsx @@ -5,7 +5,7 @@ import { required, BooleanInput, TextInput, - useGetList + useGetList, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; diff --git a/client/src/entities/teacher-report-status.jsx b/client/src/entities/teacher-report-status.jsx index 6e283f60..72f61836 100644 --- a/client/src/entities/teacher-report-status.jsx +++ b/client/src/entities/teacher-report-status.jsx @@ -5,7 +5,7 @@ import { required, BooleanInput, TextInput, - useGetList + useGetList, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; diff --git a/client/src/entities/transportation.jsx b/client/src/entities/transportation.jsx index 21494105..7e2e7703 100644 --- a/client/src/entities/transportation.jsx +++ b/client/src/entities/transportation.jsx @@ -6,7 +6,7 @@ import { TextField, TextInput, NumberInput, - maxLength + maxLength, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { getResourceComponents } from '@shared/components/crudContainers/CommonEntity'; diff --git a/client/src/pivots/PercentReportWithDatesList.jsx b/client/src/pivots/PercentReportWithDatesList.jsx index dcc126a4..22eface5 100644 --- a/client/src/pivots/PercentReportWithDatesList.jsx +++ b/client/src/pivots/PercentReportWithDatesList.jsx @@ -9,7 +9,7 @@ import { useAuthState, usePermissions, BooleanInput, - NullableBooleanInput + NullableBooleanInput, } from 'react-admin'; import { CommonDatagrid } from '@shared/components/crudContainers/CommonList'; import { MultiReferenceField } from '@shared/components/fields/CommonReferenceField'; diff --git a/client/src/pivots/StudentAttendanceByKlassList.jsx b/client/src/pivots/StudentAttendanceByKlassList.jsx index 9eaa71f6..a2069b9e 100644 --- a/client/src/pivots/StudentAttendanceByKlassList.jsx +++ b/client/src/pivots/StudentAttendanceByKlassList.jsx @@ -104,7 +104,12 @@ const Datagrid = ({ isAdmin, children, ...props }) => { {summaryHeaders.map((h) => PCT_SUMMARY_KEYS.has(h.value) ? ( - + ) : ( ), diff --git a/client/src/utils/absenceThresholds.js b/client/src/utils/absenceThresholds.js index b8c707b5..0d892db3 100644 --- a/client/src/utils/absenceThresholds.js +++ b/client/src/utils/absenceThresholds.js @@ -1,10 +1,10 @@ import { getColorForValue } from '@shared/utils/thresholdUtil'; export const ABSENCE_THRESHOLDS = [ - { min: 0.80, color: '#ff0000' }, - { min: 0.60, color: '#ff6666' }, - { min: 0.40, color: '#ffa500' }, - { min: 0.20, color: '#ffff88' }, + { min: 0.8, color: '#ff0000' }, + { min: 0.6, color: '#ff6666' }, + { min: 0.4, color: '#ffa500' }, + { min: 0.2, color: '#ffff88' }, ]; export function getThresholdColor(value) { diff --git a/server/src/db/entities/KnownAbsence.entity.ts b/server/src/db/entities/KnownAbsence.entity.ts index f0a541fc..2ffb1a0e 100644 --- a/server/src/db/entities/KnownAbsence.entity.ts +++ b/server/src/db/entities/KnownAbsence.entity.ts @@ -8,27 +8,27 @@ import { JoinColumn, ManyToOne, PrimaryGeneratedColumn, -} from "typeorm"; -import { IHasUserId } from "@shared/base-entity/interface"; -import { User } from "src/db/entities/User.entity"; -import { findOneAndAssignReferenceId, getDataSource } from "@shared/utils/entity/foreignKey.util"; -import { Student } from "./Student.entity"; -import { IsOptional, ValidateIf } from "class-validator"; -import { CrudValidationGroups } from "@dataui/crud"; -import { IsBoolean, IsDate, IsNotEmpty, IsNumber, MaxLength } from "@shared/utils/validation/class-validator-he"; -import { fillDefaultYearValue } from "@shared/utils/entity/year.util"; -import { fillDefaultReportDateValue } from "@shared/utils/entity/deafultValues.util"; -import { Klass } from "./Klass.entity"; -import { Lesson } from "./Lesson.entity"; -import { KlassType } from "./KlassType.entity"; -import { Teacher } from "./Teacher.entity"; -import { AbsenceType } from "./AbsenceType.entity"; -import { BooleanType, DateType, NumberType, StringType } from "@shared/utils/entity/class-transformer"; -import { LessonKlassName } from "../view-entities/LessonKlassName.entity"; -import { CreatedAtColumn, DateColumn, UpdatedAtColumn } from "@shared/utils/entity/column-types.util"; -import { FileData } from "@shared/entities/Image.entity"; - -@Index("known_users_idx", ["userId"], {}) +} from 'typeorm'; +import { IHasUserId } from '@shared/base-entity/interface'; +import { User } from 'src/db/entities/User.entity'; +import { findOneAndAssignReferenceId, getDataSource } from '@shared/utils/entity/foreignKey.util'; +import { Student } from './Student.entity'; +import { IsOptional, ValidateIf } from 'class-validator'; +import { CrudValidationGroups } from '@dataui/crud'; +import { IsBoolean, IsDate, IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he'; +import { fillDefaultYearValue } from '@shared/utils/entity/year.util'; +import { fillDefaultReportDateValue } from '@shared/utils/entity/deafultValues.util'; +import { Klass } from './Klass.entity'; +import { Lesson } from './Lesson.entity'; +import { KlassType } from './KlassType.entity'; +import { Teacher } from './Teacher.entity'; +import { AbsenceType } from './AbsenceType.entity'; +import { BooleanType, DateType, NumberType, StringType } from '@shared/utils/entity/class-transformer'; +import { LessonKlassName } from '../view-entities/LessonKlassName.entity'; +import { CreatedAtColumn, DateColumn, UpdatedAtColumn } from '@shared/utils/entity/column-types.util'; +import { FileData } from '@shared/entities/Image.entity'; + +@Index('known_users_idx', ['userId'], {}) @Index(['studentReferenceId', 'year']) @Index('known_absences_lookup_idx', ['userId', 'year', 'isApproved', 'studentReferenceId']) @Entity('known_absences') @@ -209,4 +209,4 @@ export class KnownAbsence implements IHasUserId { @ManyToOne(() => AbsenceType, { createForeignKeyConstraints: false }) @JoinColumn({ name: 'absence_type_id' }) absenceType: AbsenceType; -} \ No newline at end of file +} diff --git a/server/src/entity-modules/student-by-year.config.ts b/server/src/entity-modules/student-by-year.config.ts index 7157f26c..22b3d505 100644 --- a/server/src/entity-modules/student-by-year.config.ts +++ b/server/src/entity-modules/student-by-year.config.ts @@ -175,10 +175,7 @@ class StudentByYearService extends BaseEntityS if (!selectedKlassIds?.length) return; const data = list as StudentByYear[]; - const studentMap: Record = data.reduce( - (a, b) => ({ ...a, [b.id]: b }), - {}, - ); + const studentMap: Record = data.reduce((a, b) => ({ ...a, [b.id]: b }), {}); const klassTypeReferenceIds = getAsNumberArray(extra.klassTypeReferenceIds); const excludedLessonIds = getAsNumberArray(extra?.excludedLessonIds); @@ -212,9 +209,7 @@ class StudentByYearService extends BaseEntityS const selectedKlasses = await this.dataSource.getRepository(Klass).find({ where: { id: In(selectedKlassIds) }, }); - const klassNameMap: Record = Object.fromEntries( - selectedKlasses.map((k) => [k.id, k.name]), - ); + const klassNameMap: Record = Object.fromEntries(selectedKlasses.map((k) => [k.id, k.name])); selectedKlassIds.forEach((kid) => { const key = `klass_${kid}`; headers[key] = { diff --git a/server/src/entity-modules/student-percent-report.config.ts b/server/src/entity-modules/student-percent-report.config.ts index 7effbdc3..1a133421 100644 --- a/server/src/entity-modules/student-percent-report.config.ts +++ b/server/src/entity-modules/student-percent-report.config.ts @@ -84,12 +84,10 @@ class StudentPercentReportService exten switch (pivotName) { case 'PercentReportWithDates': { - const pivotData = await this.dataSource - .getRepository(AttReportAndGrade) - .find({ - where: getReportDataFilterBySprAndDates(sprIds, extra?.fromDate, extra?.toDate), - order: { reportDate: 'ASC' }, - }); + const pivotData = await this.dataSource.getRepository(AttReportAndGrade).find({ + where: getReportDataFilterBySprAndDates(sprIds, extra?.fromDate, extra?.toDate), + order: { reportDate: 'ASC' }, + }); const pivotDataMap = groupDataByKeys(pivotData, [ 'studentReferenceId', 'teacherReferenceId', diff --git a/server/src/reports/klassAttendanceReport.ts b/server/src/reports/klassAttendanceReport.ts index 3bec5049..3d11c9fa 100644 --- a/server/src/reports/klassAttendanceReport.ts +++ b/server/src/reports/klassAttendanceReport.ts @@ -180,7 +180,9 @@ const getReportData: IGetReportDataFunction { const dateSessions = sessionsByDate[formatDate(date)] || []; if (!dateSessions.length) return [buildEmptySession(date)]; - return groupByDate ? [buildGroupedSession(date, dateSessions, lessonCountsBySession)] : buildSingleSessions(date, dateSessions, lessonCountsBySession); + return groupByDate + ? [buildGroupedSession(date, dateSessions, lessonCountsBySession)] + : buildSingleSessions(date, dateSessions, lessonCountsBySession); }); // Build student data diff --git a/server/src/reports/michlolPopulatedFile.ts b/server/src/reports/michlolPopulatedFile.ts index cb8c795d..4664fd2e 100644 --- a/server/src/reports/michlolPopulatedFile.ts +++ b/server/src/reports/michlolPopulatedFile.ts @@ -40,12 +40,10 @@ const getReportData: IGetReportDataFunction = async ( } const [lesson, students] = await Promise.all([ - dataSource - .getRepository(Lesson) - .findOne({ - where: { userId: params.userId, key: lessonKey, year: getCurrentHebrewYear() }, - select: { id: true, key: true, name: true, userId: true }, - }), + dataSource.getRepository(Lesson).findOne({ + where: { userId: params.userId, key: lessonKey, year: getCurrentHebrewYear() }, + select: { id: true, key: true, name: true, userId: true }, + }), dataSource .getRepository(Student) .find({ where: { userId: params.userId, tz: In(studentTzs) }, select: { id: true, tz: true } }), diff --git a/server/src/utils/absenceThresholds.ts b/server/src/utils/absenceThresholds.ts index ec1018f5..ad0f4143 100644 --- a/server/src/utils/absenceThresholds.ts +++ b/server/src/utils/absenceThresholds.ts @@ -1,14 +1,14 @@ import { findByThreshold } from '@shared/utils/reportData.util'; export const ABSENCE_THRESHOLDS = [ - { min: 0.80, argb: 'FFFF0000' }, - { min: 0.60, argb: 'FFFF6666' }, - { min: 0.40, argb: 'FFFFA500' }, - { min: 0.20, argb: 'FFFFFF88' }, + { min: 0.8, argb: 'FFFF0000' }, + { min: 0.6, argb: 'FFFF6666' }, + { min: 0.4, argb: 'FFFFA500' }, + { min: 0.2, argb: 'FFFFFF88' }, ] as const; export type AbsenceThreshold = (typeof ABSENCE_THRESHOLDS)[number]; export function getThresholdArgb(ratio: number | null): string | null { - return findByThreshold(ratio, ABSENCE_THRESHOLDS, 'min', 'argb'); + return findByThreshold(ratio, ABSENCE_THRESHOLDS, 'min', 'argb'); } diff --git a/server/src/yemot-handler.service.test.ts b/server/src/yemot-handler.service.test.ts index 14807a18..b595876a 100644 --- a/server/src/yemot-handler.service.test.ts +++ b/server/src/yemot-handler.service.test.ts @@ -7,13 +7,7 @@ import { YemotHandlerService } from './yemot-handler.service'; */ function israelTimeAt(hour: number, minute: number): Date { const now = new Date(); - const utcMs = Date.UTC( - now.getFullYear(), - now.getMonth(), - now.getDate(), - hour - 3, - minute, - ); + const utcMs = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), hour - 3, minute); return new Date(utcMs); } @@ -110,16 +104,18 @@ describe('YemotHandlerService — react-admin-nestjs', () => { const scenario = new YemotScenarioBuilder('Already reported') .seed('User', [baseUser]) .seed('Student', [{ id: 100, userId: 1, tz: '123456789', name: 'Test Student' }]) - .seed('KnownAbsence', [{ - userId: 1, - studentReferenceId: 100, - studentTz: '123456789', - reportDate: today, - absnceCount: 1, - isApproved: true, - comment: 'test', - klassReferenceId: 200, - }]) + .seed('KnownAbsence', [ + { + userId: 1, + studentReferenceId: 100, + studentTz: '123456789', + reportDate: today, + absnceCount: 1, + isApproved: true, + comment: 'test', + klassReferenceId: 200, + }, + ]) .seed('Text', baseTexts) .systemAsks(/enter.*id/i) .userResponds('123456789')