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

jwt
Rinsvent 2 years ago
parent af0c3bcd98
commit 2cd4d87d0a
  1. 2
      components/elements/commands/elements/argument/index.tsx
  2. 5
      components/elements/commands/elements/options/index.tsx

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

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

Loading…
Cancel
Save