fix phone dashboard

This commit is contained in:
root
2026-05-27 03:11:45 -04:00
parent 7ca43ba2f3
commit 1112b04516
48 changed files with 1222 additions and 368 deletions
+17 -2
View File
@@ -58,12 +58,27 @@ class CustomerListResponse {
required this.pageSize,
});
factory CustomerListResponse.fromApi(dynamic json) {
if (json is List<dynamic>) {
final customers = json
.map((e) => Customer.fromJson(e as Map<String, dynamic>))
.toList();
return CustomerListResponse(
data: customers,
total: customers.length,
page: 1,
pageSize: customers.length,
);
}
return CustomerListResponse.fromJson(json as Map<String, dynamic>);
}
factory CustomerListResponse.fromJson(Map<String, dynamic> json) =>
CustomerListResponse(
data: (json['data'] as List<dynamic>)
data: ((json['data'] ?? const <dynamic>[]) as List<dynamic>)
.map((e) => Customer.fromJson(e as Map<String, dynamic>))
.toList(),
total: json['total'] as int? ?? 0,
total: json['total'] as int? ?? ((json['data'] as List<dynamic>?)?.length ?? 0),
page: json['page'] as int? ?? 1,
pageSize: json['pageSize'] as int? ?? 20,
);