import 'package:cpt_auth/modules/select_role/select_role_state.dart';
import 'package:cpt_auth/modules/tenant_doc/tenant_doc_page.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import '../select_estate/select_estate_state.dart';
import '../select_estate/select_estate_view_model.dart';

part 'select_role_view_model.g.dart';

@riverpod
class SelectRoleViewModel extends _$SelectRoleViewModel {
  late final SelectEstateViewModel _selectEstateViewModel;

  @override
  SelectRoleState build() {
    _selectEstateViewModel = ref.watch(selectEstateViewModelProvider.notifier);
    return SelectRoleState();
  }

  //进入下一步
  void submitRole() {
    _selectEstateViewModel.saveRoleType(type: "${state.selectedIndex + 1}");
    TenantDocPage.startInstance();
  }

  //选择角色
  void selectRole(int index) {
    state = state.copyWith(selectedIndex: index);
  }
}
