Leave & Holiday Management
Last updated August 2, 2026
Classgrid's Leave & Holiday system has two interconnected modules:
- Leave Management (
leave.routes.js) — Student leave requests, teacher approvals, quick-leave mode, leave summary, and weekly calendar view. Stored in Supabaseleave_requeststable. - Holiday Calendar (
holidays.routes.js) — Organization holiday management with Google Calendar auto-sync for Indian festivals, manual holiday creation, and holiday-aware guards across the platform. Stored in Supabaseholidaystable.
Leave Management
Student: Apply for Leave
API: POST /api/leave/request
Roles: Any authenticated user (typically student)
Body:
Leave types: casual, sick, long, quick
Day types: full, first_half, second_half
Workflow:
- Validates
from_dateis provided - Looks up the classroom to find the
teacher_id(for routing the approval) - Creates a
leave_requestsrecord in Supabase withstatus: pending - Sends push notification to the teacher via
dispatchNotification:- Title: "📩 Leave Request — [Student Name]"
- Message: "[Name] has applied for [type] leave from [date] to [date]"
Student: Quick Leave (No Approval Needed)
API: POST /api/leave/quick
Roles: Any authenticated user
Body:
Workflow:
- Auto-generates a message: "Ma'am/Sir, I will not be able to attend class the first half on 10 September, 2026."
- Creates a leave record with
status: quick(no approval needed) total_daysis1for full day,0.5for half day- Sends informational notification to teacher
Student: View My Leave Requests
API: GET /api/leave/me
Roles: Any authenticated user
Returns all leave requests for the student, populated with:
- Classroom info (name, subject) from MongoDB
- Leave type, day type, dates, reason
- Status and teacher notes
Student: Cancel Pending Leave
API: DELETE /api/leave/:requestId
Roles: Any authenticated user (own leave only)
Only deletes if status is pending. Returns error if already approved/rejected.
Student: Leave Summary & Balance
API: GET /api/leave/summary
Roles: Any authenticated user
Returns:
The monthlyUsage map is designed for chart/graph rendering on the frontend.
Teacher: Manage Leave Requests
View Requests for My Classes
API: GET /api/leave/teacher
Roles: faculty, org_admin
Query params: status — filter by pending, approved, rejected, quick, or all
Returns all leave requests where teacher_id matches the current user.
Approve / Reject
API: PUT /api/leave/:requestId/status
Roles: faculty, org_admin
Body:
Valid statuses: approved, rejected
Workflow:
- Updates the leave request in Supabase
- Sends push notification to student:
- Approved: "🏠 Leave Approved ✅ — Your [type] request has been approved."
- Rejected: "🏠 Leave Rejected ❌ — Your [type] request has been rejected. Note: [teacher note]"
Weekly Calendar View
API: GET /api/leave/calendar
Roles: faculty, org_admin
Query params: weekStart — e.g., 2026-09-07 (Monday). Defaults to current week.
Returns a 7-day calendar showing which students are on leave each day:
Filters: only shows approved and quick leaves that overlap with the requested week.
Holiday Calendar
View All Holidays
API: GET /api/holidays/
Roles: Any authenticated user
Query params:
year— defaults to current yearmonth— formatYYYY-MM(e.g.,2026-08)search— text search on holiday title
Auto-sync behavior: If zero holidays exist for the requested year, the system automatically syncs festivals from Google Calendar before returning results.
Check Today's Holiday
API: GET /api/holidays/today
Roles: Any authenticated user
Returns { isHoliday: true/false, holiday: { title, date } } using the shared isHoliday() utility function. This same function is used by the attendance and assignment modules to block operations on holidays.
Upcoming Holidays (Next 5 Days)
API: GET /api/holidays/upcoming
Roles: Any authenticated user
Returns holidays within the next 5 days with countdown info:
countdownText returns "Today", "Tomorrow", or "in X days".
Toggle Holiday Status (Admin)
API: PATCH /api/holidays/:id
Roles: org_admin
Body: { "is_holiday": true }
Allows admins to mark/unmark a festival as a working day or holiday for their organization. Google-synced festivals default to is_holiday: false — admins must explicitly enable the ones they observe.
Add Custom Holiday
API: POST /api/holidays/manual
Roles: org_admin
Body:
Creates a holiday with source: manual and is_holiday: true.
Sync Indian Festivals from Google Calendar
API: POST /api/holidays/sync
Roles: org_admin
Query params: year — defaults to current year
Workflow:
- Checks if festivals for this year already exist for the org (skips if yes)
- Fetches the public Indian holidays iCal feed from Google Calendar:
calendar.google.com/calendar/ical/en.indian%23holiday@group.v.calendar.google.com/public/basic.ics - Parses ICS format — extracts
SUMMARY,DTSTART,DTENDfor eachVEVENT - Filters to the target year
- Upserts into
holidaystable (conflict onorg_id, title, date) - Returns: "Synced 45 festivals for 2026"
Holiday Guards Across the Platform
The isHoliday() utility function is used as a guard in: