import { configureAxios, request } from "../requests"; import { getUserInfos } from "./users"; export const getPolochons = () => request("PUBLIC_POLOCHON_LIST_FETCH", configureAxios().get("/polochons")); export const getManagedPolochons = () => request( "MANAGED_POLOCHON_LIST_FETCH", configureAxios().get("/users/polochons") ); export const addPolochon = params => request("ADD_POLOCHON", configureAxios().post("/polochons", params), [ () => getPolochons(), () => getManagedPolochons() ]); export const updatePolochon = ({ id, ...params }) => request( "UPDATE_POLOCHON", configureAxios().post(`/polochons/${id}`, params), [() => getPolochons(), () => getManagedPolochons()] ); export const deletePolochon = id => request("DELETE_POLOCHON", configureAxios().delete(`/polochons/${id}`), [ () => getPolochons(), () => getManagedPolochons() ]); export const editPolochonUser = ({ polochonId, id, ...params }) => request( "EDIT_POLOCHON_USER", configureAxios().post(`/polochons/${polochonId}/users/${id}`, params), [() => getPolochons(), () => getManagedPolochons(), () => getUserInfos()] );