mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Refactor SpaceDetailsModel and ProductAllocation: Update JSON parsing for clarity and remove unused location field. Change subspace name mapping for consistency with API response.
This commit is contained in:
@ -31,8 +31,8 @@ class SpaceDetailsModel extends Equatable {
|
||||
spaceName: json['spaceName'] as String,
|
||||
icon: json['icon'] as String,
|
||||
productAllocations: (json['productAllocations'] as List)
|
||||
.map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
.map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
subspaces: (json['subspaces'] as List)
|
||||
.map((e) => Subspace.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
@ -72,12 +72,10 @@ class SpaceDetailsModel extends Equatable {
|
||||
class ProductAllocation extends Equatable {
|
||||
final Product product;
|
||||
final Tag tag;
|
||||
final String? location;
|
||||
|
||||
const ProductAllocation({
|
||||
required this.product,
|
||||
required this.tag,
|
||||
this.location,
|
||||
});
|
||||
|
||||
factory ProductAllocation.fromJson(Map<String, dynamic> json) {
|
||||
@ -97,12 +95,10 @@ class ProductAllocation extends Equatable {
|
||||
ProductAllocation copyWith({
|
||||
Product? product,
|
||||
Tag? tag,
|
||||
String? location,
|
||||
}) {
|
||||
return ProductAllocation(
|
||||
product: product ?? this.product,
|
||||
tag: tag ?? this.tag,
|
||||
location: location ?? this.location,
|
||||
);
|
||||
}
|
||||
|
||||
@ -124,7 +120,7 @@ class Subspace extends Equatable {
|
||||
factory Subspace.fromJson(Map<String, dynamic> json) {
|
||||
return Subspace(
|
||||
uuid: json['uuid'] as String,
|
||||
name: json['name'] as String,
|
||||
name: json['subspaceName'] as String,
|
||||
productAllocations: (json['productAllocations'] as List)
|
||||
.map((e) => ProductAllocation.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
|
Reference in New Issue
Block a user