|
|
@ -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]); |
|
|
|