Reference for leave request workflow states in CHRIS.
Status Values
| Status | Description |
|---|---|
| pending | Request submitted, awaiting approval |
| approved | Request approved by manager/HR |
| rejected | Request denied by manager/HR |
| cancelled | Request cancelled by employee |
Workflow Diagram
stateDiagram-v2
[*] --> pending: Submit Request
pending --> approved: Approve
pending --> rejected: Reject
pending --> cancelled: Cancel
approved --> cancelled: Revoke (HR only)
rejected --> [*]
cancelled --> [*]
approved --> [*]
State Transitions
pending → approved
Trigger: Manager or HR approves the request
Who can do this:
- Team leader (for team members)
- HR Manager (for any employee)
- Admin (for any employee)
Required fields:
approver_user_id- Who approvedapproved_at- Timestamp of approvalapprover_comment- Optional comment
Effects:
- Working days deducted from balance
- Employee notified via email
- Request appears on team calendar
pending → rejected
Trigger: Manager or HR rejects the request
Who can do this:
- Team leader (for team members)
- HR Manager (for any employee)
- Admin (for any employee)
Required fields:
approver_user_id- Who rejectedapproved_at- Timestamp of rejectionapprover_comment- Required (reason for rejection)
Effects:
- No balance change
- Employee notified via email with reason
pending → cancelled
Trigger: Employee cancels their own request
Who can do this:
- The employee who submitted the request
- HR Manager
- Admin
Effects:
- Request removed from pending queue
- No balance change (request was never approved)
approved → cancelled (Revoke)
Trigger: HR or Admin revokes an approved request
Who can do this:
- HR Manager
- Admin
Required fields:
approver_comment- Reason for revocation
Effects:
- Working days restored to balance
- Employee notified of revocation
- Request removed from calendar
!!! warning "Use Sparingly" Revoking approved leave should be rare and well-justified.
Status Colors
| Status | Color | Hex |
|---|---|---|
| pending | Yellow | #FFC107 |
| approved | Green | #4CAF50 |
| rejected | Red | #F44336 |
| cancelled | Gray | #9E9E9E |
Database Enum
CREATE TYPE leave_status AS ENUM (
'pending',
'approved',
'rejected',
'cancelled'
);
Querying by Status
Get Pending Requests
const { data } = await supabase
.from('leave_requests')
.select('*')
.eq('status', 'pending')
.order('created_at', { ascending: true });
Get Approved Requests for Date Range
const { data } = await supabase
.from('leave_requests')
.select('*')
.eq('status', 'approved')
.gte('start_date', '2025-01-01')
.lte('end_date', '2025-12-31');
Count by Status
const { count } = await supabase
.from('leave_requests')
.select('*', { count: 'exact', head: true })
.eq('status', 'pending')
.eq('user_id', userId);
Updating Status
Approve Request
const { error } = await supabase
.from('leave_requests')
.update({
status: 'approved',
approver_user_id: approverId,
approver_comment: 'Approved. Enjoy your time off!',
approved_at: new Date().toISOString()
})
.eq('id', requestId);
Reject Request
const { error } = await supabase
.from('leave_requests')
.update({
status: 'rejected',
approver_user_id: approverId,
approver_comment: 'Cannot approve due to project deadline.',
approved_at: new Date().toISOString()
})
.eq('id', requestId);
Cancel Request
const { error } = await supabase
.from('leave_requests')
.update({
status: 'cancelled'
})
.eq('id', requestId)
.eq('status', 'pending'); // Only cancel if still pending
UI Display
Status Badge Component
function StatusBadge({ status }: { status: string }) {
const colors = {
pending: 'bg-yellow-100 text-yellow-800',
approved: 'bg-green-100 text-green-800',
rejected: 'bg-red-100 text-red-800',
cancelled: 'bg-gray-100 text-gray-800',
};
return (
<span className={`px-2 py-1 rounded ${colors[status]}`}>
{t(`leaveRequests.status.${status}`)}
</span>
);
}
Translated Status Names
| Status | Croatian | English | Russian | Hindi |
|---|---|---|---|---|
| pending | Na čekanju | Pending | Ожидает | लंबित |
| approved | Odobreno | Approved | Одобрено | स्वीकृत |
| rejected | Odbijeno | Rejected | Отклонено | अस्वीकृत |
| cancelled | Otkazano | Cancelled | Отменено | रद्द |
Business Rules
Pending Requests
- Can only be modified by the submitter
- Auto-expire if not acted upon within X days (configurable)
- Show warning if balance insufficient
Approved Requests
- Cannot be edited
- Can only be revoked by HR/Admin
- Contribute to leave calendar
Rejected Requests
- Employee can submit a new request
- Keep historical record for auditing
Cancelled Requests
- Soft delete - data preserved
- Can be filtered out from normal views
- Available in audit logs