removeSlotSupervisor method
Removes a supervisor from the slot with the given slotId
.
Implementation
Future<void> removeSlotSupervisor({required int slotId, required int supervisorId}) async {
if (!state.hasData) {
log('Cannot remove supervisor: No data');
return;
}
log('Removing supervisor $supervisorId from slot $slotId');
try {
data(
state.requireData.map((s) {
if (s.id == slotId) {
return s.copyWith(supervisors: s.supervisors.where((id) => id != supervisorId).toList());
}
return s;
}).toList(),
);
await _datasource.removeSupervisor(
token: _auth.state.requireData.pick(Webservice.lb_planner_api),
slotId: slotId,
supervisorId: supervisorId,
);
log('Removed supervisor $supervisorId from slot $slotId');
} catch (e, s) {
log('Failed to remove supervisor $supervisorId from slot $slotId', e, s);
}
}