This commit is contained in:
Phuoc Nguyen
2025-10-10 17:51:31 +07:00
parent 10ccd0300d
commit 77440ac957
7 changed files with 300 additions and 11 deletions

View File

@@ -14,14 +14,18 @@ class UserModel extends User {
/// Create UserModel from JSON
factory UserModel.fromJson(Map<String, dynamic> json) {
final createdAt = DateTime.parse(json['createdAt'] as String);
return UserModel(
id: json['id'] as String,
name: json['name'] as String,
email: json['email'] as String,
roles: (json['roles'] as List<dynamic>).cast<String>(),
isActive: json['isActive'] as bool? ?? true,
createdAt: DateTime.parse(json['createdAt'] as String),
updatedAt: DateTime.parse(json['updatedAt'] as String),
createdAt: createdAt,
// updatedAt might not be in response, default to createdAt
updatedAt: json['updatedAt'] != null
? DateTime.parse(json['updatedAt'] as String)
: createdAt,
);
}