All files / app/src/entities/change-log/lib export-change-log.ts

12.5% Statements 2/16
100% Branches 0/0
0% Functions 0/1
12.5% Lines 2/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221x         1x                                
import { httpClient } from '@/shared/lib'
import { forceDownload } from '@/shared/helpers'
import { CHANGE_LOG_EXPORT_TARGET } from './constants'
import { EXCEL_ACCEPT } from '@/shared/config'
 
export const downloadChangeLogXLSX = async (filters?: Record<string, unknown>) => {
  const response = await httpClient<Blob>({
    url: CHANGE_LOG_EXPORT_TARGET,
    responseType: 'blob',
    headers: {
      Accept: EXCEL_ACCEPT,
    },
    params: filters,
  }).then(res => {
    return res.data
  })
 
  forceDownload(window.URL.createObjectURL(response), `${new Date().toTimeString()}.xlsx`).then(url =>
    window.URL.revokeObjectURL(url)
  )
}