{"version":3,"file":"xKS8mD2Z.js","sources":["../../../../services/report.ts"],"sourcesContent":["import { useAPI, useFetchAPI } from '@/composables';\nimport type { IQueryParams, ReportAPI } from '@/types';\nimport { params2Query } from '@/utils';\n\nconst buildUrlWithToken = (baseUrl: string, token: string) => {\n return token !== '' ? `${baseUrl}/magic/link?token=${token}` : baseUrl;\n};\n\nexport const getReports = (tab: string, query: IQueryParams) => {\n return useAPI(\n `/reports?filter[tab]=${tab}&${params2Query(query)}`\n );\n};\n\nexport const getReportPreview = async (id: string, token: string) => {\n const baseUrl = `/reports/${id}`;\n const url = buildUrlWithToken(baseUrl, token);\n try {\n const response = await useAPI(url);\n return response;\n } catch (error: any) {\n console.log('Error caught in getReportPreview:', error);\n\n const errorCode = error.statusCode || null;\n\n if (token !== '' && errorCode === 404) {\n if (process.client) {\n window.location.href = '/vdp/login';\n // Prevent further execution\n return new Promise(() => {});\n }\n }\n\n throw error;\n }\n};\n\nexport const getReportDetails = () => {\n return useAPI('/reports/details');\n};\n\nexport const saveReport = (payload: FormData) => {\n return useFetchAPI('/reports', {\n method: 'POST',\n body: payload\n });\n};\n\nexport const saveLinkToFix = (id: string, link: string, token: string) => {\n const baseUrl = `/reports/${id}/link`;\n const url = buildUrlWithToken(baseUrl, token);\n return useFetchAPI(url, {\n method: 'PUT',\n body: { link }\n });\n};\n\nexport const uploadFixedCode = (\n id: string,\n payload: FormData,\n token: string\n) => {\n const baseUrl = `/reports/${id}/upload`;\n const url = buildUrlWithToken(baseUrl, token);\n return useFetchAPI(url, {\n method: 'POST',\n body: payload\n });\n};\n\nexport const getReportChat = (uuid: string, token: string) => {\n const baseUrl = `/reports/${uuid}/messages`;\n const url = buildUrlWithToken(baseUrl, token);\n return useAPI(url);\n};\n\nexport const saveChatMessage = (\n uuid: string,\n payload: FormData,\n token: string\n) => {\n const baseUrl = `/reports/${uuid}/messages`;\n const url = buildUrlWithToken(baseUrl, token);\n return useFetchAPI(url, {\n method: 'POST',\n body: payload\n });\n};\n\nexport const getChatMessageRead = (uuid: string, token: string) => {\n const baseUrl = `/reports/${uuid}/message`;\n const url =\n token !== ''\n ? `${baseUrl}/magic/link/read?token=${token}`\n : `${baseUrl}/read`;\n return useFetchAPI(url, {\n method: 'POST'\n });\n};\n"],"names":["buildUrlWithToken","baseUrl","token","getReports","tab","query","useAPI","params2Query","getReportPreview","id","url","error","errorCode","getReportDetails","saveReport","payload","useFetchAPI","saveLinkToFix","link","uploadFixedCode","getReportChat","uuid","saveChatMessage","getChatMessageRead"],"mappings":"2cAIA,MAAMA,EAAoB,CAACC,EAAiBC,IACnCA,IAAU,GAAK,GAAGD,CAAO,qBAAqBC,CAAK,GAAKD,EAGpDE,EAAa,CAACC,EAAaC,IAC/BC,EACL,wBAAwBF,CAAG,IAAIG,EAAaF,CAAK,CAAC,EACpD,EAGWG,EAAmB,MAAOC,EAAYP,IAAkB,CAC7D,MAAAD,EAAU,YAAYQ,CAAE,GACxBC,EAAMV,EAAkBC,EAASC,CAAK,EACxC,GAAA,CAEK,OADU,MAAMI,EAAOI,CAAG,QAE1BC,EAAY,CACX,QAAA,IAAI,oCAAqCA,CAAK,EAEhD,MAAAC,EAAYD,EAAM,YAAc,KAElC,GAAAT,IAAU,IAAMU,IAAc,IAE9B,cAAO,SAAS,KAAO,aAEhB,IAAI,QAAQ,IAAM,CAAA,CAAE,EAIzB,MAAAD,CAAA,CAEV,EAEaE,EAAmB,IACvBP,EAAO,kBAAkB,EAGrBQ,EAAcC,GAClBC,EAAY,WAAY,CAC7B,OAAQ,OACR,KAAMD,CAAA,CACP,EAGUE,EAAgB,CAACR,EAAYS,EAAchB,IAAkB,CAClE,MAAAD,EAAU,YAAYQ,CAAE,QACxBC,EAAMV,EAAkBC,EAASC,CAAK,EAC5C,OAAOc,EAAYN,EAAK,CACtB,OAAQ,MACR,KAAM,CAAE,KAAAQ,CAAK,CAAA,CACd,CACH,EAEaC,EAAkB,CAC7BV,EACAM,EACAb,IACG,CACG,MAAAD,EAAU,YAAYQ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