Skip to main content

Leaves

Apply for Leave

POST /parent/leave/create-leave
{
"data": {
"studentId": "{id}",
"fromDate": "2024-04-15",
"toDate": "2024-04-16",
"reason": "Family wedding",
"type": "SICK"
}
}

Leave Types

TypeDescription
SICKMedical leave
CASUALPersonal leave

Leave Status

StatusVisual
PENDINGYellow badge
APPROVEDGreen badge
REJECTEDRed badge

Leave History

GET /parent/leave/get-leaves
{
"data": {
"leaves": [
{
"id": "uuid",
"fromDate": "2024-04-10",
"toDate": "2024-04-11",
"reason": "Medical appointment",
"type": "SICK",
"status": "APPROVED",
"appliedAt": "2024-04-09T08:00:00Z",
"approvedBy": "Mr. R. Kumar"
}
]
}
}

UI — Apply Leave Form

class LeaveApplyScreen extends StatefulWidget {
@override
State<LeaveApplyScreen> createState() => _LeaveApplyScreenState();
}

class _LeaveApplyScreenState extends State<LeaveApplyScreen> {
final _formKey = GlobalKey<FormState>();
DateTime? _fromDate;
DateTime? _toDate;
String _reason = '';
String _type = 'SICK';

@override
Widget build(BuildContext context) {
return Form(
key: _formKey,
child: Column(
children: [
DropdownButtonFormField<String>(
value: _type,
items: const [
DropdownMenuItem(value: 'SICK', child: Text('Sick Leave')),
DropdownMenuItem(value: 'CASUAL', child: Text('Casual Leave')),
],
onChanged: (v) => setState(() => _type = v!),
),
Row(
children: [
Expanded(
child: ListTile(
title: const Text('From'),
subtitle: Text(_fromDate?.toString() ?? 'Select'),
onTap: () => _selectDate(true),
),
),
Expanded(
child: ListTile(
title: const Text('To'),
subtitle: Text(_toDate?.toString() ?? 'Select'),
onTap: () => _selectDate(false),
),
),
],
),
TextFormField(
decoration: const InputDecoration(labelText: 'Reason'),
maxLines: 3,
onChanged: (v) => _reason = v,
validator: (v) => v!.isEmpty ? 'Required' : null,
),
ElevatedButton(
onPressed: _submit,
child: const Text('Submit Application'),
),
],
),
);
}
}