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<{ document: string; fields: { name: string; value: string }[]; result: string; }>(`${baseUrl}/`, payload.file, { headers: { 'Content-Type': payload.file?.type }, onUploadProgress: (e) => console.log(e), }) .catch((e) => console.error(e)); if (!res || res.status >= 400) return false; return res.data; } return { sendOcr, }; }); export default useOcr;