diff --git a/src/App.tsx b/src/App.tsx index 5d8e889..caf8ad4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -19,6 +19,9 @@ const useStyles = makeStyles((theme) => ({ root: { padding: theme.spacing(10, 2, 2, 2), height: "100vh", + "& > div > *": { + height: "100%", + }, }, })); @@ -44,8 +47,8 @@ export const App = () => { useEffect(() => { if (planContainer.current) setCanvasSize({ - w: planContainer.current.clientWidth, - h: planContainer.current.clientHeight, + w: planContainer.current.clientWidth - theme.spacing(2), + h: planContainer.current.clientHeight - theme.spacing(1), }); }, [planContainer.current]); @@ -60,10 +63,7 @@ export const App = () => { - + diff --git a/src/components/RoomList.tsx b/src/components/RoomList.tsx index f29f1f9..830a2bf 100644 --- a/src/components/RoomList.tsx +++ b/src/components/RoomList.tsx @@ -6,16 +6,26 @@ import { ListItemText, Typography, makeStyles, + InputLabel, + Select, + Box, } from "@material-ui/core"; +import { ChangeEvent, useState } from "react"; import { useRoomContext } from "../context"; +import { FilterState } from "../types/ui"; const useStyles = makeStyles((theme) => ({ drawer: { width: "100%", - minHeight: "100%", + height: `calc(100% - ${theme.spacing(1)}px)`, padding: theme.spacing(2), }, + filterBox: { + display: "flex", + alignItems: "center", + gap: theme.spacing(1), + }, indicatorContainer: { minWidth: theme.spacing(3), }, @@ -37,22 +47,54 @@ export const RoomList = () => { const { state } = useRoomContext(); + const [filter, setFilter] = useState(FilterState.ALL); + + const handleFilterChange = ( + event: ChangeEvent<{ name?: string; value: unknown }> + ) => { + if (event.target && typeof event.target.value === "string") + setFilter(Number.parseInt(event.target.value)); + }; + return ( Class room avaliability status + + Filter + + + - {state.map.map(({ title }, index) => ( - - -
- - - - ))} + {state.map.map(({ title }, index) => { + if (filter === FilterState.FREE && !state.char[index].free) return ""; + else if (filter === FilterState.BUSY && state.char[index].free) + return ""; + else + return ( + + +
+ + + + ); + })} ); diff --git a/src/types/ui.ts b/src/types/ui.ts new file mode 100644 index 0000000..20739e6 --- /dev/null +++ b/src/types/ui.ts @@ -0,0 +1,5 @@ +export enum FilterState { + ALL, + FREE, + BUSY, +}