default provider
Some checks failed
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m59s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m22s
Build and Release FLUX (Multi-Platform) / build-windows (push) Has been cancelled

This commit is contained in:
2026-06-02 13:12:21 +02:00
parent a51ac8fe7f
commit 3210b4fcfa
12 changed files with 435 additions and 170 deletions

View File

@@ -17,14 +17,18 @@ class StoreCubit extends Cubit<StoreState> {
StoreCubit() : super(const StoreState(stores: []));
Future<void> createStore(final StoreModel store) async {
Future<void> saveStore(final StoreModel store) async {
emit(state.copyWith(status: StoreStatus.loading));
try {
await _repository.createStore(store);
emit(state.copyWith(status: StoreStatus.success));
final savedStore = await _repository.saveStore(store);
emit(state.copyWith(status: StoreStatus.success, savedStore: savedStore));
} catch (e) {
emit(
state.copyWith(status: StoreStatus.failure, errorMessage: e.toString()),
state.copyWith(
status: StoreStatus.failure,
errorMessage: e.toString(),
savedStore: null,
),
);
}
}
@@ -70,6 +74,7 @@ class StoreCubit extends Cubit<StoreState> {
state.copyWith(
status: StoreStatus.failure,
errorMessage: "Errore nel salvataggio dei provider: $e",
savedStore: null,
),
);
}
@@ -90,6 +95,7 @@ class StoreCubit extends Cubit<StoreState> {
state.copyWith(
status: StoreStatus.failure,
errorMessage: "Errore nel salvataggio dello staff: $e",
savedStore: null,
),
);
}
@@ -110,6 +116,7 @@ class StoreCubit extends Cubit<StoreState> {
state.copyWith(
status: StoreStatus.failure,
errorMessage: "Errore nell'associazione: $e",
savedStore: null,
),
);
}
@@ -130,6 +137,7 @@ class StoreCubit extends Cubit<StoreState> {
state.copyWith(
status: StoreStatus.failure,
errorMessage: "Errore nella rimozione: $e",
savedStore: null,
),
);
}
@@ -142,7 +150,11 @@ class StoreCubit extends Cubit<StoreState> {
loadStores();
} catch (e) {
emit(
state.copyWith(status: StoreStatus.failure, errorMessage: e.toString()),
state.copyWith(
status: StoreStatus.failure,
errorMessage: e.toString(),
savedStore: null,
),
);
}
}
@@ -157,6 +169,7 @@ class StoreCubit extends Cubit<StoreState> {
state.copyWith(
status: StoreStatus.failure,
errorMessage: "Errore nella rimozione: $e",
savedStore: null,
),
);
}

View File

@@ -7,6 +7,8 @@ class StoreState extends Equatable {
final StoreModel? store;
final String? errorMessage;
final List<StoreModel> stores;
final StoreModel?
savedStore; // Per tenere traccia del negozio appena salvato (utile per aggiornare la sessione)
final Map<String, List<StaffMemberModel>> staffByStore;
const StoreState({
@@ -14,6 +16,7 @@ class StoreState extends Equatable {
this.store,
this.errorMessage,
required this.stores,
this.savedStore,
this.staffByStore = const {},
});
@@ -22,6 +25,7 @@ class StoreState extends Equatable {
StoreModel? store,
String? errorMessage,
List<StoreModel>? stores,
StoreModel? savedStore,
Map<String, List<StaffMemberModel>>? staffByStore,
}) {
return StoreState(
@@ -29,6 +33,7 @@ class StoreState extends Equatable {
store: store ?? this.store,
errorMessage: errorMessage ?? this.errorMessage,
stores: stores ?? this.stores,
savedStore: savedStore ?? this.savedStore,
staffByStore: staffByStore ?? this.staffByStore,
);
}
@@ -39,6 +44,7 @@ class StoreState extends Equatable {
store,
errorMessage,
stores,
savedStore,
staffByStore,
];
}