1- import axios , {
2- type AxiosProgressEvent ,
3- type AxiosRequestConfig ,
4- type AxiosResponse ,
5- } from 'axios' ;
1+ import axios , { type AxiosProgressEvent , type AxiosRequestConfig , type AxiosResponse } from 'axios' ;
62
73import { createApiEndpoint } from '@/api/common/client' ;
84import { type CallFilesResult } from '@/models/v4/callFiles/callFilesResult' ;
@@ -33,10 +29,7 @@ const getCallFilesApi = createApiEndpoint('/CallFiles/GetFilesForCall');
3329const saveCallFileApi = createApiEndpoint ( '/CallFiles/SaveCallFile' ) ;
3430
3531// Function to download a file with progress reporting
36- export const getCallAttachmentFile = async (
37- url : string ,
38- options : DownloadOptions = { }
39- ) : Promise < Blob > => {
32+ export const getCallAttachmentFile = async ( url : string , options : DownloadOptions = { } ) : Promise < Blob > => {
4033 const { onEvent, headers = { } , timeout = 30000 } = options ;
4134
4235 try {
@@ -51,9 +44,7 @@ export const getCallAttachmentFile = async (
5144 timeout,
5245 onDownloadProgress : ( progressEvent : AxiosProgressEvent ) => {
5346 if ( progressEvent . total ) {
54- const percentCompleted = Math . round (
55- ( progressEvent . loaded * 100 ) / progressEvent . total
56- ) ;
47+ const percentCompleted = Math . round ( ( progressEvent . loaded * 100 ) / progressEvent . total ) ;
5748
5849 // Notify progress event
5950 onEvent ?.( {
@@ -79,8 +70,7 @@ export const getCallAttachmentFile = async (
7970 // Notify error event
8071 onEvent ?.( {
8172 type : 'error' ,
82- error :
83- error instanceof Error ? error : new Error ( 'Unknown error occurred' ) ,
73+ error : error instanceof Error ? error : new Error ( 'Unknown error occurred' ) ,
8474 } ) ;
8575
8676 throw error ;
@@ -99,11 +89,7 @@ export const saveBlobAsFile = (blob: Blob, fileName: string): void => {
9989 window . URL . revokeObjectURL ( url ) ;
10090} ;
10191
102- export const getFiles = async (
103- callId : string ,
104- includeData : boolean ,
105- type : number
106- ) => {
92+ export const getFiles = async ( callId : string , includeData : boolean , type : number ) => {
10793 const response = await getCallFilesApi . get < CallFilesResult > ( {
10894 callId : callId ,
10995 includeData : includeData ,
@@ -139,16 +125,7 @@ export const getCallAudio = async (callId: string, includeData: boolean) => {
139125 return response . data ;
140126} ;
141127
142- export const saveCallFile = async (
143- callId : string ,
144- userId : string ,
145- note : string ,
146- name : string ,
147- latitude : number | null ,
148- longitude : number | null ,
149- file : string ,
150- type : number
151- ) => {
128+ export const saveCallFile = async ( callId : string , userId : string , note : string , name : string , latitude : number | null , longitude : number | null , file : string , type : number ) => {
152129 let data = {
153130 CallId : callId ,
154131 UserId : userId ,
@@ -171,26 +148,10 @@ export const saveCallFile = async (
171148 return response . data ;
172149} ;
173150
174- export const saveCallImage = async (
175- callId : string ,
176- userId : string ,
177- note : string ,
178- name : string ,
179- latitude : number | null ,
180- longitude : number | null ,
181- file : string
182- ) => {
151+ export const saveCallImage = async ( callId : string , userId : string , note : string , name : string , latitude : number | null , longitude : number | null , file : string ) => {
183152 return saveCallFile ( callId , userId , note , name , latitude , longitude , file , 2 ) ;
184153} ;
185154
186- export const saveCallFileAttachment = async (
187- callId : string ,
188- userId : string ,
189- note : string ,
190- name : string ,
191- latitude : number | null ,
192- longitude : number | null ,
193- file : string
194- ) => {
155+ export const saveCallFileAttachment = async ( callId : string , userId : string , note : string , name : string , latitude : number | null , longitude : number | null , file : string ) => {
195156 return saveCallFile ( callId , userId , note , name , latitude , longitude , file , 3 ) ;
196157} ;
0 commit comments