diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx
index cb19fcb9..dc7b043f 100644
--- a/components/CharacterGrid/index.tsx
+++ b/components/CharacterGrid/index.tsx
@@ -1,5 +1,8 @@
import React, { useState } from 'react'
+import { useModal as useModal } from '~utils/useModal'
+
import CharacterUnit from '~components/CharacterUnit'
+import SearchModal from '~components/SearchModal'
import './index.scss'
@@ -19,12 +22,31 @@ interface Props {
}
const CharacterGrid = (props: Props) => {
+ const { open, openModal, closeModal } = useModal()
+ const [searchPosition, setSearchPosition] = useState(0)
+
const numCharacters: number = 5
+ function isCharacter(object: Character | Weapon | Summon): object is Character {
+ // There aren't really any unique fields here
+ return (object as Character).gender !== undefined
+ }
+
+ function openSearchModal(position: number) {
+ setSearchPosition(position)
+ openModal()
+ }
+
function receiveCharacter(character: Character, position: number) {
props.onSelect(GridType.Character, character, position)
}
+ function sendData(object: Character | Weapon | Summon, position: number) {
+ if (isCharacter(object)) {
+ receiveCharacter(object, position)
+ }
+ }
+
return (
@@ -33,8 +55,8 @@ const CharacterGrid = (props: Props) => {
return (
-
{ openSearchModal(i) }}
editable={props.editable}
- onReceiveData={receiveCharacter}
position={i}
character={props.grid[i]}
/>
@@ -42,6 +64,16 @@ const CharacterGrid = (props: Props) => {
)
})
}
+ {open ? (
+
+ ) : null}
)
diff --git a/components/CharacterUnit/index.tsx b/components/CharacterUnit/index.tsx
index 72149e2c..27b36ace 100644
--- a/components/CharacterUnit/index.tsx
+++ b/components/CharacterUnit/index.tsx
@@ -1,8 +1,6 @@
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'
@@ -10,7 +8,7 @@ import PlusIcon from '~public/icons/plus.svg'
import './index.scss'
interface Props {
- onReceiveData: (character: Character, position: number) => void
+ onClick: () => void
character: Character | undefined
position: number
editable: boolean
@@ -18,9 +16,6 @@ interface Props {
const CharacterUnit = (props: Props) => {
const [imageUrl, setImageUrl] = useState('')
- const { open, openModal, closeModal } = useModal()
-
- const openModalIfEditable = (props.editable) ? openModal : () => {}
const classes = classnames({
CharacterUnit: true,
@@ -40,27 +35,16 @@ const CharacterUnit = (props: Props) => {
if (props.character) {
const character = props.character!
- imgSrc = `/images/chara-main/${character.granblue_id}.jpg`
+ imgSrc = `/images/chara-main/${character.granblue_id}_01.jpg`
}
setImageUrl(imgSrc)
}
- function sendData(object: Character | Weapon | Summon, position: number) {
- if (isCharacter(object)) {
- props.onReceiveData(object, position)
- }
- }
-
- function isCharacter(object: Character | Weapon | Summon): object is Character {
- // There aren't really any unique fields here
- return (object as Character).gender !== undefined
- }
-
return (
-
-
+
+

{ (props.editable) ?
: '' }
@@ -71,15 +55,6 @@ const CharacterUnit = (props: Props) => {
/>
{character?.name.en}
- {open ? (
-
- ) : null}
)
}
diff --git a/components/SearchModal/index.tsx b/components/SearchModal/index.tsx
index 3deb3b77..1e351c5e 100644
--- a/components/SearchModal/index.tsx
+++ b/components/SearchModal/index.tsx
@@ -15,6 +15,7 @@ import PlusIcon from '~public/icons/plus.svg'
interface Props {
close: () => void
send: (object: Character | Weapon | Summon, position: number) => any
+ grid: GridArray
placeholderText: string
fromPosition: number
object: 'weapons' | 'characters' | 'summons'