Skip to main content

Subjects Page

Route: /dashboard/subjects
File: app/dashboard/subjects/page.tsx

This page manages the catalog of subjects offered by the school. Subjects defined here are used for teacher assignments, student subject profiles, and grading.

Features

Subject List

A table showing all subjects with drag-to-sort reordering:

ColumnDescription
Drag handleGrip icon for drag-and-drop reordering
NameSubject name
CodeShort code (e.g., "MATH")
GradedBadge indicating if the subject is graded or remarks-only
Sort OrderNumeric ordering value (updated automatically on drag)
ActionsEdit and Delete buttons

Drag-to-Sort

Subjects can be reordered by dragging the grip handle. Uses @dnd-kit/core and @dnd-kit/sortable. On drop:

  1. The UI updates optimistically with the new order
  2. A PATCH /api/subjects/reorder request sends the new sort order for all items
  3. On failure, the list reverts to the previous order

Create Subject

A dialog form with:

FieldRequiredDescription
NameYese.g., "Mathematics"
CodeNoe.g., "MATH"
Is GradedNoToggle; defaults to true
Sort OrderNoNumeric display order

When Is Graded is off, the subject won't have grades recorded - only remarks. This is useful for subjects like Physical Education.

Edit Subject

Same form pre-filled with existing data.

Delete Subject

Confirmation dialog. Fails with an error if the subject has existing assessments or student assignments.

API Calls

ActionEndpoint
ListGET /api/subjects
CreatePOST /api/subjects
UpdatePATCH /api/subjects/:id
DeleteDELETE /api/subjects/:id
ReorderPATCH /api/subjects/reorder