checkClockedIn method

dynamic checkClockedIn(
  1. BuildContext context
)

Implementation

checkClockedIn(BuildContext context) async {
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Helper.progressDialog(context, "Please wait..");
  });
  dio
      .get(
    'https://run.mocky.io/v3/5f3d2147-c9d6-407a-8795-ce020f948f93',
    options: Options(
      headers: {
        'Authorization': 'Bearer Authorization',
        'Content-Type': 'application/x-www-form-urlencoded',
        'UserId': "user123"
      },
    ),
  )
      .then((response) {
    Get.back();
    if (response.data != null) {
      ClockinOutModel model = ClockinOutModel();
      if (kDebugMode) {
        print(response.data);
      }
      Map<String, dynamic> creditData = response.data;
      model = ClockinOutModel.fromJson(creditData);
      if (model.clockIn!.status! && !model.clockOut!.status!) {
        Get.to(() => const CollectCreditBal());
      } else {
        Helper.messageDialog(Get.context!, "Cannot collect stock",
            "Should be clocked in and not clocked out");
      }
    }
  }, onError: (error) {
    if (kDebugMode) {
      print(error.toString());
    }
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}