callEngineImpl method

Future<void> callEngineImpl({
  1. required String localFilePath,
  2. required String serverFilePath,
  3. double? timeAppUpload,
})

Implementation

Future<void> callEngineImpl({
  required String localFilePath,
  required String serverFilePath,
  double? timeAppUpload,
}) async {
  var callEngineRes = await callEngineUsecase(
    claimId: argument!.claimId,
    imageName: basename(localFilePath),
    filePath: serverFilePath,
    isCapDon: true,
    position: positionIds[0],
    direction: argument!.carPartDirectionEnum.excelId,
    vehiclePartExcelId: '',
    timeAppUpload: timeAppUpload,
    utcTimeCreated: createdDateTime,
    uploadLocation: currentLocation,
    locationName: imageLocation,
    isTruck: argument?.carModelEnum == CarModelEnum.truck,
  );

  callEngineRes.fold(
    (l) {
      isLoading(false);

      /// Code from engine
      if (l.errorCodeFromEngine != null) {
        status(
          BaseStatus(
            message: '${l.code.toString()}: ${l.details.toString()}'
                .toString(),
            state: AppState.customError,
          ),
        );
        showErrorDialog(true);
        //   status(
        //     BaseStatus(
        //       message: l.message.toString(),
        //       state: AppState.customError,
        //     ),
        //   );
        //   showRetake(false);
        //   showErrorDialog(true);
        // } else {
        //   status(
        //     BaseStatus(
        //       message: l.message.toString(),
        //       state: AppState.customError,
        //     ),
        //   );
        //   showErrorDialog(true);
        //   showRetake(true);
      } else {
        status(
          BaseStatus(
            message: l.message.toString(),
            state: AppState.customError,
          ),
        );
        showErrorDialog(true);
      }
    },
    (r) {
      isLoading(false);
      if (r.errorCodeFromEngine == null || r.errorCodeFromEngine == 0) {
        updateDirection(r);
        status(BaseStatus(message: null, state: AppState.pop));
      } else {
        cacheDamageResponse = r;

        /// confident level thấp
        if (warningCodeFromEngine.contains(r.errorCodeFromEngine)) {
          status(BaseStatus(message: r.message, state: AppState.warning));
          showRetake(false);
          isConfidentLevelWarning(true);
        } else {
          status(BaseStatus(message: r.message, state: AppState.customError));
          showRetake(false);
          showErrorDialog(true);
        }
      }
    },
  );
}