import React, { useState } from 'react'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import { Spinner, Table } from 'react-bootstrap'; import SearchField from './SearchField.js'; const search = (prefix, api, setState) => { setState({ data: undefined, loading: true }); const lookupSuccess = (response) => setState({ data: response.data, loading: false }); const lookupFail = (error) => { setState({ data: undefined, loading: false }); setState(() => { throw error; }); }; return api.lookupStorage(prefix).then(lookupSuccess).catch(lookupFail); }; const LookupStorageForm = ({ api }) => { const [state, setState] = useState({ data: undefined, loading: false }); return (
search(data.search, api, setState)} /> {state.loading && } {state.data &&
}
); }; const Details = ({ data }) => ( {data.map((item, i) => ( ))}
Key Value
); const TableRow = ({ item }) => ( {item.prefix} {item.value} ); export default LookupStorageForm;