Reviewed-on: http://catelliub.zapto.org:3000/brontomark/flux/pulls/4 Co-authored-by: mark-cachy <marco@catelli.it> Co-committed-by: mark-cachy <marco@catelli.it>
48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
import 'package:flux/core/utils/string_extensions.dart'; // Assicurati che il percorso sia corretto
|
|
|
|
class StaffMemberModel extends Equatable {
|
|
final String? id;
|
|
final String name;
|
|
final String email;
|
|
final String phone;
|
|
final bool isActive;
|
|
final String companyId;
|
|
|
|
const StaffMemberModel({
|
|
this.id,
|
|
required this.name,
|
|
this.email = '',
|
|
this.phone = '',
|
|
this.isActive = true,
|
|
required this.companyId,
|
|
});
|
|
|
|
factory StaffMemberModel.fromMap(Map<String, dynamic> map) {
|
|
return StaffMemberModel(
|
|
id: map['id'],
|
|
// Applichiamo il tuo myFormat per visualizzare i nomi correttamente
|
|
name: (map['name'] as String).myFormat(),
|
|
// L'email la teniamo lowercase per standard tecnico
|
|
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> toMap() {
|
|
return {
|
|
if (id != null) 'id': id,
|
|
'name': name.toLowerCase().trim(), // Salviamo pulito per le query
|
|
'email': email.toLowerCase().trim(),
|
|
'phone': phone.trim(),
|
|
'is_active': isActive,
|
|
'company_id': companyId,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [id, name, email, phone, isActive, companyId];
|
|
}
|