import React, { useState } from 'react'; import { nanoid } from 'nanoid'; import { IconTrash } from '@tabler/icons'; import StyledWrapper from './StyledWrapper'; const initialState = [{ uid: nanoid(), enabled: true }]; const QueryParams = () => { const [params, setParams] = useState(initialState); const addParam = () => { let newParam = { uid: nanoid(), key: '', value: '', description: '', enabled: true }; let newParams = [...params, newParam]; setParams(newParams); }; const handleParamValueChange = (e, index, menu) => { // todo: yet to implement }; const handleRemoveHeader = (index) => { params.splice(index, 1); setParams([...params]); }; return ( {params && params.length ? params.map((header, index) => { return ( ); }) : null}
Key Value Description
handleParamValueChange(e, index, 'key')} /> handleParamValueChange(e, index, 'value')} /> handleParamValueChange(e, index, 'description')} />
handleParamValueChange(e, index, 'enabled')} />
) }; export default QueryParams;