diff --git a/components/ExtraWeapons/index.tsx b/components/ExtraWeapons/index.tsx index d4c25b95..100d4ce6 100644 --- a/components/ExtraWeapons/index.tsx +++ b/components/ExtraWeapons/index.tsx @@ -9,7 +9,6 @@ interface Props { editable: boolean found?: boolean offset: number - onClick: (position: number) => void updateObject: (object: Character | Weapon | Summon, position: number) => void updateUncap: (id: string, position: number, uncap: number) => void } @@ -30,7 +29,6 @@ const ExtraWeapons = (props: Props) => { position={props.offset + i} unitType={1} gridWeapon={props.grid[props.offset + i]} - onClick={() => { props.onClick(props.offset + i)}} updateObject={props.updateObject} updateUncap={props.updateUncap} /> diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 5ba49383..5c7541e0 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -3,9 +3,6 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 're import { useCookies } from 'react-cookie' import { useSnapshot } from 'valtio' -import { useModal as useModal } from '~utils/useModal' -import state from '~utils/state' - import { AxiosResponse } from 'axios' import debounce from 'lodash.debounce' @@ -13,6 +10,8 @@ import WeaponUnit from '~components/WeaponUnit' import ExtraWeapons from '~components/ExtraWeapons' import api from '~utils/api' +import state from '~utils/state' + import './index.scss' // Props @@ -41,16 +40,9 @@ const WeaponGrid = (props: Props) => { const [found, setFound] = useState(false) const [loading, setLoading] = useState(true) - // Set up states for Search - const { open, openModal, closeModal } = useModal() - const [itemPositionForSearch, setItemPositionForSearch] = useState(0) - // Create a temporary state to store previous weapon uncap values const [previousUncapValues, setPreviousUncapValues] = useState<{[key: number]: number}>({}) - // Create a state dictionary to store pure objects for Search - const [searchGrid, setSearchGrid] = useState>({}) - // Fetch data from the server useEffect(() => { const shortcode = (props.slug) ? props.slug : slug @@ -68,16 +60,6 @@ const WeaponGrid = (props: Props) => { setPreviousUncapValues(initialPreviousUncapValues) }, [state.grid.weapons.mainWeapon, state.grid.weapons.allWeapons]) - // Update search grid whenever weapons or the mainhand are updated - useEffect(() => { - let newSearchGrid = Object.values(grid.weapons.allWeapons).map((o) => o.weapon) - - if (state.grid.weapons.mainWeapon) - newSearchGrid.unshift(state.grid.weapons.mainWeapon.weapon) - - setSearchGrid(newSearchGrid) - }, [state.grid.weapons.mainWeapon, state.grid.weapons.allWeapons]) - // Methods: Fetching an object from the server async function fetchGrid(shortcode: string) { return api.endpoints.parties.getOneWithObject({ id: shortcode, object: 'weapons' }) @@ -132,12 +114,6 @@ const WeaponGrid = (props: Props) => { }) } - // Methods: Adding an object from search - function openSearchModal(position: number) { - setItemPositionForSearch(position) - openModal() - } - function receiveWeaponFromSearch(object: Character | Weapon | Summon, position: number) { const weapon = object as Weapon if (position == 1) @@ -251,7 +227,6 @@ const WeaponGrid = (props: Props) => { key="grid_mainhand" position={-1} unitType={0} - onClick={() => { openSearchModal(-1) }} updateObject={receiveWeaponFromSearch} updateUncap={initiateUncapUpdate} /> @@ -266,7 +241,6 @@ const WeaponGrid = (props: Props) => { editable={party.editable} position={i} unitType={1} - onClick={() => { openSearchModal(i) }} updateObject={receiveWeaponFromSearch} updateUncap={initiateUncapUpdate} /> @@ -280,7 +254,6 @@ const WeaponGrid = (props: Props) => { grid={state.grid.weapons.allWeapons} editable={party.editable} offset={numWeapons} - onClick={openSearchModal} updateObject={receiveWeaponFromSearch} updateUncap={initiateUncapUpdate} /> diff --git a/components/WeaponUnit/index.tsx b/components/WeaponUnit/index.tsx index 00008196..c44593a4 100644 --- a/components/WeaponUnit/index.tsx +++ b/components/WeaponUnit/index.tsx @@ -12,7 +12,6 @@ interface Props { unitType: 0 | 1 position: number editable: boolean - onClick: () => void updateObject: (object: Character | Weapon | Summon, position: number) => void updateUncap: (id: string, position: number, uncap: number) => void } @@ -62,7 +61,7 @@ const WeaponUnit = (props: Props) => { fromPosition={props.position} object="weapons" send={props.updateObject}> -
{} }> +
{weapon?.name.en} { (props.editable) ? : '' }