Add Providers Management to Master Data Hub and Enhance Provider Model

This commit is contained in:
2026-04-16 19:25:42 +02:00
parent c7eedba5ac
commit aa18b7dd1f
5 changed files with 188 additions and 46 deletions

View File

@@ -11,6 +11,7 @@ class ProviderModel extends Equatable {
final bool altro;
final bool isActive;
final String companyId;
final int storesCount;
const ProviderModel({
this.id,
@@ -23,6 +24,7 @@ class ProviderModel extends Equatable {
required this.altro,
required this.isActive,
required this.companyId,
this.storesCount = 0, // Numero di store associati, default a 0
});
factory ProviderModel.fromMap(Map<String, dynamic> map) {
@@ -37,6 +39,11 @@ class ProviderModel extends Equatable {
altro: map['altro'] ?? false,
isActive: map['is_active'] ?? true,
companyId: map['company_id'],
storesCount:
map['providers_in_stores'] != null &&
map['providers_in_stores'].isNotEmpty
? map['providers_in_stores'][0]['count'] as int
: 0, // Assumiamo che l'API possa restituire questo campo
);
}
@@ -72,6 +79,7 @@ class ProviderModel extends Equatable {
altro,
isActive,
companyId,
storesCount,
];
ProviderModel copyWith({
@@ -85,6 +93,7 @@ class ProviderModel extends Equatable {
bool? altro,
bool? isActive,
String? companyId,
int? storesCount,
}) {
return ProviderModel(
id: id ?? this.id,
@@ -97,6 +106,7 @@ class ProviderModel extends Equatable {
altro: altro ?? this.altro,
isActive: isActive ?? this.isActive,
companyId: companyId ?? this.companyId,
storesCount: storesCount ?? this.storesCount,
);
}
}