pennellato git da rosso ad arancio e verde
This commit is contained in:
@@ -18,44 +18,61 @@ enum SystemRole {
|
||||
class StaffMemberModel extends Equatable {
|
||||
final String? id;
|
||||
final String companyId;
|
||||
final String storeId;
|
||||
final String userId;
|
||||
final String name;
|
||||
final String surname;
|
||||
final String?
|
||||
jobTitle; // Testo libero! Il cliente ci scrive quello che vuole.
|
||||
final SystemRole systemRole; // ENUM! Il sistema non si frega.
|
||||
final String? email;
|
||||
final String? phoneNumber;
|
||||
final String? jobTitle;
|
||||
final SystemRole systemRole;
|
||||
final bool isActive;
|
||||
|
||||
const StaffMemberModel({
|
||||
this.id,
|
||||
required this.companyId,
|
||||
required this.storeId,
|
||||
required this.userId,
|
||||
required this.name,
|
||||
required this.surname,
|
||||
this.email,
|
||||
this.phoneNumber,
|
||||
this.jobTitle,
|
||||
this.systemRole = SystemRole.user, // Sicurezza di default
|
||||
this.systemRole = SystemRole.user,
|
||||
this.isActive = true,
|
||||
});
|
||||
|
||||
StaffMemberModel copyWith({
|
||||
String? id,
|
||||
String? companyId,
|
||||
String? storeId,
|
||||
String? userId,
|
||||
String? name,
|
||||
String? surname,
|
||||
String? email,
|
||||
String? phoneNumber,
|
||||
String? jobTitle,
|
||||
SystemRole? systemRole,
|
||||
bool? isActive,
|
||||
}) {
|
||||
return StaffMemberModel(
|
||||
id: id ?? this.id,
|
||||
companyId: companyId ?? this.companyId,
|
||||
storeId: storeId ?? this.storeId,
|
||||
userId: userId ?? this.userId,
|
||||
name: name ?? this.name,
|
||||
surname: surname ?? this.surname,
|
||||
email: email ?? this.email,
|
||||
phoneNumber: phoneNumber ?? this.phoneNumber,
|
||||
jobTitle: jobTitle ?? this.jobTitle,
|
||||
systemRole: systemRole ?? this.systemRole,
|
||||
isActive: isActive ?? this.isActive,
|
||||
);
|
||||
}
|
||||
|
||||
factory StaffMemberModel.empty() {
|
||||
return const StaffMemberModel(
|
||||
companyId: '',
|
||||
userId: '',
|
||||
name: '',
|
||||
email: '',
|
||||
phoneNumber: '',
|
||||
jobTitle: '',
|
||||
systemRole: SystemRole.user,
|
||||
isActive: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,14 +80,13 @@ class StaffMemberModel extends Equatable {
|
||||
return StaffMemberModel(
|
||||
id: map['id'] as String?,
|
||||
companyId: map['company_id'] ?? '',
|
||||
storeId: map['store_id'] ?? '',
|
||||
userId: map['user_id'] ?? '',
|
||||
name: map['name'] ?? '',
|
||||
surname: map['surname'] ?? '',
|
||||
jobTitle: map['job_title'] as String?, // Semplice stringa
|
||||
systemRole: SystemRole.fromString(
|
||||
map['system_role'],
|
||||
), // Lettura tipizzata
|
||||
email: map['email'] as String?,
|
||||
phoneNumber: map['phone_number'] as String?,
|
||||
jobTitle: map['job_title'] as String?,
|
||||
systemRole: SystemRole.fromString(map['system_role']),
|
||||
isActive: map['is_active'] ?? true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,12 +94,13 @@ class StaffMemberModel extends Equatable {
|
||||
return {
|
||||
if (id != null) 'id': id,
|
||||
'company_id': companyId,
|
||||
'store_id': storeId,
|
||||
'user_id': userId,
|
||||
'name': name,
|
||||
'surname': surname,
|
||||
if (email != null) 'email': email,
|
||||
if (phoneNumber != null) 'phone_number': phoneNumber,
|
||||
if (jobTitle != null) 'job_title': jobTitle,
|
||||
'system_role': systemRole.name, // Trasforma SystemRole.admin in 'admin'
|
||||
'is_active': isActive,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,11 +108,12 @@ class StaffMemberModel extends Equatable {
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
companyId,
|
||||
storeId,
|
||||
userId,
|
||||
name,
|
||||
surname,
|
||||
email,
|
||||
phoneNumber,
|
||||
jobTitle,
|
||||
systemRole,
|
||||
isActive,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user