diff --git a/web/app/common/api.js b/web/app/common/api.js index 97b1b9a8..9871abcc 100644 --- a/web/app/common/api.js +++ b/web/app/common/api.js @@ -2,11 +2,13 @@ import { siteId, url } from './settings'; import fetcher from './fetcher' +/* common */ + export const find = ({ url }) => fetcher.get(`/find?url=${url}&sort=-score&format=tree`); export const getComment = ({ id }) => fetcher.get(`/id/${id}?url=${url}`); -export const getUser = () => fetcher.get('/user'); +export const vote = ({ id, url, value }) => fetcher.put(`/vote/${id}?url=${url}&vote=${value}`); export const send = ({ text, pid }) => fetcher.post('/comment', { text, @@ -17,12 +19,19 @@ export const send = ({ text, pid }) => fetcher.post('/comment', { ...(pid ? { pid } : {}), }); -export const vote = ({ id, url, value }) => fetcher.put(`/vote/${id}?url=${url}&vote=${value}`); +export const getUser = () => fetcher.get('/user'); + +/* admin */ +export const pin = ({ id, url }) => fetcher.put(`/admin/pin/${id}?url=${url}&pin=1`); + +export const unpin = ({ id, url }) => fetcher.get(`/admin/pin/${id}?url=${url}&pin=0`); export default { find, getComment, - send, + pin, + unpin, vote, + send, getUser, };