Properly send raid ID to server

This commit is contained in:
Justin Edmund 2023-06-18 01:18:04 -07:00
parent 49761f9112
commit 11234c6093

View file

@ -119,6 +119,23 @@ const Party = (props: Props) => {
.then((response) => storeParty(response.data.party))
}
async function updateParty(details: DetailsObject) {
const payload = formatDetailsObject(details)
if (props.team && props.team.id) {
return await api.endpoints.parties
.update(props.team.id, payload)
.then((response) => storeParty(response.data.party))
.catch((error) => {
const data = error.response.data
if (data.errors && Object.keys(data.errors).includes('guidebooks')) {
const message = t('errors.validation.guidebooks')
setErrorMessage(message)
}
})
}
}
// Methods: Updating the party's details
async function updateDetails(details: DetailsObject) {
if (!props.team) return await createParty(details)
@ -131,7 +148,6 @@ const Party = (props: Props) => {
const mappings: { [key: string]: string } = {
name: 'name',
description: 'description',
raid: 'raid_id',
chargeAttack: 'charge_attack',
fullAuto: 'full_auto',
autoGuard: 'auto_guard',
@ -153,6 +169,8 @@ const Party = (props: Props) => {
}
})
if (details.raid) payload.raid_id = details.raid.id
if (Object.keys(payload).length >= 1) {
return { party: payload }
} else {
@ -160,23 +178,6 @@ const Party = (props: Props) => {
}
}
async function updateParty(details: DetailsObject) {
const payload = formatDetailsObject(details)
if (props.team && props.team.id) {
return await api.endpoints.parties
.update(props.team.id, payload)
.then((response) => storeParty(response.data.party))
.catch((error) => {
const data = error.response.data
if (data.errors && Object.keys(data.errors).includes('guidebooks')) {
const message = t('errors.validation.guidebooks')
setErrorMessage(message)
}
})
}
}
function cancelAlert() {
setErrorMessage('')
}