diff --git a/components/Party/index.tsx b/components/Party/index.tsx index be92ea5f..fa20c988 100644 --- a/components/Party/index.tsx +++ b/components/Party/index.tsx @@ -57,9 +57,11 @@ const Party = (props: Props) => { } // Methods: Updating the party's extra flag - // Note: This doesn't save to the server yet. function checkboxChanged(event: React.ChangeEvent) { setHasExtra(event.target.checked) + api.endpoints.parties.update(id, { + 'party': { 'is_extra': event.target.checked } + }, headers) } // Methods: Navigating with segmented control diff --git a/utils/api.tsx b/utils/api.tsx index 89203821..f1cc9c85 100644 --- a/utils/api.tsx +++ b/utils/api.tsx @@ -8,13 +8,14 @@ type CollectionEndpoint = ({ query }: { query: AxiosRequestConfig }) => Promise< type IdEndpoint = ({ id }: { id: string }) => Promise> type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise> type PostEndpoint = (object: {}, headers?: {}) => Promise> +type PutEndpoint = (id: string, object: {}, headers?: {}) => Promise> interface EndpointMap { getAll: CollectionEndpoint getOne: IdEndpoint getOneWithObject: IdWithObjectEndpoint create: PostEndpoint - update: PostEndpoint + update: PutEndpoint destroy: IdEndpoint } @@ -43,7 +44,7 @@ class Api { getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}/`), getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`), create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers), - update: (object: {}, headers?: {}) => axios.put(resourceUrl, object, headers), + update: (id: string, object: {}, headers?: {}) => axios.put(`${resourceUrl}/${id}`, object, headers), destroy: ({ id }: { id: string }) => axios.delete(`${resourceUrl}/${id}`) } as EndpointMap }