Skip to content

Commit 35aa7ef

Browse files
committed
expanded view frontend
1 parent 478bcd4 commit 35aa7ef

File tree

5 files changed

+148
-38
lines changed

5 files changed

+148
-38
lines changed
Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
import React from "react";
2-
import { Button, Text } from "@chakra-ui/react";
2+
import { Button, Flex, Text } from "@chakra-ui/react";
33
import { ButtonProps } from "../../types/component";
44

5-
export default function GreenButton({ text, action, is_active }: ButtonProps) {
5+
type GreenButtonProps = ButtonProps & {
6+
icon?: JSX.Element;
7+
};
8+
9+
export default function GreenButton({ text, action, is_active, icon }: GreenButtonProps) {
610
return (
711
<Button
8-
onClick={action}
9-
isActive={is_active}
10-
cursor="pointer"
11-
borderRadius="4px"
12-
border="1px"
13-
borderColor="#0C727E"
14-
width="fit-content"
15-
height="fit-content"
16-
paddingX="10px"
17-
paddingY="8px"
18-
bg="#FFFFFF"
19-
color="#0C727E"
20-
_hover={{
21-
color: "#FFFFFF",
22-
bg: "#0C727E",
23-
}}
24-
_active={{
25-
color: "#FFFFFF",
26-
bg: "#0C727E",
27-
}}
12+
onClick={action}
13+
isActive={is_active}
14+
cursor="pointer"
15+
borderRadius="4px"
16+
border="1px"
17+
borderColor="#0C727E"
18+
width="fit-content"
19+
height="fit-content"
20+
paddingX="10px"
21+
paddingY="8px"
22+
bg="#FFFFFF"
23+
color="#0C727E"
24+
_hover={{
25+
color: "#FFFFFF",
26+
bg: "#0C727E",
27+
}}
28+
_active={{
29+
color: "#FFFFFF",
30+
bg: "#0C727E",
31+
}}
2832
>
29-
<Text textStyle="mobile.c1" color="inherit">
30-
{text}
31-
</Text>
33+
<Flex alignItems="center" gap="5px">
34+
{icon}
35+
<Text textStyle="mobile.c1" color="inherit">
36+
{text}
37+
</Text>
38+
</Flex>
3239
</Button>
3340
);
3441
}

frontend/src/participant/pages/announcements/Main.tsx

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { ParticipantContext } from "../../common/ParticipantContext";
1010
import { Priority } from "../../../types/AnnouncementTypes";
1111
import GreenButton from "../../common/GreenButton";
12+
import AnnouncementsExpandedView from "./components/AnnouncementsExpandedView";
1213

1314
// Keep labels stable
1415
const FILTER_LABELS = ["ALL", "UNREAD", "PINNED", "IMPORTANT"] as const;
@@ -17,6 +18,17 @@ export default function ParticipantsAnnouncementsPage() {
1718
const participant = useContext(ParticipantContext);
1819
const participantId = participant?.id;
1920

21+
const [expandedView, setExpandedView] = useState(false);
22+
const [selected, setSelected] = useState({
23+
uaid: -1,
24+
allRooms: false,
25+
message: "",
26+
importance: -1,
27+
read: false,
28+
pinned: false,
29+
date: ""
30+
})
31+
2032
const [filter, setFilter] = useState(0);
2133
const isAll = filter === 0;
2234

@@ -56,6 +68,12 @@ export default function ParticipantsAnnouncementsPage() {
5668
if (loading) return <Text>Loading announcements…</Text>;
5769
if (error) return <Text color="red.500">Error loading announcements.</Text>;
5870

71+
if (expandedView && selected) {
72+
return (
73+
<AnnouncementsExpandedView announcement={selected} />
74+
)
75+
}
76+
5977
return (
6078
<>
6179
<Flex w="100%" alignItems="center" justifyContent="center" gap="8px">
@@ -72,17 +90,38 @@ export default function ParticipantsAnnouncementsPage() {
7290
<Text textStyle="mobile.s1" color="text.light.secondary">
7391
Most Recent
7492
</Text>
75-
{data.map((a: any) => {
93+
{data.map((a: any, i: number) => {
94+
const uaid = a.announcement_id;
95+
const allRooms = false;
96+
const message = isAll ? a.message : a.announcement.message
97+
const importance = Object.values(Priority).indexOf(isAll ? a.priority : a.announcement.priority)
98+
const read = isAll ? a.user_announcements.read : a.read
99+
const pinned = isAll ? a.user_announcements.pinned : a.pinned
100+
const date = isAll ? a.creation_date : a.announcement.creation_date
101+
76102
return (
77-
<ParticipantAnnouncementCard
78-
key={a.announcement_id}
79-
allRooms={false}
80-
message={isAll ? a.message : a.announcement.message}
81-
importance={Object.values(Priority).indexOf(isAll ? a.priority : a.announcement.priority)}
82-
hasRead={isAll ? a.user_announcements.read : a.read}
83-
isPinned={isAll ? a.user_announcements.pinned : a.pinned}
84-
time={isAll ? a.creation_date : a.announcement.creation_date}
85-
/>
103+
<Flex key={i} cursor="pointer" onClick={() => {
104+
setSelected({
105+
uaid,
106+
allRooms,
107+
message,
108+
importance,
109+
read,
110+
pinned,
111+
date
112+
})
113+
setExpandedView(true)
114+
}}>
115+
<ParticipantAnnouncementCard
116+
userAnnouncementId={uaid}
117+
allRooms={allRooms}
118+
message={message}
119+
importance={importance}
120+
hasRead={read}
121+
isPinned={pinned}
122+
time={date}
123+
/>
124+
</Flex>
86125
);
87126
})}
88127
</>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Divider, Flex, Text } from "@chakra-ui/react";
2+
import React from "react";
3+
import { displayDate2 } from "../../../../utils/formatDateTime";
4+
import Icon from "../../../common/Icon";
5+
import important from "../../../icons/announcements/important.svg"
6+
import orangepin from "../../../icons/announcements/orangepin.svg"
7+
import greenpin from "../../../icons/announcements/greenpin.svg"
8+
import unread from "../../../icons/announcements/unread.svg"
9+
import GreenButton from "../../../common/GreenButton";
10+
11+
type AnnouncementInfo = {
12+
uaid: number;
13+
allRooms: boolean;
14+
message: string;
15+
importance: number;
16+
read: boolean;
17+
pinned: boolean;
18+
date: string;
19+
}
20+
21+
type AnnouncementsExpandedViewProps = {
22+
announcement: AnnouncementInfo;
23+
}
24+
25+
export default function AnnouncementsExpandedView({ announcement }: AnnouncementsExpandedViewProps) {
26+
return (
27+
<>
28+
<Flex alignItems="center" justify="space-between">
29+
<Text textStyle="mobile.h2">{announcement.allRooms ? "Admin To All Rooms" : "Admin To Your Room"}</Text>
30+
<Text textStyle="mobile.b0" color="text.light.secondary">{displayDate2(new Date(announcement.date))}</Text>
31+
</Flex>
32+
33+
<Flex gap="12px">
34+
<Flex gap="8px">
35+
<Icon icon={important} width="3px" height="3px" />
36+
<Text textStyle="mobile.s1" color="#D34C5C">Priority</Text>
37+
</Flex>
38+
<Flex gap="8px">
39+
<Icon icon={orangepin} width="8px" height="8px" />
40+
<Text textStyle="mobile.s1" color="#E67D4F">Pinned</Text>
41+
</Flex>
42+
</Flex>
43+
44+
<Divider borderColor="neutral.300" />
45+
46+
<Text>{announcement.message}</Text>
47+
48+
<Flex marginTop="8px" gap="12px">
49+
<GreenButton
50+
text="Mark as Unread"
51+
is_active={false}
52+
action={() => {}}
53+
icon={<Icon icon={unread} width="14px" height="14px" />}
54+
/>
55+
<GreenButton
56+
text="Pin"
57+
is_active={false}
58+
action={() => {}}
59+
icon={<Icon icon={greenpin} width="8px" height="8px" />}
60+
/>
61+
</Flex>
62+
</>
63+
)
64+
};

frontend/src/participant/pages/announcements/components/ParticipantAnnouncementCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PeopleOutlineIcon from "@mui/icons-material/PeopleOutline";
44
import PriorityHighIcon from "@mui/icons-material/PriorityHigh";
55
import PushPinIcon from "@mui/icons-material/PushPin";
66
import CircleIcon from "@mui/icons-material/Circle";
7-
import React from "react";
7+
import React, { useState } from "react";
88
import notification from "../../../icons/announcements/notification.svg"
99
import group from "../../../icons/announcements/group.svg"
1010
import profile from "../../../icons/announcements/profile.svg"
@@ -20,9 +20,11 @@ type ParticipantAnnouncementCardProps = {
2020
hasRead: boolean;
2121
isPinned: boolean;
2222
time: string;
23+
userAnnouncementId: number;
2324
};
2425

2526
export default function ParticipantAnnouncementCard({
27+
userAnnouncementId,
2628
allRooms,
2729
message,
2830
importance,
@@ -39,7 +41,6 @@ export default function ParticipantAnnouncementCard({
3941
paddingLeft="25px"
4042
flexDir="column"
4143
position="relative"
42-
cursor="pointer"
4344
>
4445
{!hasRead && (
4546
<Flex position="absolute" top="42px" left="0px">

frontend/src/utils/formatDateTime.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ export const displayDate2 = (date: Date) => {
237237
const month = get("month");
238238
const day = get("day");
239239
const dayPeriod = get("dayPeriod").toUpperCase().replaceAll(".", "");
240-
console.log(dayPeriod)
241240

242241
return `${hour}:${minute} ${dayPeriod}, ${month} ${day}`;
243242
};

0 commit comments

Comments
 (0)