Fix saving characters (#427)
Saving characters was buggy because we added a key to the `GridCharacter` response. They added to the backend but didn't show up on the frontend without a refresh. Now we properly unwrap things and newly added characters display instantly again.
This commit is contained in:
parent
156f4222d7
commit
0be7be8612
2 changed files with 10 additions and 3 deletions
|
|
@ -100,13 +100,19 @@ const CharacterGrid = (props: Props) => {
|
||||||
if (!party.id) {
|
if (!party.id) {
|
||||||
props.createParty().then((team) => {
|
props.createParty().then((team) => {
|
||||||
saveCharacter(team.id, character, position)
|
saveCharacter(team.id, character, position)
|
||||||
.then((response) => storeGridCharacter(response.data))
|
.then((response) => {
|
||||||
|
const data = response.data['grid_character']
|
||||||
|
storeGridCharacter(data)
|
||||||
|
})
|
||||||
.catch((error) => console.error(error))
|
.catch((error) => console.error(error))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (props.editable)
|
if (props.editable)
|
||||||
saveCharacter(party.id, character, position)
|
saveCharacter(party.id, character, position)
|
||||||
.then((response) => handleCharacterResponse(response.data))
|
.then((response) => {
|
||||||
|
const data = response.data['grid_character']
|
||||||
|
handleCharacterResponse(data)
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
const axiosError = error as AxiosError
|
const axiosError = error as AxiosError
|
||||||
const response = axiosError.response
|
const response = axiosError.response
|
||||||
|
|
@ -126,6 +132,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
setPosition(data.position)
|
setPosition(data.position)
|
||||||
setModalOpen(true)
|
setModalOpen(true)
|
||||||
} else {
|
} else {
|
||||||
|
console.log(data)
|
||||||
storeGridCharacter(data)
|
storeGridCharacter(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ class Api {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const api: Api = new Api({ url: process.env.NEXT_PUBLIC_SIERO_API_URL || 'https://localhost:3000/api/v1'})
|
const api: Api = new Api({ url: process.env.NEXT_PUBLIC_SIERO_API_URL || 'https://localhost:3000/v1'})
|
||||||
api.createEntity({ name: 'users' })
|
api.createEntity({ name: 'users' })
|
||||||
api.createEntity({ name: 'parties' })
|
api.createEntity({ name: 'parties' })
|
||||||
api.createEntity({ name: 'characters' })
|
api.createEntity({ name: 'characters' })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue