From b284bf1f817dd771169229fb2516d0bd0aba2004 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 02:35:49 -0800 Subject: [PATCH] Small syntax updates --- components/WeaponGrid/index.tsx | 13 ++++++++----- components/WeaponUnit/index.tsx | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 5c7541e0..ed35ac9a 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -47,16 +47,18 @@ const WeaponGrid = (props: Props) => { useEffect(() => { const shortcode = (props.slug) ? props.slug : slug if (shortcode) fetchGrid(shortcode) - else { - state.party.editable = true - } + else state.party.editable = true }, [slug, props.slug]) // Initialize an array of current uncap values for each weapon useEffect(() => { let initialPreviousUncapValues: {[key: number]: number} = {} - if (state.grid.weapons.mainWeapon) initialPreviousUncapValues[-1] = state.grid.weapons.mainWeapon.uncap_level + + if (state.grid.weapons.mainWeapon) + initialPreviousUncapValues[-1] = state.grid.weapons.mainWeapon.uncap_level + Object.values(state.grid.weapons.allWeapons).map(o => initialPreviousUncapValues[o.position] = o.uncap_level) + setPreviousUncapValues(initialPreviousUncapValues) }, [state.grid.weapons.mainWeapon, state.grid.weapons.allWeapons]) @@ -113,7 +115,8 @@ const WeaponGrid = (props: Props) => { } }) } - + + // Methods: Adding an object from search function receiveWeaponFromSearch(object: Character | Weapon | Summon, position: number) { const weapon = object as Weapon if (position == 1) diff --git a/components/WeaponUnit/index.tsx b/components/WeaponUnit/index.tsx index c44593a4..4a1ac816 100644 --- a/components/WeaponUnit/index.tsx +++ b/components/WeaponUnit/index.tsx @@ -1,11 +1,11 @@ import React, { useEffect, useState } from 'react' import classnames from 'classnames' +import SearchModal from '~components/SearchModal' import UncapIndicator from '~components/UncapIndicator' import PlusIcon from '~public/icons/Add.svg' import './index.scss' -import SearchModal from '~components/SearchModal' interface Props { gridWeapon: GridWeapon | undefined