pennellato git da rosso ad arancio e verde
This commit is contained in:
@@ -11,7 +11,7 @@ part 'product_state.dart';
|
||||
|
||||
class ProductCubit extends Cubit<ProductState> {
|
||||
final ProductRepository _repository = GetIt.I<ProductRepository>();
|
||||
final SessionBloc _sessionBloc = GetIt.I<SessionBloc>();
|
||||
final SessionCubit _sessionCubit = GetIt.I<SessionCubit>();
|
||||
|
||||
ProductCubit() : super(const ProductState());
|
||||
|
||||
@@ -20,7 +20,7 @@ class ProductCubit extends Cubit<ProductState> {
|
||||
emit(state.copyWith(status: ProductStatus.loading));
|
||||
try {
|
||||
final brands = await _repository.getBrands(
|
||||
_sessionBloc.state.company!.id,
|
||||
_sessionCubit.state.company!.id!,
|
||||
);
|
||||
emit(state.copyWith(status: ProductStatus.success, brands: brands));
|
||||
} catch (e) {
|
||||
@@ -54,7 +54,7 @@ class ProductCubit extends Cubit<ProductState> {
|
||||
final brand = BrandModel(
|
||||
id: id,
|
||||
name: name,
|
||||
companyId: _sessionBloc.state.company!.id,
|
||||
companyId: _sessionCubit.state.company!.id!,
|
||||
);
|
||||
final newBrand = await _repository.upsertBrand(brand);
|
||||
await loadBrands(); // Ricarichiamo la lista aggiornata
|
||||
@@ -137,7 +137,10 @@ class ProductCubit extends Cubit<ProductState> {
|
||||
// 1. Cerchiamo o creiamo il Brand
|
||||
// (Usa una funzione upsert o una ricerca rapida nel repository)
|
||||
brand ??= await _repository.upsertBrand(
|
||||
BrandModel(name: brandName, companyId: _sessionBloc.state.company!.id),
|
||||
BrandModel(
|
||||
name: brandName,
|
||||
companyId: _sessionCubit.state.company!.id!,
|
||||
),
|
||||
);
|
||||
|
||||
// 2. Creiamo il Modello legato al Brand
|
||||
|
||||
Reference in New Issue
Block a user