From 7915ec2385e6e5f6fba9b6d5bfee346227c75044 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 27 Feb 2022 22:30:12 -0800 Subject: [PATCH] Add endpoints for favoriting --- utils/api.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/utils/api.tsx b/utils/api.tsx index 5af1e299..ee947ee2 100644 --- a/utils/api.tsx +++ b/utils/api.tsx @@ -71,6 +71,31 @@ class Api { }) } + savedTeams(params: {}) { + const resourceUrl = `${this.url}/parties/favorites` + return axios.get(resourceUrl, params) + } + + saveTeam({ id, params }: { id: string, params?: {} }) { + const body = { favorite: { party_id: id } } + const resourceUrl = `${this.url}/favorites` + return axios.post(resourceUrl, body, { headers: params }) + .then((response) => { + if (response.status == 201) + appState.party.favorited = true + }) + } + + unsaveTeam({ id, params }: { id: string, params?: {} }) { + const body = { favorite: { party_id: id } } + const resourceUrl = `${this.url}/favorites` + return axios.delete(resourceUrl, { data: body, headers: params }) + .then((response) => { + if (response.status == 200) + appState.party.favorited = false + }) + } + updateUncap(resource: 'character'|'weapon'|'summon', id: string, value: number) { const pluralized = resource + 's' const resourceUrl = `${this.url}/${pluralized}/update_uncap` @@ -90,5 +115,6 @@ api.createEntity( { name: 'characters' }) api.createEntity( { name: 'weapons' }) api.createEntity( { name: 'summons' }) api.createEntity( { name: 'raids' }) +api.createEntity( { name: 'favorites' }) export default api \ No newline at end of file