rework-onboarding (#7)

Onboarding completato, ora super rapido e top

Reviewed-on: http://catelliub.zapto.org:3000/brontomark/flux/pulls/7
Co-authored-by: Mark M2 Macbook <marco@catelli.it>
Co-committed-by: Mark M2 Macbook <marco@catelli.it>
This commit is contained in:
2026-04-22 11:06:02 +02:00
committed by brontomark
parent c5b5b76bd6
commit 90bd5ecacf
47 changed files with 1742 additions and 516 deletions

View File

@@ -1,7 +1,7 @@
import 'package:collection/collection.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/blocs/session/session_bloc.dart';
import 'package:flux/core/blocs/session/session_cubit.dart';
import 'package:flux/features/master_data/products/data/product_repository.dart';
import 'package:flux/features/master_data/products/models/brand_model.dart';
import 'package:flux/features/master_data/products/models/model_model.dart';
@@ -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