Refactor service management: streamline service form, enhance state management, and improve loading logic
This commit is contained in:
@@ -115,12 +115,14 @@ class ServiceModel extends Equatable {
|
||||
|
||||
factory ServiceModel.fromMap(Map<String, dynamic> map) {
|
||||
return ServiceModel(
|
||||
id: map['id'],
|
||||
createdAt: DateTime.parse(map['created_at']),
|
||||
storeId: map['store_id'],
|
||||
employeeId: map['employee_id'],
|
||||
customerId: map['customer_id'],
|
||||
number: map['number'] ?? '',
|
||||
id: map['id'].toString(),
|
||||
createdAt: map['created_at'] != null
|
||||
? DateTime.parse(map['created_at'])
|
||||
: DateTime.now(),
|
||||
storeId: map['store_id'] ?? '',
|
||||
employeeId: map['employee_id']?.toString(),
|
||||
customerId: map['customer_id']?.toString(),
|
||||
number: map['number']?.toString() ?? '',
|
||||
isBozza: map['bozza'] ?? true,
|
||||
note: map['note'] ?? '',
|
||||
resultOk: map['result_ok'] ?? true,
|
||||
@@ -130,7 +132,7 @@ class ServiceModel extends Equatable {
|
||||
unica: map['unica'] ?? 0,
|
||||
telepass: map['telepass'] ?? 0,
|
||||
|
||||
// Mappaggio delle liste collegate (se incluse nella query)
|
||||
// Estrazione sicura liste collegate
|
||||
energyServices:
|
||||
(map['energy_service'] as List?)
|
||||
?.map((x) => EnergyServiceModel.fromMap(x))
|
||||
@@ -146,9 +148,12 @@ class ServiceModel extends Equatable {
|
||||
?.map((x) => EntertainmentServiceModel.fromMap(x))
|
||||
.toList() ??
|
||||
const [],
|
||||
|
||||
// Display name del cliente con fallback
|
||||
customerDisplayName: map['customer'] != null
|
||||
? "${map['customer']['name']} ${map['customer']['surname']}"
|
||||
: "Cliente sconosciuto",
|
||||
? "${map['customer']['name'] ?? ''} ${map['customer']['surname'] ?? ''}"
|
||||
.trim()
|
||||
: "Cliente non assegnato",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user