teleconsultationCancelOrder method

dynamic teleconsultationCancelOrder({
  1. dynamic orderId,
  2. dynamic cancelReason,
  3. dynamic context,
})

Implementation

teleconsultationCancelOrder({orderId, cancelReason, context}) async {
  var decodedResponse;
  final ApiBody = {
    "cancel_reason": cancelReason,
    "is_cancelled": '1',
  };

  http.Response response = await http.post(
      Uri.parse(
          '${WELLNESS_URL}api/teleconsultation/consultations/edit/$orderId'),
      headers: {
        'Authorization': currentUserToken,
      },
      body: ApiBody);
  decodedResponse = json.decode(response.body);
  Get.back();

  if (decodedResponse['success'] == true) {
    showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return MedicinePaymentSuccessPopup(
            fromPage: 'cancel_medicine',
            message: "${decodedResponse['message']}",
            image: "${FolderPath}Cancel_Order_Icon.svg",
            ontap: () {
              Get.back();
            },
          );
        });
  } else {
    Validator().errorMessage(
        context: context, message: "${decodedResponse['message']}");
  }
}