Сделал предустановку значений из процесса

This commit is contained in:
Rinsvent 2023-01-25 23:34:36 +07:00
parent af0c3bcd98
commit 2cd4d87d0a
2 changed files with 3 additions and 4 deletions

View File

@ -13,7 +13,7 @@ export interface ArgumentInterface {
export default function Argument(argument: ArgumentInterface) {
let {argumentList, setArgumentList} = useContext<ContextInterface>(Context)
let [value, setValue] = useState('')
let [value, setValue] = useState(argumentList[argument.name] || '')
useEffect(() => {
let temp = {

View File

@ -11,8 +11,7 @@ interface OptionsInterface {
export default function Options({optionList}: OptionsInterface) {
let {optionList: ol, setOptionList} = useContext<ContextInterface>(Context)
let [selectedOptions, setSelectedOptions] = useState<OptionInterface[]>([]);
let [values, setValues] = useState<OptionInterface[]>([]);
let [selectedValues, setSelectedValues] = useState<string[]>([]);
let [selectedValues, setSelectedValues] = useState<string[]>(Object.keys(ol) || []);
useEffect(() => {
let result: OptionInterface[] = [];
@ -25,7 +24,7 @@ export default function Options({optionList}: OptionsInterface) {
let temp: any = {}
optionList.forEach((value, index, array) => {
let check = selectedValues.find(item => item === value.name)
check && (temp[value.name] = value.acceptValue ? '' : null)
check && (temp[value.name] = value.acceptValue ? '' : true)
})
setOptionList(temp)
}, [selectedValues]);