Fix display of weapon keys and Select changes
This commit is contained in:
parent
4fdf5fade4
commit
bfdd019484
2 changed files with 9 additions and 5 deletions
|
|
@ -56,7 +56,6 @@ const WeaponKeySelect = React.forwardRef<HTMLButtonElement, Props>(
|
||||||
|
|
||||||
function fetchWeaponKeys() {
|
function fetchWeaponKeys() {
|
||||||
api.endpoints.weapon_keys.getAll(filterParams).then((response) => {
|
api.endpoints.weapon_keys.getAll(filterParams).then((response) => {
|
||||||
const keys = response.data.map((k: any) => k.weapon_key)
|
|
||||||
const keys = response.data
|
const keys = response.data
|
||||||
organizeWeaponKeys(keys)
|
organizeWeaponKeys(keys)
|
||||||
})
|
})
|
||||||
|
|
@ -125,9 +124,9 @@ const WeaponKeySelect = React.forwardRef<HTMLButtonElement, Props>(
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
key={`weapon-key-${props.slot}`}
|
key={`weapon-key-${props.slot}`}
|
||||||
defaultValue={props.currentValue ? props.currentValue.id : 'no-key'}
|
value={props.currentValue ? props.currentValue.id : 'no-key'}
|
||||||
open={open}
|
open={open}
|
||||||
onChange={handleChange}
|
onValueChange={handleChange}
|
||||||
onClick={openSelect}
|
onClick={openSelect}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
triggerClass="modal"
|
triggerClass="modal"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { AxiosResponse } from 'axios'
|
||||||
import * as Dialog from '@radix-ui/react-dialog'
|
import * as Dialog from '@radix-ui/react-dialog'
|
||||||
|
|
||||||
import AXSelect from '~components/AxSelect'
|
import AXSelect from '~components/AxSelect'
|
||||||
|
import AwakeningSelect from '~components/AwakeningSelect'
|
||||||
import ElementToggle from '~components/ElementToggle'
|
import ElementToggle from '~components/ElementToggle'
|
||||||
import WeaponKeySelect from '~components/WeaponKeySelect'
|
import WeaponKeySelect from '~components/WeaponKeySelect'
|
||||||
import Button from '~components/Button'
|
import Button from '~components/Button'
|
||||||
|
|
@ -16,7 +17,6 @@ import { appState } from '~utils/appState'
|
||||||
|
|
||||||
import CrossIcon from '~public/icons/Cross.svg'
|
import CrossIcon from '~public/icons/Cross.svg'
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
import AwakeningSelect from '~components/AwakeningSelect'
|
|
||||||
|
|
||||||
interface GridWeaponObject {
|
interface GridWeaponObject {
|
||||||
weapon: {
|
weapon: {
|
||||||
|
|
@ -253,11 +253,16 @@ const WeaponModal = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function openChange(open: boolean) {
|
function openChange(open: boolean) {
|
||||||
setFormValid(false)
|
if (props.gridWeapon.object.ax > 0 || props.gridWeapon.object.awakening) {
|
||||||
|
setFormValid(false)
|
||||||
|
} else {
|
||||||
|
setFormValid(true)
|
||||||
|
}
|
||||||
setOpen(open)
|
setOpen(open)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// TODO: Refactor into Dialog component
|
||||||
<Dialog.Root open={open} onOpenChange={openChange}>
|
<Dialog.Root open={open} onOpenChange={openChange}>
|
||||||
<Dialog.Trigger asChild>{props.children}</Dialog.Trigger>
|
<Dialog.Trigger asChild>{props.children}</Dialog.Trigger>
|
||||||
<Dialog.Portal>
|
<Dialog.Portal>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue