import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/models/doctor/request_doctor_reply.dart';
import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart';
import 'package:flutter/cupertino.dart';

class DoctorReplyProvider with ChangeNotifier {
  List<ListGtMyPatientsQuestions> listDoctorWorkingHoursTable = [];

  bool isLoading = true;
  bool isError = false;
  String error = '';
  RequestDoctorReply _requestDoctorReply = RequestDoctorReply();

  DoctorReplyProvider() {
    getDoctorReply();
  }

  getDoctorReply() async {
    try {
      await BaseAppClient.post(GT_MY_PATIENT_QUESTION,
          body: _requestDoctorReply.toJson(),
          onSuccess: (dynamic response, int statusCode) {
        response['List_GtMyPatientsQuestions'].forEach((v) {
          listDoctorWorkingHoursTable
              .add(ListGtMyPatientsQuestions.fromJson(v));
          isError = false;
          isLoading = false;
        });
      }, onFailure: (String error, int statusCode) {
        isError = true;
        isLoading = false;
        this.error = error;
      });

      notifyListeners();
    } catch (error) {
      throw error;
    }
  }
}
