Track imports in DB, show history in Data section, allow deleting transactions of a specific import instead of clearing all.
27 lines
631 B
TypeScript
27 lines
631 B
TypeScript
import type {
|
|
ImportStatementResponse,
|
|
Import,
|
|
} from '@family-budget/shared';
|
|
import { api } from './client';
|
|
|
|
export async function importStatement(
|
|
file: File,
|
|
): Promise<ImportStatementResponse> {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
return api.postFormData<ImportStatementResponse>(
|
|
'/api/import/statement',
|
|
formData,
|
|
);
|
|
}
|
|
|
|
export async function getImports(): Promise<Import[]> {
|
|
return api.get<Import[]>('/api/imports');
|
|
}
|
|
|
|
export async function deleteImport(
|
|
id: number,
|
|
): Promise<{ deleted: number }> {
|
|
return api.delete<{ deleted: number }>(`/api/imports/${id}`);
|
|
}
|