17 lines
406 B
TypeScript
17 lines
406 B
TypeScript
|
|
import type { ImportResult } from '~/types'
|
||
|
|
|
||
|
|
export const useImport = () => {
|
||
|
|
const importClients = async (file: File): Promise<ImportResult> => {
|
||
|
|
const form = new FormData()
|
||
|
|
form.append('file', file)
|
||
|
|
|
||
|
|
const response = await useApiFetch<{ data: ImportResult }>('/api/clients/import', {
|
||
|
|
method: 'POST',
|
||
|
|
body: form,
|
||
|
|
})
|
||
|
|
return response.data
|
||
|
|
}
|
||
|
|
|
||
|
|
return { importClients }
|
||
|
|
}
|