EduTrack Online — Frontend Build Order (Phase 1: SiteOwner)

Overview

Build these pages in order. Each page depends on the previous one.


Page 1: Login Page

APIs to use (from API_PUBLIC.md):

Action Method Endpoint Purpose
Login POST /accounts/login/ Authenticate user, returns JWT cookies + {role, name, is_active}
Forgot Password POST /accounts/forgot-password/ Send OTP to email (always returns 200)
Verify OTP POST /accounts/verify-otp/ Verify 6-digit code, get reset_token
Reset Password POST /accounts/reset-password/ Set new password with OTP + reset_token

Flow:

  1. User enters username + password → POST /accounts/login/
  2. If 200 → store {role, name} in React state, redirect to Teachers Page (if role=siteowner)
  3. If 401 → show error message
  4. "Forgot Password?" link → step-by-step: email → OTP → new password

Required: Login form, Forgot Password modal/flow.


Page 2: Student Register Page (Public)

APIs to use (from API_PUBLIC.md):

Action Method Endpoint Purpose
Register POST /accounts/student/register/ Create student account (pending approval)

Required fields in form:

Dropdown data: Fetch from Settings endpoints (see Page 6).

Business rules:


Page 3: Teachers Page (SiteOwner Dashboard)

This is the main landing page after login. Shows all teachers as cards.

APIs to use (from API_SITEOWNER.md):

Action Method Endpoint Purpose
List teachers GET /accounts/teachers/ Paginated list with search, filter
Create teacher POST /accounts/teachers/ Create new teacher account

Teacher Card shows:

Teacher List Filters:

Teacher Create Form fields:

Success response: Returns full teacher profile with ID. Use this to navigate to the new teacher's detail.


Page 4: Teacher Detail Page (View/Edit Teacher)

Clicking on a teacher card or the edit button from the Teachers Page.

APIs to use:

Action Method Endpoint Purpose
Get teacher GET /accounts/teachers/<id>/ Full teacher detail with subject/grades
Update teacher PATCH /accounts/teachers/<id>/ Update teacher fields
List assistants GET /accounts/teacher/assistants/?teacher=<id> View assistants for this teacher

Teacher Detail sections:

  1. Profile Info — name, phone, gmail, subject, grades, active status. Editable.
  2. Assistants List — read-only table showing assigned assistants (name, phone, gmail, is_active). Note: assistants are created later by the teacher themselves.
  3. Create Course Button → opens a form to create a course for this teacher.

Course Create Form (inline):

Note: Subject is auto-derived from teacher.subject — NOT sent in request.

Success: After creating a course, the page should show a success message and optionally navigate to the Teacher Courses Page.


Page 5: Teacher Courses Page

List all courses for a specific teacher. Accessed via "View Courses" button on teacher card.

APIs to use:

Action Method Endpoint Purpose
List courses GET /courses/?teacher=<id> Paginated list of courses for this teacher
Get course GET /courses/<id>/ Full course detail
Update course PATCH /courses/<id>/ Update course name/description/active
Delete course DELETE /courses/<id>/ Delete empty course (no enrollments/topics/lectures)

Course Card shows:

Course Edit Form:

Course Delete rules:


Page 6: Students Page (SiteOwner)

Manage all student registrations. Approve/decline pending students.

APIs to use:

Action Method Endpoint Purpose
List students GET /accounts/students/ Paginated list with search, sort, filters
Get student GET /accounts/students/<id>/ Full student detail
Change status PATCH /accounts/students/<id>/status/ Update status + is_active

Student List Filters:

Student Table columns:

Student Detail view:

Default view: Show pending students first (sort by most recent).


Page 7: Settings Page (Read-Only Reference)

Display all reference data for preview. No CRUD operations.

APIs to use (from API_PUBLIC.md):

Action Endpoint Purpose
List grades GET /accounts/grades/
List school types GET /accounts/school-types/
List divisions GET /accounts/divisions/
List subjects GET /accounts/subjects/
List governorates GET /accounts/governorates/
List areas GET /accounts/areas/
List video security GET /accounts/video-security/
List chapters GET /curriculum/chapters/
List lessons GET /curriculum/lessons/

Note: All these endpoints support ?all=true to bypass pagination and get complete lists for dropdowns.


Static Files Needed

No static files are served by the backend. The frontend should handle all assets (images, icons, logos) on its own.


Auth Flow Summary

1. POST /accounts/login/ with {username, password} 2. Server sets httpOnly cookies: access_token (30min), refresh_token (7d) 3. Server returns JSON: {role: "siteowner", name: "Admin", is_active: true} 4. Frontend stores {role, name} in React context/state 5. All subsequent requests automatically send cookies (browser handles this) 6. When access_token expires → POST /accounts/token/refresh/ (reads refresh cookie) 7. POST /accounts/logout/ to clear cookies

Note: Since cookies are httpOnly, the frontend CANNOT read the JWT. Session restoration works via GET /accounts/me/ which reads the cookie and returns {role, name, is_active}.


Error Handling

All API errors follow this pattern:

{"error": "Human-readable error message"}

HTTP Status codes: