blob: 6c57a2509209366dac310e7924bca088877d7b13 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { QueryInputContext } from '../Contexts/QueryInputContext';
import React, { useContext, useEffect } from 'react';
import SimpleDropDownForm from './SimpleDropDownForm';
export default function QueryDropdownFormn({ choices, id }) {
const { inputs, setInputs } = useContext(QueryInputContext);
const updateType = (e) => {
e.preventDefault();
const index = inputs.findIndex((element) => element.id === id);
inputs[index].type = e.target.value;
setInputs(inputs);
};
useEffect(() => {
const index = inputs.findIndex((element) => element.id === id);
inputs[index].type = choices[0];
setInputs(inputs);
}, []);
return (
<SimpleDropDownForm
id={id}
onChange={updateType}
choices={choices}
></SimpleDropDownForm>
);
}
|