import 'package:fis_jsonrpc/services/user.m.dart';
import 'package:get/get.dart';
import 'package:vitalapp/architecture/defines.dart';

class PersonalCenterState {
  final Rx<UserDTO> _dto = Rx<UserDTO>(
    UserDTO(),
  );

  final Rx<String> _oldPassword = ''.obs;
  final Rx<String> _newPassword = Rx('');
  final Rx<String> _confirmPassword = Rx('');
  final Rx<String> _name = Rx('');
  final Rx<String> _phone = Rx('');
  final RxnString _signaturUrl = RxnString(null);
  final RxnString _headImageToken = RxnString(null);
  UserDTO get dto => _dto.value;

  String? get headImageToken => _headImageToken.value;
  set headImageToken(String? value) => _headImageToken.value = value;

  String get name => _name.value;
  set name(String value) => _name.value = value;
  String get phone => _phone.value;
  set phone(String value) => _phone.value = value;

  /// 原始密码
  String get oldPassword => _oldPassword.value;
  set oldPassword(String value) => _oldPassword.updateValue(value);

  /// 新密码
  String get newPassword => _newPassword.value;
  set newPassword(String value) => _newPassword.value = value;

  /// 确认密码
  String get confirmPassword => _confirmPassword.value;
  set confirmPassword(String value) => _confirmPassword.value = value;

  ///医院名称
  String get organizationName => _dto.value.organizationName ?? '';

  ///团队名称
  String get teamName => _dto.value.teamName ?? '';

  ///角色名称
  String get roleName => _dto.value.roleName ?? '';

  void updateDto(UserDTO dto) {
    _dto.value = dto;
    _name.value = dto.realName ?? '';
    _phone.value = dto.phone ?? '';
    _headImageToken.value = dto.headImageToken;
  }

  /// 签名Base64
  String? get signaturUrl => _signaturUrl.value;
  set signaturUrl(String? value) => _signaturUrl.updateValue(value);
}
