- H4: scoped SSE import progress to exact userId match; non-HTTP events excluded from all subscribers - H2: moved PRAGMA foreign_key_check inside SQLite transaction before COMMIT; violations rollback preserving old tables - M1: removed dead axios-style error branch from extractErrorMessage (interceptor already unwraps) - M2: split handleSave try/catch — save errors vs reload errors shown distinctly - M3: added provider field validation before AI config test request - Added SSE scoping regression tests (import service + controller) - Added FK check failure rollback test (database-migrations.spec) - Updated controller spec expectations for userId parameter Co-authored-by: Code Review <branch-review>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import dayjs, { type Dayjs } from 'dayjs';
|
|
|
|
export interface ScheduleFormValues {
|
|
classId: number;
|
|
classroomId: number;
|
|
weekDay: number;
|
|
subject: string;
|
|
teacherId?: number;
|
|
timeRange: [Dayjs, Dayjs];
|
|
dateRange: [Dayjs, Dayjs];
|
|
}
|
|
|
|
export interface EditableSchedule {
|
|
id?: number;
|
|
classId: number;
|
|
classroomId: number;
|
|
weekDay: number;
|
|
subject: string;
|
|
teacherId: number | null;
|
|
startTime: string;
|
|
endTime: string;
|
|
startDate: string;
|
|
endDate: string;
|
|
}
|
|
|
|
export const scheduleToFormValues = (schedule: EditableSchedule): ScheduleFormValues => ({
|
|
classId: schedule.classId,
|
|
classroomId: schedule.classroomId,
|
|
weekDay: schedule.weekDay,
|
|
subject: schedule.subject,
|
|
teacherId: schedule.teacherId ?? undefined,
|
|
timeRange: [dayjs(`2000-01-01 ${schedule.startTime}`), dayjs(`2000-01-01 ${schedule.endTime}`)],
|
|
dateRange: [dayjs(schedule.startDate), dayjs(schedule.endDate)],
|
|
});
|
|
|
|
export const buildSchedulePayload = (values: ScheduleFormValues) => ({
|
|
classId: values.classId,
|
|
classroomId: values.classroomId,
|
|
weekDay: values.weekDay,
|
|
subject: values.subject,
|
|
teacherId: values.teacherId,
|
|
startTime: values.timeRange[0].format('HH:mm'),
|
|
endTime: values.timeRange[1].format('HH:mm'),
|
|
startDate: values.dateRange[0].format('YYYY-MM-DD'),
|
|
endDate: values.dateRange[1].format('YYYY-MM-DD'),
|
|
});
|