disable radio and dropdown for the component if it is primed to add

This commit is contained in:
csawatzky 2025-07-02 16:56:05 -06:00
parent 5bebde4bfb
commit 54a826bc2d

View file

@ -21,7 +21,7 @@ export default function ScannedI2C(props: Props){
const [subtypeOptions, setSubtypeOptions] = useState<Array<Subtype>>([])
const [selectedPrimaryType, setSelectedPrimaryType] = useState<quack.ComponentType>(quack.ComponentType.COMPONENT_TYPE_INVALID)
const [selectedPrimarySubtype, setSelectedPrimarySubtype] = useState(0)
const [added,setAdded] = useState(false)
const [added, setAdded] = useState(false)
const [addressInUse, setAddressInUse] = useState(false)
useEffect(()=>{
@ -80,7 +80,7 @@ export default function ScannedI2C(props: Props){
const componentSelected = (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => {
let toAdd: Component[] = []
setAdded(true)
setAdded(checked)
//build a component with given information and defaults for the rest
let primaryComponent = Component.create()
primaryComponent.settings.type = selectedPrimaryType
@ -120,6 +120,7 @@ export default function ScannedI2C(props: Props){
{types.map((type, i) => {
return (
<FormControlLabel
disabled={added}
key={i}
value={type}
control={<Radio />}
@ -132,6 +133,7 @@ export default function ScannedI2C(props: Props){
<Grid2 size={8}>
{subtypeOptions.length > 0 &&
<TextField
disabled={added}
value={selectedPrimarySubtype}
fullWidth
onChange={(event)=>{
@ -152,7 +154,7 @@ export default function ScannedI2C(props: Props){
<Checkbox
value={added}
onChange={componentSelected}
//disabled={addressInUse}
disabled={addressInUse}
/>
}
/>