diff --git a/packages/web/nextjs/src/layouts/AdrBrowserLayout/AdrBrowserLayout.tsx b/packages/web/nextjs/src/layouts/AdrBrowserLayout/AdrBrowserLayout.tsx index d4194ee..ef4cb0d 100644 --- a/packages/web/nextjs/src/layouts/AdrBrowserLayout/AdrBrowserLayout.tsx +++ b/packages/web/nextjs/src/layouts/AdrBrowserLayout/AdrBrowserLayout.tsx @@ -18,6 +18,9 @@ import { Hidden, IconButton } from "@material-ui/core"; +import Select from "@material-ui/core/Select"; +import InputLabel from "@material-ui/core/InputLabel"; +import MenuItem from "@material-ui/core/MenuItem"; import { Menu as MenuIcon, Close as CloseIcon } from "@material-ui/icons"; import { createStyles, makeStyles } from "@material-ui/core/styles"; // import { @@ -161,6 +164,21 @@ const useStyles = makeStyles((theme: CustomTheme) => { paddingBottom: theme.spacing(0.5), paddingRight: theme.spacing(3) }, + adlPackageSelect: { + display: "flex", + justifyContent: "left", + paddingLeft: theme.spacing(2), + [theme.breakpoints.up("sm")]: { + paddingLeft: theme.spacing(3) + }, + paddingBottom: theme.spacing(0.5), + paddingRight: theme.spacing(3) + }, + packageSelectLabel: { + paddingTop: "7px", + minWidth: "100px" + }, + packageSelectSelect: {}, adlTitle: { fontWeight: theme.typography.fontWeightBold }, @@ -266,6 +284,67 @@ export function AdrBrowserLayout({ const [searchOpen, setSearchOpenState] = React.useState(false); const [searchReallyOpen, setSearchReallyOpenState] = React.useState(false); + const [packages, setPackages] = React.useState(["all"]); + const [currentPackage, setCurrentPackage] = React.useState("All"); + const [currentPackageAdrs, setCurrentPackageAdrs] = React.useState(adrs); + + const [statuses, setStatuses] = React.useState(["all"]); + const [currentStatus, setCurrentStatus] = React.useState("All"); + const [currentStatusAdrs, setCurrentStatusAdrs] = React.useState(adrs); + + const handlePackageChange = ( + event: React.ChangeEvent<{ value: unknown }> + ) => { + setCurrentPackage(event.target.value as string); + setCurrentStatus("All"); + }; + + const handleStatusChange = (event: React.ChangeEvent<{ value: unknown }>) => { + setCurrentStatus(event.target.value as string); + }; + + React.useEffect(() => { + setPackages([ + ...new Set( + adrs?.map((adr) => { + return adr.package ? adr.package : "Global"; + }) + ) + ]); + }, [adrs]); + + React.useEffect(() => { + setStatuses([ + ...new Set( + currentPackageAdrs?.map((adr) => { + return adr.status ? adr.status : "Unknown"; + }) + ) + ]); + }, [currentPackageAdrs]); + + React.useEffect(() => { + if (currentPackage === "All") { + setCurrentPackageAdrs(adrs); + } else if (currentPackage === "Global") { + setCurrentPackageAdrs(adrs?.filter((adr) => adr.package === null)); + } else { + setCurrentPackageAdrs( + adrs?.filter((adr) => adr.package === currentPackage) + ); + } + }, [currentPackage, adrs]); + + React.useEffect(() => { + if (currentStatus === "All") { + setCurrentStatusAdrs(currentPackageAdrs); + } else { + setCurrentStatusAdrs( + currentPackageAdrs?.filter((adr) => adr.status === currentStatus) + ); + } + }, [currentStatus, currentPackageAdrs]); + const drawer = (