deleteSlot method

Future<void> deleteSlot(
  1. int slotId
)

Deletes the slot with the given slotId.

Implementation

Future<void> deleteSlot(int slotId) async {
  if (!state.hasData) {
    log('Cannot delete slot: No data');
    return;
  }

  log('Deleting slot with id $slotId');
  try {
    data(state.requireData.where((s) => s.id != slotId).toList());

    await _datasource.deleteSlot(token: _auth.state.requireData.pick(Webservice.lb_planner_api), slotId: slotId);
    log('Deleted slot with id $slotId');

    await captureEvent(
      'slot_deleted',
      properties: {
        'slotId': slotId,
      },
    );
  } catch (e, s) {
    log('Failed to delete slot with id $slotId', e, s);
  }
}