mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-05 07:28:01 +00:00
a6e1cbbbce
* feat: upload logo to project data --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me>
37 lines
949 B
TypeScript
37 lines
949 B
TypeScript
import axios, { AxiosResponse } from 'axios';
|
|
import { ProjectData, ProjectLogoResponse } from 'ontime-types';
|
|
|
|
import { apiEntryUrl } from './constants';
|
|
|
|
const projectPath = `${apiEntryUrl}/project`;
|
|
|
|
/**
|
|
* HTTP request to fetch project data
|
|
*/
|
|
export async function getProjectData(): Promise<ProjectData> {
|
|
const res = await axios.get(projectPath);
|
|
return res.data;
|
|
}
|
|
|
|
/**
|
|
* HTTP request to mutate project data
|
|
*/
|
|
export async function postProjectData(data: ProjectData): Promise<AxiosResponse<ProjectData>> {
|
|
return axios.post(projectPath, data);
|
|
}
|
|
|
|
/**
|
|
* HTTP request to upload a project logo
|
|
*/
|
|
export async function uploadProjectLogo(file: File): Promise<AxiosResponse<ProjectLogoResponse>> {
|
|
const formData = new FormData();
|
|
formData.append('image', file);
|
|
const response = await axios.post(`${projectPath}/upload`, formData, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
});
|
|
|
|
return response;
|
|
}
|