Initial commit from ZIP
This commit is contained in:
commit
378d4692a9
454 files changed
+40367
No files matched your search
Executable
+57
@@ -0,0 +1,57 @@
|
||||
import API from './axiosConfig';
|
||||
import { DesignStageResponse, DesignStageFileRequest, DesignStageFileResponse } from 'interfaces/API/draft';
|
||||
import objectToFormDataConverter from 'helpers/objectToFormDataConverter';
|
||||
import { AxiosResponse } from 'axios';
|
||||
|
||||
const getDraftById = async (draftId: number): Promise<DesignStageResponse | null> => {
|
||||
try {
|
||||
const response = await API.get<DesignStageResponse>(`/drafts/${draftId}/`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const addDraftFile = async (draftId: number, data: DesignStageFileRequest): Promise<DesignStageFileResponse | null> => {
|
||||
try {
|
||||
const formData = objectToFormDataConverter(data);
|
||||
const response = await API.post<DesignStageFileResponse>(`/drafts/${draftId}/files/`, formData);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const acceptDraft = async (draftId: number): Promise<DesignStageResponse | null> => {
|
||||
try {
|
||||
const response = await API.patch<DesignStageResponse>(`/drafts/${draftId}/`, { accept: true });
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const openDraft = async (draftId: number) => {
|
||||
try {
|
||||
const response = await API.get<AxiosResponse>(`/draft-files/${draftId}/open-file/`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
openDraft,
|
||||
getDraftById,
|
||||
addDraftFile,
|
||||
acceptDraft,
|
||||
};
|
||||
// export const fetchDrafts = async (productId: number): Promise<DraftResponse[] | []> => {
|
||||
// try {
|
||||
// const response = await API.get<DraftResponse[]>('');
|
||||
// return response.data;
|
||||
// } catch (err) {
|
||||
// console.error(err);
|
||||
// return [];
|
||||
// }
|
||||
// };
|
||||
Reference in new issue
Block a user