From 6d1b12fd2f1ff3d090f1b305b12706aa354a46f1 Mon Sep 17 00:00:00 2001 From: Net Date: Mon, 26 Aug 2024 18:05:05 +0700 Subject: [PATCH] refactor: add function sendOcr --- src/stores/ocr/index.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/stores/ocr/index.ts diff --git a/src/stores/ocr/index.ts b/src/stores/ocr/index.ts new file mode 100644 index 00000000..96a4ce1d --- /dev/null +++ b/src/stores/ocr/index.ts @@ -0,0 +1,34 @@ +import { ref } from 'vue'; +import { api } from 'src/boot/axios'; +import { defineStore } from 'pinia'; + +import axios from 'axios'; + +const useOcr = defineStore('useOcrStore', () => { + const baseUrl = import.meta.env.VITE_API_BASE_URL_OCR; + + async function sendOcr( + payload: { + file: File; + }, + flow?: { + sessionId?: string; + refTransactionId?: string; + transactionId?: string; + }, + ) { + const res = await axios + .post(`${baseUrl}/`, payload.file, { + headers: { 'Content-Type': payload.file?.type }, + onUploadProgress: (e) => console.log(e), + }) + .catch((e) => console.error(e)); + // ]); + } + + return { + sendOcr, + }; +}); + +export default useOcr;