Use SearchableObject type
This commit is contained in:
parent
cbbad53e09
commit
6af2ace6b0
4 changed files with 44 additions and 46 deletions
|
|
@ -8,12 +8,14 @@ import debounce from "lodash.debounce"
|
|||
|
||||
import JobSection from "~components/JobSection"
|
||||
import CharacterUnit from "~components/CharacterUnit"
|
||||
import CharacterConflictModal from "~components/CharacterConflictModal"
|
||||
|
||||
import type { SearchableObject } from "~types"
|
||||
|
||||
import api from "~utils/api"
|
||||
import { appState } from "~utils/appState"
|
||||
|
||||
import "./index.scss"
|
||||
import CharacterConflictModal from "~components/CharacterConflictModal"
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
|
|
@ -73,7 +75,7 @@ const CharacterGrid = (props: Props) => {
|
|||
|
||||
// Methods: Adding an object from search
|
||||
function receiveCharacterFromSearch(
|
||||
object: Character | Weapon | Summon,
|
||||
object: SearchableObject,
|
||||
position: number
|
||||
) {
|
||||
const character = object as Character
|
||||
|
|
|
|||
|
|
@ -1,47 +1,46 @@
|
|||
import React from 'react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import SummonUnit from '~components/SummonUnit'
|
||||
import './index.scss'
|
||||
import React from "react"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import SummonUnit from "~components/SummonUnit"
|
||||
import { SearchableObject } from "~types"
|
||||
import "./index.scss"
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
grid: GridArray<GridSummon>
|
||||
editable: boolean
|
||||
exists: boolean
|
||||
found?: boolean
|
||||
offset: number
|
||||
updateObject: (object: Character | Weapon | Summon, position: number) => void
|
||||
updateUncap: (id: string, position: number, uncap: number) => void
|
||||
grid: GridArray<GridSummon>
|
||||
editable: boolean
|
||||
exists: boolean
|
||||
found?: boolean
|
||||
offset: number
|
||||
updateObject: (object: SearchableObject, position: number) => void
|
||||
updateUncap: (id: string, position: number, uncap: number) => void
|
||||
}
|
||||
|
||||
const ExtraSummons = (props: Props) => {
|
||||
const numSummons: number = 2
|
||||
const numSummons: number = 2
|
||||
|
||||
const { t } = useTranslation('common')
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
return (
|
||||
<div id="ExtraSummons">
|
||||
<span>{t('summons.subaura')}</span>
|
||||
<ul id="grid_summons">
|
||||
{
|
||||
Array.from(Array(numSummons)).map((x, i) => {
|
||||
return (
|
||||
<li key={`grid_unit_${i}`} >
|
||||
<SummonUnit
|
||||
editable={props.editable}
|
||||
position={props.offset + i}
|
||||
unitType={1}
|
||||
gridSummon={props.grid[props.offset + i]}
|
||||
updateObject={props.updateObject}
|
||||
updateUncap={props.updateUncap}
|
||||
/>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
<div id="ExtraSummons">
|
||||
<span>{t("summons.subaura")}</span>
|
||||
<ul id="grid_summons">
|
||||
{Array.from(Array(numSummons)).map((x, i) => {
|
||||
return (
|
||||
<li key={`grid_unit_${i}`}>
|
||||
<SummonUnit
|
||||
editable={props.editable}
|
||||
position={props.offset + i}
|
||||
unitType={1}
|
||||
gridSummon={props.grid[props.offset + i]}
|
||||
updateObject={props.updateObject}
|
||||
updateUncap={props.updateUncap}
|
||||
/>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ExtraSummons
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import ExtraSummons from "~components/ExtraSummons"
|
|||
|
||||
import api from "~utils/api"
|
||||
import { appState } from "~utils/appState"
|
||||
import type { SearchableObject } from "~types"
|
||||
|
||||
import "./index.scss"
|
||||
|
||||
|
|
@ -83,10 +84,7 @@ const SummonGrid = (props: Props) => {
|
|||
])
|
||||
|
||||
// Methods: Adding an object from search
|
||||
function receiveSummonFromSearch(
|
||||
object: Character | Weapon | Summon,
|
||||
position: number
|
||||
) {
|
||||
function receiveSummonFromSearch(object: SearchableObject, position: number) {
|
||||
const summon = object as Summon
|
||||
|
||||
if (!party.id) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import ExtraWeapons from "~components/ExtraWeapons"
|
|||
import api from "~utils/api"
|
||||
import { appState } from "~utils/appState"
|
||||
|
||||
import type { SearchableObject } from "~types"
|
||||
|
||||
import "./index.scss"
|
||||
|
||||
// Props
|
||||
|
|
@ -71,10 +73,7 @@ const WeaponGrid = (props: Props) => {
|
|||
}, [appState.grid.weapons.mainWeapon, appState.grid.weapons.allWeapons])
|
||||
|
||||
// Methods: Adding an object from search
|
||||
function receiveWeaponFromSearch(
|
||||
object: Character | Weapon | Summon,
|
||||
position: number
|
||||
) {
|
||||
function receiveWeaponFromSearch(object: SearchableObject, position: number) {
|
||||
const weapon = object as Weapon
|
||||
if (position == 1) appState.party.element = weapon.element
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue