Properly send raid ID to server
This commit is contained in:
parent
49761f9112
commit
11234c6093
1 changed files with 19 additions and 18 deletions
|
|
@ -119,6 +119,23 @@ const Party = (props: Props) => {
|
||||||
.then((response) => storeParty(response.data.party))
|
.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
|
// Methods: Updating the party's details
|
||||||
async function updateDetails(details: DetailsObject) {
|
async function updateDetails(details: DetailsObject) {
|
||||||
if (!props.team) return await createParty(details)
|
if (!props.team) return await createParty(details)
|
||||||
|
|
@ -131,7 +148,6 @@ const Party = (props: Props) => {
|
||||||
const mappings: { [key: string]: string } = {
|
const mappings: { [key: string]: string } = {
|
||||||
name: 'name',
|
name: 'name',
|
||||||
description: 'description',
|
description: 'description',
|
||||||
raid: 'raid_id',
|
|
||||||
chargeAttack: 'charge_attack',
|
chargeAttack: 'charge_attack',
|
||||||
fullAuto: 'full_auto',
|
fullAuto: 'full_auto',
|
||||||
autoGuard: 'auto_guard',
|
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) {
|
if (Object.keys(payload).length >= 1) {
|
||||||
return { party: payload }
|
return { party: payload }
|
||||||
} else {
|
} 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() {
|
function cancelAlert() {
|
||||||
setErrorMessage('')
|
setErrorMessage('')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue