addSlotSupervisor method
Adds a supervisor to the slot with the given slotId
.
Implementation
Future<void> addSlotSupervisor({required int slotId, required int supervisorId}) async {
if (!state.hasData) {
log('Cannot add supervisor: No data');
return;
}
log('Adding supervisor $supervisorId to slot $slotId');
try {
data(
state.requireData.map((s) {
if (s.id == slotId) {
return s.copyWith(supervisors: [...s.supervisors, supervisorId]);
}
return s;
}).toList(),
);
await _datasource.addSupervisor(
token: _auth.state.requireData.pick(Webservice.lb_planner_api),
slotId: slotId,
supervisorId: supervisorId,
);
log('Added supervisor $supervisorId to slot $slotId');
} catch (e, s) {
log('Failed to add supervisor $supervisorId to slot $slotId', e, s);
}
}