import API from './request'; import { Device } from '@tempi/types/pb'; export const pageApi = { getPages: async (params) => { const { data } = await API.builderBffClient.get('/v1/pages', { params: { ...params, pageSize: params?.pageSize || 18, }, }); return data; }, getPage: async (id, params = { device: null }) => { const newParams = { ...params }; if (newParams.device) { newParams.device = newParams.device === Device.MOBILE ? Device.MOBILE : Device.DESKTOP; } const { data } = await API.builderBffClient.get(`/v1/pages/${id}`, { params: newParams, }); return data; }, updatePage: async (id, body) => { const newBody = { ...body }; if (newBody.device) { newBody.device = newBody.device === Device.MOBILE ? Device.MOBILE : Device.DESKTOP; } return await API.builderBffClient.patch(`/v1/pages/${id}`, newBody); }, deletePage: async (id) => { return await API.builderBffClient.delete(`/v1/pages/${id}`); }, createPage: async (body) => { const { data } = await API.builderBffClient.post(`/v1/pages`, body); return data?.data; }, };