import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/doctor_reply_service.dart';
import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart';

import '../../locator.dart';
import 'base_view_model.dart';

class DoctorReplayViewModel extends BaseViewModel {
  DoctorReplyService _doctorReplyService = locator<DoctorReplyService>();

  List<ListGtMyPatientsQuestions> get listDoctorWorkingHoursTable => _doctorReplyService.listDoctorWorkingHoursTable;

  Future getDoctorReply() async {
    setState(ViewState.Busy);
    await _doctorReplyService.getDoctorReply();
    if (_doctorReplyService.hasError) {
      error = _doctorReplyService.error;
      setState(ViewState.Error);
    } else
      setState(ViewState.Idle);
  }

  Future replay(String referredDoctorRemarks, ListGtMyPatientsQuestions model) async {
    setState(ViewState.BusyLocal);
    await _doctorReplyService.replay(referredDoctorRemarks, model);
    if (_doctorReplyService.hasError) {
      error = _doctorReplyService.error;
      setState(ViewState.ErrorLocal);
    } else
      setState(ViewState.Idle);
  }
}
