/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-02-02 10:37:14
 * @LastEditTime : 2023-06-09 10:29:34
 * @Description  : Do not edit
 */
import 'package:flutter/material.dart';
import 'package:task_package/src/impl/dashboard_service_impl.dart';
import 'package:task_package/src/models/dashboard_department.dart';
import 'package:task_package/src/models/dashboard_person.dart';
import 'package:task_package/src/models/dashboard_staff.dart';

class PrivateDashBoardStore with ChangeNotifier {
  final BuildContext context, providerContext;
  late Map<String, dynamic> routingArgs;
  PrivateDashBoardStore(this.context, this.providerContext)
      : routingArgs = ModalRoute.of(context)!.settings.arguments
                as Map<String, dynamic>? ??
            {};

  var _dashboardServiceImpl = DashboardServiceImpl.instance;

  ///------
  DashboardPersonModel? person;
  List<DashboardStaffModel> staffList = [];
  DashboardDepartmentModel? department;

  ///获取个人的
  Future getPerson() async {
    var res = await _dashboardServiceImpl!.getPerson();
    person = res.data;
    notifyListeners();
  }

  ///获取员工的
  Future getStaffList() async {
    var res = await _dashboardServiceImpl!.getStaff();
    staffList = res.data ?? [];
    notifyListeners();
  }

  ///获取部门的
  Future getDepartment() async {
    var res = await _dashboardServiceImpl!.getDepartment();
    department = res.data;
    notifyListeners();
  }

  Future getData() async {
    var futures = [getPerson(), getStaffList(), getDepartment()];
    await Future.wait(futures);
  }
}
