import React, { useEffect } from "react"; import PropTypes from "prop-types"; import { withRouter } from "react-router-dom"; import { Form, FormGroup, FormControl, FormLabel } from "react-bootstrap"; import { upperCaseFirst } from "../../utils"; const ExplorerOptions = ({ display, params, options, type, history, fetch, }) => { useEffect(() => { fetch(); }, [fetch]); if (!display) { return null; } if ( !params || !params.source || !params.category || params.source === "" || params.category === "" ) { return null; } const handleSourceChange = (event) => { let source = event.target.value; let category = options[event.target.value][0]; history.push(`/${type}/explore/${source}/${category}`); }; const handleCategoryChange = (event) => { let source = params.source; let category = event.target.value; history.push(`/${type}/explore/${source}/${category}`); }; const prettyName = (name) => { return name .replace("_", " ") .split(" ") .map((w) => upperCaseFirst(w)) .join(" "); }; // Options are not yet fetched if (Object.keys(options).length === 0) { return null; } let source = params.source; let category = params.category; let categories = options[params.source]; return (