Skip to content

Commit

Permalink
fix prettier errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KathleenX7 committed Jun 20, 2024
1 parent c1af4eb commit 8400055
Showing 1 changed file with 65 additions and 29 deletions.
94 changes: 65 additions & 29 deletions frontend/src/components/pages/announcements/AnnouncementsGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import moment from "moment";
import {
Box,
Flex,
InputGroup,
InputLeftElement,
Input,
Icon,
Tabs,
TabList,
Expand All @@ -22,9 +19,8 @@ import {
TagLabel,
TagCloseButton,
HStack,
border,
} from "@chakra-ui/react";
import { BorderColor, Search } from "@mui/icons-material";
import { Search } from "@mui/icons-material";
import EditNoteIcon from "@mui/icons-material/EditNote";
import PersonOutlineOutlinedIcon from "@mui/icons-material/PersonOutlineOutlined";
import PeopleAltOutlinedIcon from "@mui/icons-material/PeopleAltOutlined";
Expand Down Expand Up @@ -107,7 +103,7 @@ const GroupList: React.FC<{
useState<ProcessedGroupAnnouncements>();

const [searchRooms, setSearchRooms] = useState<number[]>([]);
const [allRooms, setAllRooms] = useState([1,2,3,4,5,6]);
const [allRooms, setAllRooms] = useState([1, 2, 3, 4, 5, 6]);

Check warning on line 106 in frontend/src/components/pages/announcements/AnnouncementsGroups.tsx

View workflow job for this annotation

GitHub Actions / run-lint

'setAllRooms' is assigned a value but never used
useEffect(() => {
const processedData: ProcessedGroupAnnouncements = {
all: {},
Expand All @@ -134,29 +130,39 @@ const GroupList: React.FC<{
return (
announcementsGroup &&
Object.keys(announcementsGroup)
.filter(roomKey => !searchRooms || searchRooms.length === 0 || searchRooms.some(room => roomKey.split(',').map(Number).includes(room)))
.map((roomKey) => (
<GroupTab
key={roomKey}
roomKey={roomKey}
firstAnnouncement={announcementsGroup[roomKey][0]}
setSelectedGroup={setSelectedGroup}
/>
))
.filter(
(roomKey) =>
!searchRooms ||
searchRooms.length === 0 ||
searchRooms.some((room) =>
roomKey.split(",").map(Number).includes(room),
),
)
.map((roomKey) => (
<GroupTab
key={roomKey}
roomKey={roomKey}
firstAnnouncement={announcementsGroup[roomKey][0]}
setSelectedGroup={setSelectedGroup}
/>
))
);
};

const deleteSearchRoom = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>, roomId: number) => {
if(searchRooms.includes(roomId)) {
setSearchRooms(searchRooms.filter(room => room !== roomId));
const deleteSearchRoom = (
e: React.MouseEvent<HTMLButtonElement, MouseEvent>,
roomId: number,
) => {
if (searchRooms.includes(roomId)) {
setSearchRooms(searchRooms.filter((room) => room !== roomId));
}
}
};

const addRoomToSearch = (roomId: number) => {
if(!searchRooms.includes(roomId)) {
if (!searchRooms.includes(roomId)) {
setSearchRooms([...searchRooms, roomId]);
}
}
};

return (
<Box h="100vh" w="100%" borderRight="solid" borderRightColor="gray.300">
Expand All @@ -169,22 +175,52 @@ const GroupList: React.FC<{
mb={4}
bg="purple.50"
>
<Box width = "100%" marginRight="1.25rem" marginLeft="1.25rem" position="relative" w="100%" bg="white" h="2.5rem" borderRadius="0.375rem" border="1px solid" borderColor="inherit" _hover={{borderColor: "#C5C8D8"}} _focusVisible={{borderColor: "477FC8", boxShadow: "0 0 0 1px #3182ce"}}>
<Box
width="100%"
marginRight="1.25rem"
marginLeft="1.25rem"
position="relative"
w="100%"
bg="white"
h="2.5rem"
borderRadius="0.375rem"
border="1px solid"
borderColor="inherit"
_hover={{ borderColor: "#C5C8D8" }}
_focusVisible={{
borderColor: "477FC8",
boxShadow: "0 0 0 1px #3182ce",
}}
>
<Menu>
<MenuButton width="100%" position="absolute" height="100%"/>
<MenuButton width="100%" position="absolute" height="100%" />
<MenuList maxH="40vh" overflow="auto" position="absolute">
{allRooms.filter(room => !searchRooms.includes(room)).map((room) => (
<MenuItem onClick={()=>addRoomToSearch(room)} key={room}>Room {room}</MenuItem>
))}
{allRooms
.filter((room) => !searchRooms.includes(room))
.map((room) => (
<MenuItem onClick={() => addRoomToSearch(room)} key={room}>
Room {room}
</MenuItem>
))}
</MenuList>
</Menu>

<HStack spacing={2} height="100%" paddingLeft="8px">
<Icon as={Search} color="gray.300" />
{searchRooms.map((room) => (
<Tag key={room} variant='solid' height="30px" color='#57469D' border='1px solid #57469D' backgroundColor='#F9F7FF'>
<Tag
key={room}
variant="solid"
height="30px"
color="#57469D"
border="1px solid #57469D"
backgroundColor="#F9F7FF"
>
<TagLabel textAlign="center"> Room {room} </TagLabel>
<TagCloseButton onClick = {(e) => deleteSearchRoom(e, room)} color='#57469D'/>
<TagCloseButton
onClick={(e) => deleteSearchRoom(e, room)}
color="#57469D"
/>
</Tag>
))}
</HStack>
Expand Down

0 comments on commit 8400055

Please sign in to comment.