import 'package:get/get.dart';
import 'package:fis_jsonrpc/rpc.dart';

class GroupListState {
  final RxList<UserGroupDTO> _groups = RxList(<UserGroupDTO>[]);
  final RxString _selectedGroupCode = RxString('');

  ///群组列表
  List<UserGroupDTO> get groups => _groups;
  set groups(List<UserGroupDTO> v) => _groups.value = v;

  ///选中的群组Code
  String get selectedGroupCode => _selectedGroupCode.value;
  set selectedGroupCode(String v) => _selectedGroupCode.value = v;

  ///当前选择的群组
  UserGroupDTO? get selectedGroup =>
      groups.firstWhereOrNull((element) => element.code == selectedGroupCode);
}
