Skip to main content

Leaves

Teachers can apply for their own leaves and approve/reject student leave requests.

Apply for Own Leave

POST /teacher/leaves/add-leave-teacher
{
"data": {
"fromDate": "2024-04-15",
"toDate": "2024-04-16",
"reason": "Personal work",
"type": "CASUAL",
"halfDay": false
}
}

Get Own Leaves

GET /teacher/leaves/get-leaves-teacher

Student Leaves (Read-Only)

Student leave requests are visible to teachers but do not require approval — the status is automatically computed from dates.

GET /teacher/leaves/get-leaves-student
{
"data": {
"leaves": [
{
"id": "uuid",
"studentName": "John Doe",
"className": "Class 5-A",
"dates": { "from": "2024-04-15", "to": "2024-04-16" },
"reason": "Family wedding",
"type": "SICK",
"status": "PENDING",
"attachment": { "link": "s3://bucket/medical-cert.pdf" }
}
]
}
}

Status is auto-calculated: if toDate is in the past, the leave is marked REJECTED automatically by the system.

UI — Student Leave List

class StudentLeaveScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final vm = context.watch<LeaveViewModel>();

return ListView.builder(
itemCount: vm.studentLeaves.length,
itemBuilder: (_, i) {
final leave = vm.studentLeaves[i];
return Card(
child: ListTile(
leading: CircleAvatar(
backgroundImage: leave.studentImage != null
? NetworkImage(leave.studentImage!)
: null,
child: leave.studentImage == null
? const Icon(Icons.person)
: null,
),
title: Text(leave.studentName ?? 'Unknown'),
subtitle: Text(
'${leave.className} • ${leave.dates['from']} to ${leave.dates['to']}\n'
'${leave.reason}',
),
isThreeLine: true,
trailing: Chip(
label: Text(leave.status),
backgroundColor: leave.status == 'PENDING'
? Colors.orange.shade100
: Colors.grey.shade100,
),
),
);
},
);
}
}