23 lines
513 B
TypeScript
23 lines
513 B
TypeScript
import { api } from '@/lib/api';
|
|||
|
|
|
||
|
|
export type TreasuryPendingPhoto = {
|
||
|
|
localId: string;
|
||
|
|
name: string;
|
||
|
|
dataUrl: string;
|
||
|
|
file: File;
|
||
|
|
};
|
||
|
|
|
||
|
|
export async function uploadTreasuryDocumentPhotos(
|
||
|
|
documentId: string,
|
||
|
|
photos: TreasuryPendingPhoto[],
|
||
|
|
): Promise<number> {
|
||
|
|
let attached = 0;
|
||
|
|
for (const photo of photos) {
|
||
|
|
const body = new FormData();
|
||
|
|
body.append('file', photo.file);
|
||
|
|
await api.post(`/treasury/documents/${documentId}/attachments`, body);
|
||
|
|
attached += 1;
|
||
|
|
}
|
||
|
|
return attached;
|
||
|
|
}
|