maremma maiala impestata, buonissima base dopo ultra refactor

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-02 12:19:04 +02:00
parent 1721b2ff89
commit 67e8b8b654
23 changed files with 706 additions and 2730 deletions

View File

@@ -210,12 +210,40 @@ class OperationsCubit extends Cubit<OperationsState> {
.toList();
}
void updateField({String? customerId, String? customerDisplayName}) {
// --- GESTIONE DELLO STATO DEL FORM IN TEMPO REALE ---
void updateOperationFields({
String? customerId,
String? customerDisplayName,
String? type,
String? providerId,
String? subtype,
DateTime? expirationDate,
int? quantity,
// Aggiungiamo questi flag per forzare la pulizia dei campi quando cambi tipo
bool clearProvider = false,
bool clearType = false,
bool clearSubtype = false,
bool clearExpiration = false,
}) {
if (state.currentOperation == null) return;
final updated = state.currentOperation!.copyWith(
final current = state.currentOperation!;
// Creiamo il modello aggiornato
// ATTENZIONE: adatta questa logica in base a come è scritto il tuo copyWith!
final updated = current.copyWith(
customerId: customerId,
customerDisplayName: customerDisplayName,
type: clearType ? null : type,
subtype: clearSubtype ? null : subtype,
expirationDate: clearExpiration ? null : expirationDate,
// Se clearProvider è true, forziamo una stringa vuota (o null se il tuo modello lo supporta)
providerId: clearProvider ? null : (providerId ?? current.providerId),
// Idem per subtype e date.
// Se expirationDate è nullabile nel copyWith, dovresti poterlo gestire
quantity: quantity ?? current.quantity,
);
emit(state.copyWith(currentOperation: updated));
}
}