This commit is contained in:
2026-05-06 19:25:17 +02:00
parent d15d7e458b
commit 040db4ad79
8 changed files with 60 additions and 53 deletions

View File

@@ -35,8 +35,7 @@ enum TicketStatus {
final String displayValue;
const TicketStatus(this.value, this.displayValue);
static TicketStatus? fromString(String? val) {
if (val == null) return null;
static TicketStatus fromString(String? val) {
return TicketStatus.values.firstWhere(
(e) => e.value == val,
orElse: () => TicketStatus.open,
@@ -103,9 +102,9 @@ class TicketModel extends Equatable {
final String? alternativePhoneNumber;
final bool hasCourtesyDevice;
final TicketType ticketType;
final TicketStatus? status;
final TicketStatus ticketStatus;
final DateTime? estimatedDeliveryAt;
final TicketResult? result;
final TicketResult? ticketResult;
final String? resolutionNotes;
final String? legacyId;
final String? customerName;
@@ -139,9 +138,9 @@ class TicketModel extends Equatable {
this.alternativePhoneNumber,
this.hasCourtesyDevice = false,
required this.ticketType,
this.status,
this.ticketStatus = TicketStatus.closed,
this.estimatedDeliveryAt,
this.result,
this.ticketResult,
this.resolutionNotes,
this.legacyId,
this.customerName,
@@ -160,7 +159,7 @@ class TicketModel extends Equatable {
companyId: companyId ?? '',
storeId: storeId,
ticketType: TicketType.repair, // Valore di default
status: TicketStatus.open,
ticketStatus: TicketStatus.open,
customerPrice: 0.0,
internalCost: 0.0,
hasCourtesyDevice: false,
@@ -190,9 +189,9 @@ class TicketModel extends Equatable {
String? alternativePhoneNumber,
bool? hasCourtesyDevice,
TicketType? ticketType,
TicketStatus? status,
TicketStatus? ticketStatus,
DateTime? estimatedDeliveryAt,
TicketResult? result,
TicketResult? ticketResult,
String? resolutionNotes,
String? legacyId,
String? customerName,
@@ -227,9 +226,9 @@ class TicketModel extends Equatable {
alternativePhoneNumber ?? this.alternativePhoneNumber,
hasCourtesyDevice: hasCourtesyDevice ?? this.hasCourtesyDevice,
ticketType: ticketType ?? this.ticketType,
status: status ?? this.status,
ticketStatus: ticketStatus ?? this.ticketStatus,
estimatedDeliveryAt: estimatedDeliveryAt ?? this.estimatedDeliveryAt,
result: result ?? this.result,
ticketResult: ticketResult ?? this.ticketResult,
resolutionNotes: resolutionNotes ?? this.resolutionNotes,
legacyId: legacyId ?? this.legacyId,
customerName: customerName ?? this.customerName,
@@ -274,11 +273,11 @@ class TicketModel extends Equatable {
alternativePhoneNumber: map['alternative_phone_number'] as String?,
hasCourtesyDevice: map['has_courtesy_device'] as bool? ?? false,
ticketType: TicketType.fromString(map['ticket_type'] as String),
status: TicketStatus.fromString(map['status'] as String?),
ticketStatus: TicketStatus.fromString(map['ticket_status'] as String),
estimatedDeliveryAt: map['estimated_delivery_at'] != null
? DateTime.parse(map['estimated_delivery_at']).toLocal()
: null,
result: TicketResult.fromString(map['result'] as String?),
ticketResult: TicketResult.fromString(map['ticket_result'] as String?),
resolutionNotes: map['resolution_notes'] as String?,
legacyId: map['legacy_id'] as String?,
customerName: (map['customer']?['name'] as String?).myFormat(),
@@ -318,10 +317,10 @@ class TicketModel extends Equatable {
'alternative_phone_number': alternativePhoneNumber,
'has_courtesy_device': hasCourtesyDevice,
'ticket_type': ticketType.value,
if (status != null) 'status': status!.value,
'ticket_status': ticketStatus.value,
if (estimatedDeliveryAt != null)
'estimated_delivery_at': estimatedDeliveryAt!.toUtc().toIso8601String(),
if (result != null) 'result': result!.value,
if (ticketResult != null) 'ticket_result': ticketResult!.value,
'resolution_notes': resolutionNotes,
'legacy_id': legacyId,
'included_accessories': includedAccessories,
@@ -351,9 +350,9 @@ class TicketModel extends Equatable {
alternativePhoneNumber,
hasCourtesyDevice,
ticketType,
status,
ticketStatus,
estimatedDeliveryAt,
result,
ticketResult,
resolutionNotes,
legacyId,
includedAccessories,