Skip to content

Commit 2af404e

Browse files
authored
Merge pull request #292 from uwblueprint/announcements
e2e implementation of participant announcements
2 parents ebc191c + d0866b1 commit 2af404e

File tree

20 files changed

+474
-197
lines changed

20 files changed

+474
-197
lines changed

backend/resolvers/announcementResolver.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PrismaClient, Announcement, Priority } from "@prisma/client";
1+
import { PrismaClient, Announcement, Priority, UserAnnouncement } from "@prisma/client";
22
import { getNow } from "../utils/formatDateTime";
33

44
const prisma = new PrismaClient();
@@ -83,21 +83,19 @@ const announcementResolver = {
8383
{
8484
participant_id,
8585
}: { participant_id: number; }
86-
): Promise<Announcement[]> => {
86+
): Promise<UserAnnouncement[]> => {
8787
try {
88-
return await prisma.announcement.findMany({
88+
return await prisma.userAnnouncement.findMany({
8989
orderBy: {
90-
creation_date: "desc",
90+
announcement: {
91+
creation_date: "desc"
92+
},
9193
},
9294
where: {
93-
user_announcements: {
94-
some: {
95-
participant_id,
96-
},
97-
},
95+
participant_id,
9896
},
9997
include: {
100-
user_announcements: true,
98+
announcement: true,
10199
},
102100
});
103101
} catch (err) {

backend/types/resolvers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const resolvers = gql`
1616
getAllAnnouncements: [Announcement]
1717
getAnnouncementsInDateRange(start: String!, end: String!): [Announcement]
1818
getAnnouncementsByParticipants(participant_ids: [Int!]!): [Announcement]
19-
getAnnouncementsByParticipantId(participant_id: Int!): [Announcement]
19+
getAnnouncementsByParticipantId(participant_id: Int!): [UserAnnouncement]
2020
getAssignedTasks(participant_id: Int!): GetAssignedTaskResponse!
2121
getTasksByType(type: [TaskType!]!): [Task]
2222
getCustomBadges: [Badge]

frontend/src/gql/mutations.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,22 @@ export const SET_MARILLAC_BUCKS_GOAL = gql`
308308
}
309309
`;
310310

311+
export const UPDATE_PIN_READ_ANNOUNCEMENTS = gql`
312+
mutation UpdatePinReadAnnouncement(
313+
$announcement_id: Int!
314+
$participant_id: Int!
315+
$pinned: Boolean
316+
$read: Boolean
317+
) {
318+
updatePinReadAnnouncement(
319+
announcement_id: $announcement_id
320+
participant_id: $participant_id
321+
pinned: $pinned
322+
read: $read
323+
)
324+
}
325+
`
326+
311327
export const UPDATE_MARILLAC_BUCKS_GOAL = gql`
312328
mutation updateMarillacBucksGoal($participant_id: Int!, $new_goal_value: Int!) {
313329
updateMarillacBucksGoal(participant_id: $participant_id, new_goal_value: $new_goal_value)

frontend/src/gql/queries.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ export const GET_ANNOUNCEMENTS_BY_PARTICIPANT_ID = gql`
164164
participant_id: $participant_id
165165
) {
166166
announcement_id
167-
priority
168-
creation_date
169-
message
170-
user_announcements {
171-
participant_id
167+
participant_id
168+
read
169+
pinned
170+
announcement {
171+
priority
172+
creation_date
173+
message
172174
}
173175
}
174176
}
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
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)