hezarfen_frontend
Clone
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
Backend Contract Refresh Plan (Superseded)
Superseded on 2026-07-28 by
backend-feature-contract-2026-07-28.md
and
2026-07-28-backend-alignment.md.
Context
This is the active frontend plan for the latest backend contract changes. It is based on the last three backend commits:
493fbbb feat(courses): add kind course|study (etut)31e155a feat(events)!: registration audience replaces hand-picked usersbd9e7d8 feat(events)!: audience targeting + teacher-only attendance
It also tracks the separate note-file upload issue, because the frontend now has
note attachment UI and the backend exposes /notes/{id}/files routes.
Goals
- Align the frontend with backend event audience, registration, and roster rules.
- Add course kind support for
courseandstudy. - Fix and verify note file upload/list/download/delete behavior.
- Keep every change minimal, role-aware, and consistent with existing SidePanel, TableRowActions, pagination, and dashboard rules.
Phase 0: Verify Running Backend
Before coding feature UI, confirm the running backend is the expected build.
- Start backend and frontend locally.
- Probe the note-file route through the Vite proxy:
POST /api/notes/test/fileswithout auth should return401if the route exists.404means the running backend is old, not the expected server, or not mounted.
- Check
/api-docs/openapi.jsonincludes:/notes/{id}/files/events/{id}/roster/events/{id}/register- event
audience - course
kind
Phase 1: Note File Upload UX
Backend contract:
POST /notes/{id}/filesmultipart field name:file.GET /notes/{id}/files?limit&offsetreturns a page of metadata.GET /notes/{id}/files/{file_id}downloads bytes.DELETE /notes/{id}/files/{file_id}deletes one file.- Max 10 files per note, max size from
settings.max_file_bytes.
Files:
src/api/client.tssrc/api/getNoteFiles.tssrc/api/postNoteFile.tssrc/api/getNoteFileBlob.tssrc/api/getNoteFileUrl.tssrc/api/deleteNoteFileById.tssrc/components/notes/note-files-panel.tsxsrc/components/notes/note-form.tsxsrc/pages/notes-page.tsxsrc/i18n/messages.ts
Tasks:
- Keep native
FormData; do not set multipartContent-Typemanually. - Do not hide note-file
404as an empty list once backend route is verified. - Improve blob/download error parsing so preview/download failures show backend JSON errors when available.
- If note creation succeeds but a staged file upload fails, show a clear partial success error and keep the created note visible after refetch.
- Keep reader panel attachments below note content.
- Keep create-form staged uploads as upload-after-create only; no draft upload queue.
Verification:
- Open
/notes. - Create a note with one file.
- Open an existing note and upload a file.
- List, preview/download, and delete the file.
- Test oversized file and 10-file cap messages.
Phase 2: Event Audience Types
Backend contract:
- Event response includes
audience. - Create/edit event can send audience:
{ "kind": "school" }{ "kind": "role", "role": "student" }{ "kind": "course", "course": "<id>" }{ "kind": "registration", "capacity": number | null }
- Audience is the expected-attendee roster, not event visibility. Everyone still sees every event.
Files:
src/api/types.tssrc/api/postEvent.tssrc/api/patchEventById.tssrc/components/events/event-form.tsxsrc/pages/events-page.tsxsrc/pages/event-detail-page.tsxsrc/i18n/messages.ts
Tasks:
- Add
EventAudiencetype andaudiencefield onEvent. - Add audience picker to event create/edit SidePanel.
- For course audience, reuse existing course list data or fetch visible courses.
- Show compact audience summary on event cards/detail.
- Preserve existing start/end schedule validation.
Verification:
- Create and edit school, role, course, and registration audience events.
- Ensure omitted audience defaults to school-wide only when creating.
- Ensure editing with omitted audience keeps the current audience.
Phase 3: Teacher-Only Event Attendance And Roster
Backend contract:
- Students never mark event attendance.
POST /events/{id}/attendanceis teacher+ only.- Target
user_idmust be in the event audience. GET /events/{id}/rosterreturns expected attendees withstatus: nullwhen unmarked.GET /events/{id}/attendanceremains recorded rows, including rows no longer in the live audience.
Files:
- Add
src/api/getEventRoster.ts src/api/postEventAttendance.tssrc/api/deleteEventAttendanceByUserId.tssrc/api/types.tssrc/components/events/attendance-table.tsxsrc/pages/event-detail-page.tsxsrc/i18n/messages.ts
Tasks:
- Add
RosterEntrytype. - Add a roster section for teacher+ users.
- Show expected attendees and clearly mark unmarked rows.
- Move teacher marking workflow to roster rows where possible.
- Keep recorded attendance rows as a secondary audit section.
- Remove or hide student self-attendance UI.
Verification:
- Student event detail has no attendance mutation controls.
- Teacher can mark an expected attendee.
- Teacher sees validation error when trying to mark a user outside audience.
- Removing attendance updates roster and audit rows.
Phase 4: Registration Events
Backend contract:
- Registration audience uses
POST /events/{id}/registerandDELETE /events/{id}/register/{user}. - Teachers register students; staff can register only themselves.
- Capacity may cap seats.
- Registration closes when the event starts.
Files:
- Add
src/api/postEventRegistration.ts - Add
src/api/deleteEventRegistrationByUserId.ts src/api/types.tssrc/pages/event-detail-page.tsxsrc/components/users/user-search-select.tsxif role-filter wiring is neededsrc/i18n/messages.ts
Tasks:
- Show registration controls only for
audience.kind === "registration"and teacher+ users. - Show capacity and current roster count.
- Add student picker filtered to
role=studentfor teacher registration. - Add self-register/self-unregister control for staff users.
- Disable or explain controls after the event starts.
- Surface
409full/closed errors clearly.
Verification:
- Register a student.
- Register/unregister current staff user.
- Hit capacity and see a clear full-list message.
- After start time, registration actions show backend conflict cleanly.
Phase 5: Course Kind (course / study)
Backend contract:
- Course response includes
kind. - Create/edit course accepts
kind. courseandstudybehave identically; the frontend only labels them.
Files:
src/api/types.tssrc/api/postCourse.tssrc/api/patchCourseById.tssrc/pages/courses-page.tsxsrc/pages/course-detail-page.tsxsrc/i18n/messages.ts
Tasks:
- Add
CourseKind = "course" | "study" | string. - Add
kindtoCourse,PostCourseBody, andPatchCourseBody. - Add simple create/edit select for course kind.
- Show muted badge in courses table and course detail header.
- Include course kind in search text.
- Do not add separate routes or pages for study courses.
Verification:
- Create a normal course.
- Create a study course.
- Edit kind both ways.
- Confirm list/detail labels update.
Phase 6: Request And Pagination Cleanup
Files:
src/lib/list-page.ts- event and note detail sections touched above
Tasks:
- Use server paging for large main lists.
- Use paged roster/attendance requests in event detail sections.
- Avoid hidden teacher-only requests until sections are opened.
- Keep client-side filtering only where the expected dataset is small or where current backend filtering does not exist.
Verification:
- Build passes.
- No hidden heavy requests on student event/detail views.
- Teacher-only sections fetch only when visible.
Commit Order
- Docs plan only.
- Note file verification and UX fix.
- Course kind UI.
- Event audience create/edit/read UI.
- Event roster + teacher-only attendance.
- Registration event controls.
Each implementation commit must run bun run build before commit and needs
explicit user approval for the exact commit message.