import 'package:equatable/equatable.dart';

class UserModel extends Equatable {
  final int id;
  final String? nickname;
  final String? phone;
  final String? avatar;
  final int? type;
  final dynamic canControlDevice;
  final dynamic canViewOperation;
  final dynamic hospitalId;
  final String? hospitalName;

  const UserModel({
    required this.id,
    this.nickname,
    this.phone,
    this.avatar,
    this.type,
    this.canControlDevice,
    this.canViewOperation,
    this.hospitalId,
    this.hospitalName,
  });

  factory UserModel.fromJson(Map<String, dynamic> json) {
    return UserModel(
      id: json['id'] as int? ?? 0,
      nickname: json['nickname'] as String?,
      phone: json['phone'] as String?,
      avatar: json['avatar'] as String?,
      type: json['type'] as int?,
      canControlDevice: json['canControlDevice'],
      canViewOperation: json['canViewOperation'],
      hospitalId: json['hospitalId'],
      hospitalName: json['hospitalName'] as String?,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'nickname': nickname,
      'phone': phone,
      'avatar': avatar,
      'type': type,
      'canControlDevice': canControlDevice,
      'canViewOperation': canViewOperation,
      'hospitalId': hospitalId,
      'hospitalName': hospitalName,
    };
  }

  @override
  List<Object?> get props => [
        id,
        nickname,
        phone,
        avatar,
        type,
        canControlDevice,
        canViewOperation,
        hospitalId,
        hospitalName,
      ];
}
