canape/frontend/js/actions/polochon.js
Grégoire Delattre bcadc48d5a Launch prettier with the --fix option
They've changed their default settings, this changes a lot of stuff in
our code base.
2020-04-01 17:55:34 +02:00

39 lines
1.1 KiB
JavaScript

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()]
);