@@ -142,6 +142,19 @@ class ShopInBitOrderModel extends ChangeNotifier {
142142 }
143143 }
144144
145+ // The most recent raw API state string, persisted alongside _status so that
146+ // we can recover from contract drift (renames / new states) without losing
147+ // history. _status is the parsed/mapped value; _statusRaw is the source of
148+ // truth straight from the API.
149+ String ? _statusRaw;
150+ String ? get statusRaw => _statusRaw;
151+ set statusRaw (String ? value) {
152+ if (_statusRaw != value) {
153+ _statusRaw = value;
154+ notifyListeners ();
155+ }
156+ }
157+
145158 String ? _offerProductName;
146159 String ? get offerProductName => _offerProductName;
147160
@@ -277,6 +290,7 @@ class ShopInBitOrderModel extends ChangeNotifier {
277290 displayName: Value (_displayName),
278291 category: Value (_category ?? ShopInBitCategory .concierge),
279292 status: Value (_status),
293+ statusRaw: Value (_statusRaw),
280294 requestDescription: Value (_requestDescription),
281295 deliveryCountry: Value (_deliveryCountry),
282296 offerProductName: Value (_offerProductName),
@@ -316,6 +330,7 @@ class ShopInBitOrderModel extends ChangeNotifier {
316330 .._apiTicketId = ticket.apiTicketId
317331 .._ticketId = ticket.ticketId
318332 .._status = ticket.status
333+ .._statusRaw = ticket.statusRaw
319334 .._requestDescription = ticket.requestDescription
320335 .._deliveryCountry = ticket.deliveryCountry
321336 .._offerProductName = ticket.offerProductName
@@ -335,7 +350,7 @@ class ShopInBitOrderModel extends ChangeNotifier {
335350 .._messages = messages;
336351 }
337352
338- static ShopInBitOrderStatus statusFromTicketState (TicketState state) {
353+ static ShopInBitOrderStatus ? statusFromTicketState (TicketState state) {
339354 switch (state) {
340355 case TicketState .newTicket:
341356 return ShopInBitOrderStatus .pending;
@@ -360,6 +375,8 @@ class ShopInBitOrderModel extends ChangeNotifier {
360375 return ShopInBitOrderStatus .cancelled;
361376 case TicketState .refunded:
362377 return ShopInBitOrderStatus .refunded;
378+ case TicketState .unknown:
379+ return null ;
363380 }
364381 }
365382}
0 commit comments