feat: create table
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/table_remote_datasource.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'create_table_event.dart';
|
||||
@@ -9,12 +7,19 @@ part 'create_table_state.dart';
|
||||
part 'create_table_bloc.freezed.dart';
|
||||
|
||||
class CreateTableBloc extends Bloc<CreateTableEvent, CreateTableState> {
|
||||
CreateTableBloc() : super(_Initial()) {
|
||||
final TableRemoteDataSource _tableRemoteDataSource;
|
||||
CreateTableBloc(this._tableRemoteDataSource)
|
||||
: super(CreateTableState.initial()) {
|
||||
on<_CreateTable>((event, emit) async {
|
||||
emit(_Loading());
|
||||
await ProductLocalDatasource.instance
|
||||
.createTableManagement(event.tableName, event.position);
|
||||
emit(_Success('Create Table Success'));
|
||||
final result = await _tableRemoteDataSource.createTable(
|
||||
tableName: event.tableName,
|
||||
capacity: event.capacity,
|
||||
location: event.location,
|
||||
);
|
||||
|
||||
result.fold((l) => emit(_Error(l)),
|
||||
(r) => emit(_Success('Meja berhasil dibuat')));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user