import React from "react"; import PropTypes from "prop-types"; import { withRouter } from "react-router-dom"; import { Form, FormGroup, FormControl, FormLabel } from "react-bootstrap"; const ExplorerOptions = ({ display, params, options, type, history }) => { // Should this componennt be displayed 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.get(event.target.value).first(); 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) => w[0].toUpperCase() + w.substr(1)) .join(" "); }; // Options are not yet fetched if (options.size === 0) { return null; } let source = params.source; let category = params.category; let categories = options.get(params.source); return (
Source {options.keySeq().map(function (source) { return ( ); })}
Category {categories.map(function (category) { return ( ); })}
); }; ExplorerOptions.propTypes = { params: PropTypes.object, history: PropTypes.object, type: PropTypes.string, options: PropTypes.object, display: PropTypes.bool, }; export default withRouter(ExplorerOptions);