B: Fix file upload api

This commit is contained in:
Ivan 2025-11-10 21:44:44 +03:00
parent b757fc5ec0
commit b2ff026922
4 changed files with 7 additions and 8 deletions

View File

@ -48,10 +48,10 @@ export const rsformsApi = {
endpoint: version ? `/api/versions/${version}/export-file` : `/api/rsforms/${itemID}/export-trs`, endpoint: version ? `/api/versions/${version}/export-file` : `/api/rsforms/${itemID}/export-trs`,
options: { responseType: 'blob' } options: { responseType: 'blob' }
}), }),
upload: (data: IRSFormUploadDTO) => upload: ({ itemID, data }: { itemID: number; data: IRSFormUploadDTO }) =>
axiosPatch<IRSFormUploadDTO, IRSFormDTO>({ axiosPatch<IRSFormUploadDTO, IRSFormDTO>({
schema: schemaRSForm, schema: schemaRSForm,
endpoint: `/api/rsforms/${data.itemID}/load-trs`, endpoint: `/api/rsforms/${itemID}/load-trs`,
request: { request: {
data: data, data: data,
successMessage: infoMsg.uploadSuccess successMessage: infoMsg.uploadSuccess

View File

@ -51,10 +51,8 @@ export type IRSFormDTO = z.infer<typeof schemaRSForm>;
/** Represents data, used for uploading {@link IRSForm} as file. */ /** Represents data, used for uploading {@link IRSForm} as file. */
export interface IRSFormUploadDTO { export interface IRSFormUploadDTO {
itemID: number;
load_metadata: boolean; load_metadata: boolean;
file: File; file: File;
fileName: string;
} }
/** Represents {@link IConstituenta} data, used in creation process. */ /** Represents {@link IConstituenta} data, used in creation process. */

View File

@ -29,6 +29,6 @@ export const useUploadTRS = () => {
onError: () => client.invalidateQueries() onError: () => client.invalidateQueries()
}); });
return { return {
upload: (data: IRSFormUploadDTO) => mutation.mutateAsync(data) upload: (data: { itemID: number; data: IRSFormUploadDTO }) => mutation.mutateAsync(data)
}; };
}; };

View File

@ -24,9 +24,10 @@ export function DlgUploadRSForm() {
if (file) { if (file) {
void upload({ void upload({
itemID: itemID, itemID: itemID,
data: {
load_metadata: loadMetadata, load_metadata: loadMetadata,
file: file, file: file
fileName: file.name }
}); });
} }
}; };