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