/// User model for BottleCRM class User { final String id; final String name; final String email; final String? phone; final String role; final String? avatar; final bool isAdmin; final DateTime createdAt; final DateTime updatedAt; const User({ required this.id, required this.name, required this.email, this.phone, required this.role, this.avatar, this.isAdmin = false, required this.createdAt, required this.updatedAt, }); /// Get user initials for avatar fallback String get initials { final parts = name.trim().split(' '); if (parts.length >= 2) { return '${parts[0][0]}${parts[1][0]}'.toUpperCase(); } else if (parts.isNotEmpty && parts[0].isNotEmpty) { return parts[0][0].toUpperCase(); } return '?'; } /// Get first name String get firstName { final parts = name.trim().split(' '); return parts.isNotEmpty ? parts[0] : name; } User copyWith({ String? id, String? name, String? email, String? phone, String? role, String? avatar, bool? isAdmin, DateTime? createdAt, DateTime? updatedAt, }) { return User( id: id ?? this.id, name: name ?? this.name, email: email ?? this.email, phone: phone ?? this.phone, role: role ?? this.role, avatar: avatar ?? this.avatar, isAdmin: isAdmin ?? this.isAdmin, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt, ); } @override bool operator ==(Object other) => identical(this, other) || other is User && runtimeType == other.runtimeType && id == other.id; @override int get hashCode => id.hashCode; }