-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrenderItem.ts
More file actions
48 lines (41 loc) · 1.2 KB
/
renderItem.ts
File metadata and controls
48 lines (41 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { AxiosResponse } from "axios";
import { createAxiosInstance } from "../../axiosConfig";
import { DesignRenderDto, ProjectRenderDto, Render } from "../types";
const api = createAxiosInstance();
type RenderParams = {
isDesign: boolean;
projectDesignId: string;
templateVariantId: string;
parameters?: { [key: string]: any };
};
export const renderItem = async (params: RenderParams): Promise<Render> => {
if (params.isDesign) {
return await renderDesign(params);
} else {
return await renderProject(params);
}
};
const renderDesign = async (params: RenderParams): Promise<Render> => {
const response = await api.post<
Render,
AxiosResponse<Render>,
DesignRenderDto
>("/api/v2/designs", {
designId: params.projectDesignId,
variantId: params.templateVariantId,
parameters: params.parameters,
});
return response.data;
};
const renderProject = async (params: RenderParams): Promise<Render> => {
const response = await api.post<
Render,
AxiosResponse<Render>,
ProjectRenderDto
>("/api/v2/renders", {
projectId: params.projectDesignId,
templateId: params.templateVariantId,
parameters: params.parameters,
});
return response.data;
};