import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hmg_flutter_template/model/base/generic_response_model2.dart';
import 'package:hmg_flutter_template/provider/base_vm.dart';
import 'package:hmg_flutter_template/services/api_repo/dashboard_api_repo.dart';
import 'package:injector/injector.dart';

import '../classes/utils.dart';
import '../main.dart';

/// Mix-in [DiagnosticableTreeMixin] to have access to [debugFillProperties] for the devtool
// ignore: prefer_mixin
class DashboardProviderModel extends BaseViewModel {
  final IDashboardApiRepo _loginApiRepo = Injector.appInstance.get<IDashboardApiRepo>();

  Future<GenericResponseModel2?> getDocProfile() async {
    try {
      Utils.showLoading();

      // Utils.showToast(deviceInfo.length.toString());
      GenericResponseModel2 docProfileModel = await _loginApiRepo.getDoctorProfile();
      appState.doctorProfile = docProfileModel;
      await _loginApiRepo.insertDoctorProfile();
      Utils.hideLoading();
      return docProfileModel;
    } catch (e) {
      Utils.hideLoading();
      Utils.handleException(e, navigatorKey.currentContext!, (msg) {
        Utils.confirmDialog(navigatorKey.currentContext!, msg);
      });
    }
    return null;
  }
}
