Implement deleting summons
This commit is contained in:
parent
bd11685295
commit
b912a7ae8f
3 changed files with 23 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ interface Props {
|
||||||
exists: boolean
|
exists: boolean
|
||||||
found?: boolean
|
found?: boolean
|
||||||
offset: number
|
offset: number
|
||||||
|
removeSummon: (id: string) => void
|
||||||
updateObject: (object: SearchableObject, position: number) => void
|
updateObject: (object: SearchableObject, position: number) => void
|
||||||
updateUncap: (id: string, position: number, uncap: number) => void
|
updateUncap: (id: string, position: number, uncap: number) => void
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +32,7 @@ const ExtraSummons = (props: Props) => {
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
position={props.offset + i}
|
position={props.offset + i}
|
||||||
unitType={1}
|
unitType={1}
|
||||||
|
removeSummon={props.removeSummon}
|
||||||
gridSummon={props.grid[props.offset + i]}
|
gridSummon={props.grid[props.offset + i]}
|
||||||
updateObject={props.updateObject}
|
updateObject={props.updateObject}
|
||||||
updateUncap={props.updateUncap}
|
updateUncap={props.updateUncap}
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,23 @@ const SummonGrid = (props: Props) => {
|
||||||
setPreviousUncapValues(newPreviousValues)
|
setPreviousUncapValues(newPreviousValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function removeSummon(id: string) {
|
||||||
|
try {
|
||||||
|
const response = await api.endpoints.grid_summons.destroy({ id: id })
|
||||||
|
const data = response.data
|
||||||
|
|
||||||
|
if (data.position === -1) {
|
||||||
|
appState.grid.summons.mainSummon = undefined
|
||||||
|
} else if (data.position === 6) {
|
||||||
|
appState.grid.summons.friendSummon = undefined
|
||||||
|
} else {
|
||||||
|
appState.grid.summons.allSummons[response.data.position] = undefined
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Render: JSX components
|
// Render: JSX components
|
||||||
const mainSummonElement = (
|
const mainSummonElement = (
|
||||||
<div className="LabeledUnit">
|
<div className="LabeledUnit">
|
||||||
|
|
@ -219,6 +236,7 @@ const SummonGrid = (props: Props) => {
|
||||||
key="grid_main_summon"
|
key="grid_main_summon"
|
||||||
position={-1}
|
position={-1}
|
||||||
unitType={0}
|
unitType={0}
|
||||||
|
removeSummon={removeSummon}
|
||||||
updateObject={receiveSummonFromSearch}
|
updateObject={receiveSummonFromSearch}
|
||||||
updateUncap={initiateUncapUpdate}
|
updateUncap={initiateUncapUpdate}
|
||||||
/>
|
/>
|
||||||
|
|
@ -251,6 +269,7 @@ const SummonGrid = (props: Props) => {
|
||||||
editable={party.editable}
|
editable={party.editable}
|
||||||
position={i}
|
position={i}
|
||||||
unitType={1}
|
unitType={1}
|
||||||
|
removeSummon={removeSummon}
|
||||||
updateObject={receiveSummonFromSearch}
|
updateObject={receiveSummonFromSearch}
|
||||||
updateUncap={initiateUncapUpdate}
|
updateUncap={initiateUncapUpdate}
|
||||||
/>
|
/>
|
||||||
|
|
@ -266,6 +285,7 @@ const SummonGrid = (props: Props) => {
|
||||||
editable={party.editable}
|
editable={party.editable}
|
||||||
exists={false}
|
exists={false}
|
||||||
offset={numSummons}
|
offset={numSummons}
|
||||||
|
removeSummon={removeSummon}
|
||||||
updateObject={receiveSummonFromSearch}
|
updateObject={receiveSummonFromSearch}
|
||||||
updateUncap={initiateUncapUpdate}
|
updateUncap={initiateUncapUpdate}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ api.createEntity({ name: 'users' })
|
||||||
api.createEntity({ name: 'parties' })
|
api.createEntity({ name: 'parties' })
|
||||||
api.createEntity({ name: 'grid_characters' })
|
api.createEntity({ name: 'grid_characters' })
|
||||||
api.createEntity({ name: 'grid_weapons' })
|
api.createEntity({ name: 'grid_weapons' })
|
||||||
|
api.createEntity({ name: 'grid_summons' })
|
||||||
api.createEntity({ name: 'characters' })
|
api.createEntity({ name: 'characters' })
|
||||||
api.createEntity({ name: 'weapons' })
|
api.createEntity({ name: 'weapons' })
|
||||||
api.createEntity({ name: 'summons' })
|
api.createEntity({ name: 'summons' })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue