refactor: migrate project upload (#796)

* refactor: migrate project upload
This commit is contained in:
Carlos Valente
2024-03-01 22:59:00 +01:00
committed by GitHub
parent 8df419d835
commit 5b01329c37
54 changed files with 698 additions and 1134 deletions
+16 -4
View File
@@ -135,6 +135,21 @@ export const downloadRundown = (fileName?: string) => {
);
};
/**
* @description HTTP request to upload project file
* @return {Promise}
*/
export async function importProjectFile(file: File): Promise<void> {
const formData = new FormData();
formData.append('userFile', file);
const response = await axios.post(`${ontimeURL}/db`, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
return response.data;
}
// TODO: should this be extracted to shared code?
export type ProjectFileImportOptions = {
onlyRundown: boolean;
@@ -341,10 +356,7 @@ export async function createProject(
}
>,
): Promise<MessageResponse> {
// TODO: is this URL correct?
const url = `${ontimeURL}/project`;
const decodedUrl = decodeURIComponent(url);
const res = await axios.post(decodedUrl, project);
const res = await axios.post(`${ontimeURL}/project`, project);
return res.data;
}