class AppUser {
  const AppUser({
    required this.id,
    required this.name,
    required this.email,
  });

  final int id;
  final String name;
  final String email;

  factory AppUser.fromJson(Map<String, dynamic> json) {
    final name = (json['name'] ?? json['nama'] ?? '').toString().trim();

    return AppUser(
      id: (json['id'] as num?)?.toInt() ?? 0,
      name: name.isEmpty ? 'Wisatawan' : name,
      email: (json['email'] ?? '').toString().trim(),
    );
  }

  AppUser copyWith({
    int? id,
    String? name,
    String? email,
  }) {
    return AppUser(
      id: id ?? this.id,
      name: name ?? this.name,
      email: email ?? this.email,
    );
  }
}
