diff --git a/components/ExtraSummons/index.tsx b/components/ExtraSummons/index.tsx index 8c71d06c..c3b4868e 100644 --- a/components/ExtraSummons/index.tsx +++ b/components/ExtraSummons/index.tsx @@ -17,16 +17,12 @@ interface Props { exists: boolean found?: boolean offset: number - onSelect: (type: GridType, summon: Summon, position: number) => void + onClick: (position: number) => void } const ExtraSummons = (props: Props) => { const numSummons: number = 2 - function receiveWeapon(summon: Summon, position: number) { - props.onSelect(GridType.Summon, summon, position) - } - return (
Sub Aura Summons @@ -36,8 +32,8 @@ const ExtraSummons = (props: Props) => { return (
  • { props.onClick(props.offset + i) }} + editable={props.editable} position={props.offset + i} unitType={1} summon={props.grid[props.offset + i]} diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 1904947c..97cbf927 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -1,4 +1,7 @@ -import React from 'react' +import React, { useState } from 'react' +import { useModal as useModal } from '~utils/useModal' + +import SearchModal from '~components/SearchModal' import ExtraSummons from '~components/ExtraSummons' import SummonUnit from '~components/SummonUnit' @@ -26,21 +29,40 @@ interface Props { } const SummonGrid = (props: Props) => { + const { open, openModal, closeModal } = useModal() + const [searchPosition, setSearchPosition] = useState(0) + const numSummons: number = 4 + function openSearchModal(position: number) { + setSearchPosition(position) + openModal() + } + function receiveSummon(summon: Summon, position: number) { props.onSelect(GridType.Summon, summon, position) } + function sendData(object: Character | Weapon | Summon, position: number) { + if (isSummon(object)) { + receiveSummon(object, position) + } + } + + function isSummon(object: Character | Weapon | Summon): object is Summon { + // There aren't really any unique fields here + return (object as Summon).granblue_id !== undefined + } + return (
    Main Summon
    { openSearchModal(0) }} editable={props.editable} key="grid_main_summon" - onReceiveData={receiveSummon} position={-1} unitType={0} summon={props.main} @@ -50,9 +72,9 @@ const SummonGrid = (props: Props) => {
    Friend Summon
    { openSearchModal(6) }} editable={props.editable} key="grid_friend_summon" - onReceiveData={receiveSummon} position={6} unitType={2} summon={props.friend} @@ -67,8 +89,8 @@ const SummonGrid = (props: Props) => { return (
  • { openSearchModal(i) }} editable={props.editable} - onReceiveData={receiveSummon} position={i} unitType={1} summon={props.grid[i]} @@ -82,12 +104,23 @@ const SummonGrid = (props: Props) => {
  • + + {open ? ( + + ) : null} ) } diff --git a/components/SummonUnit/index.tsx b/components/SummonUnit/index.tsx index f6933aeb..63597315 100644 --- a/components/SummonUnit/index.tsx +++ b/components/SummonUnit/index.tsx @@ -1,9 +1,7 @@ import React, { useEffect, useState } from 'react' import classnames from 'classnames' -import { useModal as useModal } from '~utils/useModal' -import SearchModal from '~components/SearchModal' import UncapIndicator from '~components/UncapIndicator' import PlusIcon from '~public/icons/plus.svg' @@ -11,7 +9,7 @@ import PlusIcon from '~public/icons/plus.svg' import './index.scss' interface Props { - onReceiveData: (summon: Summon, position: number) => void + onClick: () => void summon: Summon | undefined position: number editable: boolean @@ -20,9 +18,6 @@ interface Props { const SummonUnit = (props: Props) => { const [imageUrl, setImageUrl] = useState('') - const { open, openModal, closeModal } = useModal() - - const openModalIfEditable = (props.editable) ? openModal : () => {} const classes = classnames({ SummonUnit: true, @@ -54,21 +49,10 @@ const SummonUnit = (props: Props) => { setImageUrl(imgSrc) } - function sendData(object: Character | Weapon | Summon, position: number) { - if (isSummon(object)) { - props.onReceiveData(object, position) - } - } - - function isSummon(object: Character | Weapon | Summon): object is Summon { - // There aren't really any unique fields here - return (object as Summon).granblue_id !== undefined - } - return (
    -
    -
    +
    +
    {summon?.name.en} { (props.editable) ? : '' }
    @@ -80,15 +64,6 @@ const SummonUnit = (props: Props) => { />

    {summon?.name.en}

    - {open ? ( - - ) : null}
    ) }