Fix display of weapon keys and Select changes

This commit is contained in:
Justin Edmund 2022-12-23 23:34:48 -08:00
parent 4fdf5fade4
commit bfdd019484
2 changed files with 9 additions and 5 deletions

View file

@ -56,7 +56,6 @@ const WeaponKeySelect = React.forwardRef<HTMLButtonElement, Props>(
function fetchWeaponKeys() {
api.endpoints.weapon_keys.getAll(filterParams).then((response) => {
const keys = response.data.map((k: any) => k.weapon_key)
const keys = response.data
organizeWeaponKeys(keys)
})
@ -125,9 +124,9 @@ const WeaponKeySelect = React.forwardRef<HTMLButtonElement, Props>(
return (
<Select
key={`weapon-key-${props.slot}`}
defaultValue={props.currentValue ? props.currentValue.id : 'no-key'}
value={props.currentValue ? props.currentValue.id : 'no-key'}
open={open}
onChange={handleChange}
onValueChange={handleChange}
onClick={openSelect}
ref={ref}
triggerClass="modal"

View file

@ -7,6 +7,7 @@ import { AxiosResponse } from 'axios'
import * as Dialog from '@radix-ui/react-dialog'
import AXSelect from '~components/AxSelect'
import AwakeningSelect from '~components/AwakeningSelect'
import ElementToggle from '~components/ElementToggle'
import WeaponKeySelect from '~components/WeaponKeySelect'
import Button from '~components/Button'
@ -16,7 +17,6 @@ import { appState } from '~utils/appState'
import CrossIcon from '~public/icons/Cross.svg'
import './index.scss'
import AwakeningSelect from '~components/AwakeningSelect'
interface GridWeaponObject {
weapon: {
@ -253,11 +253,16 @@ const WeaponModal = (props: Props) => {
}
function openChange(open: boolean) {
setFormValid(false)
if (props.gridWeapon.object.ax > 0 || props.gridWeapon.object.awakening) {
setFormValid(false)
} else {
setFormValid(true)
}
setOpen(open)
}
return (
// TODO: Refactor into Dialog component
<Dialog.Root open={open} onOpenChange={openChange}>
<Dialog.Trigger asChild>{props.children}</Dialog.Trigger>
<Dialog.Portal>