Fixed Leave rejection and approvals

This commit is contained in:
2026-03-11 18:59:28 +08:00
parent 21e6d68910
commit f8c79acbbc
4 changed files with 41 additions and 9 deletions
+6
View File
@@ -8,6 +8,12 @@ import 'stream_recovery.dart';
import 'realtime_controller.dart';
/// All visible leaves (own for standard, all for admin/dispatcher/it_staff).
///
/// Consumers should **not** treat every record as an active absence; the UI
/// layers (dashboard, logbook) explicitly filter to `status == 'approved'` and
/// verify the leave overlaps the current time. This prevents rejected or
/// pending applications from inadvertently influencing schedules or status
/// computations.
final leavesProvider = StreamProvider<List<LeaveOfAbsence>>((ref) {
final client = ref.watch(supabaseClientProvider);
final profileAsync = ref.watch(currentProfileProvider);
+11 -6
View File
@@ -127,12 +127,17 @@ final swapRequestsProvider = StreamProvider<List<SwapRequest>>((ref) {
ref.onDispose(wrapper.dispose);
return wrapper.stream.map((result) {
return result.data
.where(
(row) =>
row.requesterId == profile.id || row.recipientId == profile.id,
)
.toList();
// only return requests that are still actionable; once a swap has been
// accepted or rejected we no longer need to bubble it up to the UI for
// either party. admins still see "admin_review" rows so they can act on
// escalated cases.
return result.data.where((row) {
if (!(row.requesterId == profile.id || row.recipientId == profile.id)) {
return false;
}
// only keep pending and admin_review statuses
return row.status == 'pending' || row.status == 'admin_review';
}).toList();
});
});