sistemato deeplinking alla serviceformscreen, aggiunto logout e sistemate altre cose

This commit is contained in:
2026-04-19 10:57:55 +02:00
parent e9f3327f31
commit 023665ae58
17 changed files with 742 additions and 198 deletions

View File

@@ -199,22 +199,24 @@ class ServicesCubit extends Cubit<ServicesState> {
// --- PERSISTENZA ---
Future<void> saveCurrentService() async {
Future<void> saveCurrentService({required bool isBozza}) async {
if (state.currentService == null) return;
emit(state.copyWith(status: ServicesStatus.saving, errorMessage: null));
try {
// Usiamo il repository corazzato che abbiamo scritto prima
await _repository.saveFullService(state.currentService!);
// 1. Aggiorniamo il flag bozza in base a quale pulsante ha premuto l'utente
final serviceToSave = state.currentService!.copyWith(isBozza: isBozza);
await loadServices(refresh: true);
// Reset della bozza e ricaricamento lista
// 2. Salvataggio corazzato
await _repository.saveFullService(serviceToSave);
// 3. Reset e ricaricamento
emit(state.copyWith(status: ServicesStatus.saved, currentService: null));
await loadServices(refresh: true);
} catch (e) {
emit(
state.copyWith(
status: ServicesStatus.failure,
errorMessage: e.toString(),
),
);