Refactor Staff and Store models to use fromMap method; enhance StoreCubit with provider management functionality

This commit is contained in:
2026-04-17 12:40:58 +02:00
parent 22a4f1dac4
commit 08a521c21c
6 changed files with 176 additions and 38 deletions

View File

@@ -18,20 +18,20 @@ class StaffMemberModel extends Equatable {
required this.companyId,
});
factory StaffMemberModel.fromJson(Map<String, dynamic> json) {
factory StaffMemberModel.fromMap(Map<String, dynamic> map) {
return StaffMemberModel(
id: json['id'],
id: map['id'],
// Applichiamo il tuo myFormat per visualizzare i nomi correttamente
name: (json['name'] as String).myFormat(),
name: (map['name'] as String).myFormat(),
// L'email la teniamo lowercase per standard tecnico
email: (json['email'] as String? ?? '').toLowerCase().trim(),
phone: (json['phone'] as String? ?? '').trim(),
isActive: json['is_active'] ?? true,
companyId: json['company_id'],
email: (map['email'] as String? ?? '').toLowerCase().trim(),
phone: (map['phone'] as String? ?? '').trim(),
isActive: map['is_active'] ?? true,
companyId: map['company_id'],
);
}
Map<String, dynamic> toJson() {
Map<String, dynamic> toMap() {
return {
if (id != null) 'id': id,
'name': name.toLowerCase().trim(), // Salviamo pulito per le query