import 'package:equatable/equatable.dart';

abstract class UserState extends Equatable {
  @override
  List<Object?> get props => [];
}

class UserInitial extends UserState {}

class UserLoading extends UserState {}

class UserLoaded extends UserState {
  final UserModel user;
  
  UserLoaded(this.user);
  
  @override
  List<Object?> get props => [user];
}

class UserError extends UserState {
  final String message;
  
  UserError(this.message);
  
  @override
  List<Object?> get props => [message];
}

// Modèle utilisateur simple
class UserModel {
  final String id;
  final String email;
  final String prenom;
  final String? nom;
  
  UserModel({
    required this.id,
    required this.email,
    required this.prenom,
    this.nom,
  });
  
  factory UserModel.fromJson(Map<String, dynamic> json) {
    return UserModel(
      id: json['id'] ?? '',
      email: json['email'] ?? '',
      prenom: json['prenom'] ?? 'Voyageur',
      nom: json['nom'],
    );
  }
  
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'email': email,
      'prenom': prenom,
      'nom': nom,
    };
  }
}
