feat: create table

This commit is contained in:
efrilm
2025-08-03 23:33:00 +07:00
parent 617b5c54f2
commit 8431b07057
9 changed files with 393 additions and 95 deletions
@@ -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')));
});
}
}