import React, { useState, useContext, useEffect } from "react"; import { useHistory } from "react-router-dom"; import { Realm } from "../../realm/models/Realm"; import { Dropdown, DropdownToggle, DropdownItem, Button, Divider, } from "@patternfly/react-core"; import style from "./realm-selector.module.css"; type RealmSelectorProps = { realm: string; realmList: Realm[]; }; export const RealmSelector = ({ realm, realmList }: RealmSelectorProps) => { const [open, setOpen] = useState(false); const history = useHistory(); const [currentRealm, setCurrentRealm] = useState(realm); const dropdownItems = realmList.map((r) => ( { setCurrentRealm(r.realm); setOpen(!open); }} > {r.realm.charAt(0).toUpperCase() + r.realm.slice(1)} )); return ( setOpen(!open)} className={style.toggle} > {currentRealm} } dropdownItems={[ ...dropdownItems, , , ]} /> ); };