import method

void import()

Implementation

void import() => UFile.showFilePicker(
  action: (List<FileData> i) {
    ULoading.show();
    if (i.length == 1 && i.first.extension!.toLowerCase().contains("xlsx")) {
      UServices.terminal.import(
        p: UTerminalImportParams(file: i.first.bytes!.toBase64()),
        onOk: (UResponse<UTerminalImportResponse> response) {
          ULoading.dismiss();
          UToast.snackBar(message: response.message);
        },
        onError: (UEmptyResponse response) {
          ULoading.dismiss();
          UToast.snackBar(message: response.message);
        },
        onException: (String response) {
          ULoading.dismiss();
          UToast.error(message: response);
        },
      );
    }
  },
);