Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
KathleenX7 committed Dec 14, 2024
1 parent ab230e1 commit e2e9945
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion frontend/src/APIClients/Types/ResidentsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ export type ResidentResponse = {
credits: number;
dateJoined: Date;
dateLeft: Date;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const formatRooms = (roomIDs: number[]) => {
const formattedRooms = roomIDs.map((id) => {
if (id === 0) {
return "New Announcement";
} if (id === -1) {
}
if (id === -1) {
return "All Rooms";
}
return `Room ${id}`;
Expand Down Expand Up @@ -107,7 +108,7 @@ const GroupTab = ({
<Flex flexDir="column" w="100%">
<Flex justifyContent="space-between">
<Text as="b" color={isDraft ? "gray.500" : "black"}>
{announcementGroup? 'All Rooms': formatRooms(rooms)}
{announcementGroup ? "All Rooms" : formatRooms(rooms)}
</Text>
<Text margin="0" color="gray.500">
{firstAnnouncement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ const AnnouncementsPage = (): React.ReactElement => {
// userId: number;
// }>(SEND_ANNOUNCEMENT);

const {
loading: allNotificationsLoading,
error: allNotificationsError,
data: allNotificationsData,
} = useQuery(GET_ALL_GROUPS_AND_NOTIFICATIONS);

// const {
// loading: notificationByIdLoading,
// error: notificationByIdError,
Expand Down Expand Up @@ -146,6 +140,12 @@ const AnnouncementsPage = (): React.ReactElement => {
]
*/

const {
loading: allNotificationsLoading,
error: allNotificationsError,
data: allNotificationsData,
} = useQuery(GET_ALL_GROUPS_AND_NOTIFICATIONS);

const [sendNotificationToGroup] = useMutation(SEND_NOTIFICATION_TO_GROUP);
const [createNotificationGroup] = useMutation(CREATE_NOTIFICATION_GROUP);
const [createAnnouncementGroup] = useMutation(CREATE_ANNOUNCEMENT_GROUP);
Expand Down
42 changes: 26 additions & 16 deletions frontend/src/components/pages/announcements/AnnouncementsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ const AnnouncementsView = ({
createNotificationGroupAndSendNotification,
}: Props): React.ReactElement => {
const groupInfo = announcements.find((group) => group.id === selectedGroup);
const rooms = groupInfo && groupInfo.recipients? groupInfo.recipients.map((recipient) => recipient.roomNumber): [];
const rooms =
groupInfo && groupInfo.recipients
? groupInfo.recipients.map((recipient) => recipient.roomNumber)
: [];
const [allRooms, setAllRooms] = useState([1, 2, 3, 4, 5, 6]);

const addRoomToNewRoom = (roomId: number) => {
Expand Down Expand Up @@ -181,34 +184,43 @@ const AnnouncementsView = ({
border="1px solid #57469D"
backgroundColor="#F9F7FF"
>
<TagLabel textAlign="center"> {room === -1? 'All Rooms': `Room ${room}`}</TagLabel>
<TagLabel textAlign="center">
{" "}
{room === -1 ? "All Rooms" : `Room ${room}`}
</TagLabel>
<TagCloseButton
onClick={() => deleteRoomSelected(room)}
color="#57469D"
/>
</Tag>
))}
{selectedRooms.length === 0 &&
{selectedRooms.length === 0 && (
<Menu>
<MenuButton>
<AddCircleOutlineOutlinedIcon sx={{ color: "#57469D" }} />
</MenuButton>
<MenuList maxH="40vh" overflow="auto">
{[
<MenuItem onClick={() => addRoomToNewRoom(-1)} key='all-rooms'>
All Rooms
</MenuItem>,
<MenuItem
onClick={() => addRoomToNewRoom(-1)}
key="all-rooms"
>
All Rooms
</MenuItem>,
...allRooms
.filter((room) => !selectedRooms.includes(room))
.map((room) => (
<MenuItem onClick={() => addRoomToNewRoom(room)} key={room}>
<MenuItem
onClick={() => addRoomToNewRoom(room)}
key={room}
>
Room {room}
</MenuItem>
))
)),
]}
</MenuList>
</Menu>
}
)}
</HStack>
</Flex>
);
Expand All @@ -219,12 +231,12 @@ const AnnouncementsView = ({
const getHeader = () => {
if (selectedGroup === "" || selectedGroup === "0") {
return formatHeader(rooms);
}
}
if (groupInfo?.announcementGroup) {
return 'All Rooms';
}
return "All Rooms";
}
return formatRooms(rooms);
}
};

return (
<Box h="100vh" w="100%">
Expand All @@ -238,9 +250,7 @@ const AnnouncementsView = ({
justifyContent="space-between"
h="10vh"
>
<h1 style={{ fontSize: "24px", margin: "0" }}>
{getHeader()}
</h1>
<h1 style={{ fontSize: "24px", margin: "0" }}>{getHeader()}</h1>
<IconButton
aria-label="info"
color="purple.main"
Expand Down

0 comments on commit e2e9945

Please sign in to comment.