Fixed Leave rejection and approvals
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user