started staff
This commit is contained in:
47
lib/features/staff/models/staff_member_model.dart
Normal file
47
lib/features/staff/models/staff_member_model.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
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.fromJson(Map<String, dynamic> json) {
|
||||
return StaffMemberModel(
|
||||
id: json['id'],
|
||||
// Applichiamo il tuo myFormat per visualizzare i nomi correttamente
|
||||
name: (json['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'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
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];
|
||||
}
|
||||
Reference in New Issue
Block a user