Save extra state to server
This commit is contained in:
parent
b42bef99fe
commit
cface6a107
2 changed files with 6 additions and 3 deletions
|
|
@ -57,9 +57,11 @@ const Party = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods: Updating the party's extra flag
|
// Methods: Updating the party's extra flag
|
||||||
// Note: This doesn't save to the server yet.
|
|
||||||
function checkboxChanged(event: React.ChangeEvent<HTMLInputElement>) {
|
function checkboxChanged(event: React.ChangeEvent<HTMLInputElement>) {
|
||||||
setHasExtra(event.target.checked)
|
setHasExtra(event.target.checked)
|
||||||
|
api.endpoints.parties.update(id, {
|
||||||
|
'party': { 'is_extra': event.target.checked }
|
||||||
|
}, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods: Navigating with segmented control
|
// Methods: Navigating with segmented control
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,14 @@ type CollectionEndpoint = ({ query }: { query: AxiosRequestConfig }) => Promise<
|
||||||
type IdEndpoint = ({ id }: { id: string }) => Promise<AxiosResponse<any>>
|
type IdEndpoint = ({ id }: { id: string }) => Promise<AxiosResponse<any>>
|
||||||
type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise<AxiosResponse<any>>
|
type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise<AxiosResponse<any>>
|
||||||
type PostEndpoint = (object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
type PostEndpoint = (object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
||||||
|
type PutEndpoint = (id: string, object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
||||||
|
|
||||||
interface EndpointMap {
|
interface EndpointMap {
|
||||||
getAll: CollectionEndpoint
|
getAll: CollectionEndpoint
|
||||||
getOne: IdEndpoint
|
getOne: IdEndpoint
|
||||||
getOneWithObject: IdWithObjectEndpoint
|
getOneWithObject: IdWithObjectEndpoint
|
||||||
create: PostEndpoint
|
create: PostEndpoint
|
||||||
update: PostEndpoint
|
update: PutEndpoint
|
||||||
destroy: IdEndpoint
|
destroy: IdEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +44,7 @@ class Api {
|
||||||
getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}/`),
|
getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}/`),
|
||||||
getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`),
|
getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`),
|
||||||
create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers),
|
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}`)
|
destroy: ({ id }: { id: string }) => axios.delete(`${resourceUrl}/${id}`)
|
||||||
} as EndpointMap
|
} as EndpointMap
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue