import { normalizeSeparator } from '@tempi/editor-site'; import API from 'services/request'; interface InterfacePopupQueryParam { categoryIds?: string[]; page?: number; pageSize?: number; q?: string; isActive?: string; searchQuery?: string; } interface UpsertPopup { name: string; thumbnailUrl: string | null; isActive: boolean; pbConfig?: any; categoryIds?: number[]; } export const popupApi = { getAllPopups: async () => { return API.builderBffClient .get('/v1/popups/get-all') .then((res) => res.data); }, getPopups: async (params: InterfacePopupQueryParam) => { const { categoryIds, ...restParams } = params; return API.builderBffClient .get('/v1/popups', { params: { ...restParams, categoryIds: normalizeSeparator(categoryIds), }, }) .then((res) => res.data); }, getPopup: async (id: number) => { return API.builderBffClient.get(`/v1/popups/${id}`).then((res) => res.data); }, updatePopup: async (id: number, params: UpsertPopup) => { return API.builderBffClient .patch(`/v1/popups/${id}`, params) .then((res) => res.data); }, createPopup: async (params: UpsertPopup) => { return API.builderBffClient .post(`/v1/popups`, params) .then((res) => res.data); }, deletePopup: async (id: number) => { return API.builderBffClient .delete(`/v1/popups/${id}`) .then((res) => res.data); }, };