diff --git a/frontend/app/allRooms/page.tsx b/frontend/app/allRooms/page.tsx index d6acadcc..0fe99dd5 100644 --- a/frontend/app/allRooms/page.tsx +++ b/frontend/app/allRooms/page.tsx @@ -9,6 +9,7 @@ import { useMemo, useState } from "react"; import { useSelector } from "react-redux"; import { selectFilters } from "redux/filtersSlice"; +import AllRoomsBuildingSelector from "../../components/AllRoomsBuildingSelector"; import AllRoomsFilter from "../../components/AllRoomsFilter"; import Room from "../../components/AllRoomsRoom"; import RoomList from "../../components/AllRoomsRoomList"; @@ -63,6 +64,7 @@ export default function Page() { Not looking for a specific building? See all free rooms in this easy to search list! + diff --git a/frontend/components/AllRoomsBuildingModal.tsx b/frontend/components/AllRoomsBuildingModal.tsx new file mode 100644 index 00000000..ebaf2c5e --- /dev/null +++ b/frontend/components/AllRoomsBuildingModal.tsx @@ -0,0 +1,129 @@ +import { Box, Fade, Modal, Stack, Typography } from "@mui/material"; +import { BoxProps, styled } from "@mui/system"; +import useBuildings from "hooks/useBuildings"; +import Image, { ImageProps } from "next/image"; +import FlipMove from "react-flip-move"; +import { useDispatch } from "react-redux"; +import { setCurrentBuilding } from "redux/currentBuildingSlice"; + +interface AllRoomsBuildingModalProps { + open: boolean; + onClose: () => void; +} + +const AllRoomsBuildingModal = ({ + open, + onClose, +}: AllRoomsBuildingModalProps) => { + const { buildings } = useBuildings(); + + const dispatch = useDispatch(); + + return ( + + + + Search by building name + + + {buildings?.map((building) => ( + { + dispatch(setCurrentBuilding(building)); + onClose(); + }} + > + + + + {building.name} + + + + ))} + + + + + + ); +}; + +const FlipMoveGrid = styled(FlipMove)(() => ({ + width: "100%", + display: "grid", + gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))", + gridGap: "20px", +})); + +const MainBox = styled(Box)(({ theme }) => ({ + position: "relative", + flex: 1, + height: 200, + backgroundColor: theme.palette.primary.main, + borderRadius: 10, + "&:hover": { + cursor: "pointer", + }, + [theme.breakpoints.down("lg")]: { + height: 100, + }, + [theme.breakpoints.down("md")]: { + height: 50, + }, +})); + +const StyledImage = styled(Image)(() => ({ + borderRadius: 10, + transition: "all 0.1s ease-in-out", + "&:hover": { + opacity: 0.7, + }, +})); + +const TitleBox = styled(Box)(({ theme }) => ({ + display: "flex", + borderRadius: 10, + position: "absolute", + justifyContent: "space-between", + bottom: 0, + left: 0, + right: 0, + backgroundColor: theme.palette.primary.main, + color: "white", + padding: 15, + paddingLeft: 20, + paddingRight: 20, + margin: 10, + pointerEvents: "none", +})); + +const StyledModal = styled(Modal)(({ theme }) => ({ + maxWidth: "70svw", + maxHeight: "70svh", + overflow: "auto", + margin: "auto", +})); + +const StyledBox = styled(Box)({ + padding: "20px", + backgroundColor: "white", + borderRadius: "10px", +}); + +const StyledGridBox = styled(Box)({ + marginTop: "15px", + display: "flex", + flexDirection: "column", + alignItems: "center", + justifyContent: "center", +}); + +export default AllRoomsBuildingModal; diff --git a/frontend/components/AllRoomsBuildingSelector.tsx b/frontend/components/AllRoomsBuildingSelector.tsx new file mode 100644 index 00000000..66329160 --- /dev/null +++ b/frontend/components/AllRoomsBuildingSelector.tsx @@ -0,0 +1,62 @@ +import { styled } from "@mui/system"; +import Image, { ImageProps } from "next/image"; +import { useState } from "react"; +import { useSelector } from "react-redux"; +import { selectCurrentBuilding } from "redux/currentBuildingSlice"; + +import AllRoomsBuildingModal from "./AllRoomsBuildingModal"; + +const AllRoomsBuildingSelector = () => { + const [open, setOpen] = useState(false); + const currentBuilding = useSelector(selectCurrentBuilding); + + return ( + <> + setOpen(true)} + buildingId={currentBuilding?.id} + > + {currentBuilding ? currentBuilding.name : "Select Building"} + + setOpen(false)} /> + + ); +}; + +const StyledSelector = styled("div")<{ buildingId?: string }>( + ({ theme, buildingId }) => ({ + display: "flex", + alignItems: "center", + justifyContent: "center", + color: theme.palette.primary.default, + fontSize: "18px", + fontWeight: buildingId ? "bold" : "normal", + borderColor: theme.palette.primary.main, + borderStyle: "solid", + borderWidth: "1px", + borderRadius: "10px", + marginTop: "20px", + padding: "20px 0", + cursor: "pointer", + position: "relative", + overflow: "hidden", + "&::before": { + content: '""', + position: "absolute", + top: 0, + left: 0, + width: "100%", + height: "100%", + backgroundImage: buildingId + ? `url(/assets/building_photos/${buildingId}.webp)` + : "none", + backgroundSize: "cover", + backgroundPosition: "center", + backgroundRepeat: "no-repeat", + opacity: 0.4, + zIndex: -1, + }, + }) +); + +export default AllRoomsBuildingSelector;