Skip to content

Commit

Permalink
🛠️ Refactor: Add created_by to pending requests (#102)
Browse files Browse the repository at this point in the history
* implement yousef's feedback

* add created by

* fix bug where createdBy not displaying after rejecting
  • Loading branch information
jcserv authored Sep 1, 2021
1 parent 34e939e commit 7cefd77
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion client/components/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Image from "next/image";
import { useRouter } from "next/router";
import React from "react";
import {
FaCalendar,
FaDiscord,
FaRegSnowflake,
FaSun,
Expand All @@ -16,6 +17,7 @@ const termToIcon = {
Fall: GiChestnutLeaf,
Winter: FaRegSnowflake,
Summer: FaSun,
Year: FaCalendar,
};

const LinkIcon = ({ link, titleColor }) => (
Expand All @@ -41,7 +43,8 @@ const CourseInfo = ({ descriptionColor, campus, term, year }) => (
as="h2"
isTruncated
>
{campus} <Icon as={termToIcon[term]} /> {year}
{campus} {year !== "N/A" ? year : ""}{" "}
{term !== "N/A" && <Icon as={termToIcon[term]} />}
</Box>
</>
);
Expand Down
10 changes: 9 additions & 1 deletion client/components/RequestsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import React from "react";

import { statuses } from "../constants";

const ChatRequestCard = ({ showRequestBtns, modifyRequest, name, id }) => {
const ChatRequestCard = ({
showRequestBtns,
modifyRequest,
name,
id,
createdBy,
}) => {
const { locale, defaultLocale, push } = useRouter();
return (
<Box
Expand All @@ -31,6 +37,8 @@ const ChatRequestCard = ({ showRequestBtns, modifyRequest, name, id }) => {
</Link>
</Heading>
<Spacer />
<Text m={7}>{createdBy}</Text>
<Spacer />
{showRequestBtns ? (
<>
<IconButton
Expand Down
2 changes: 2 additions & 0 deletions client/gql/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export const GET_ADMIN_DATA = gql`
pendingChats: getGroupChatByStatus(status: $status1) {
id
name
createdBy
}
rejectedChats: getGroupChatByStatus(status: $status2) {
id
name
createdBy
}
users: getUsers(limit: $limit) {
email
Expand Down
1 change: 1 addition & 0 deletions client/gql/GroupChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const UPDATE_GROUPCHAT_STATUS = gql`
updateStatus(id: $id, status: $status) {
name
id
createdBy
}
}
`;
Expand Down
7 changes: 5 additions & 2 deletions client/pages/admin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ export default function Admin() {
}, []);

const modifyRequest = async (id, status) => {
const { name, groupChatId } = await modifyGroupchatStatus(id, status);
const { name, groupChatId, createdBy } = await modifyGroupchatStatus(
id,
status
);
if (status === "rejected") {
setRejected((rejectedGroups) => [
...rejectedGroups,
{ id: groupChatId, name },
{ id: groupChatId, name, createdBy },
]);
}
setPending((pendingGroups) =>
Expand Down
4 changes: 2 additions & 2 deletions client/requests/groupChats.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function getGroupchatReq(id) {
export async function modifyGroupchatStatus(id, status) {
const {
data: {
updateStatus: { name, id: groupChatId },
updateStatus: { name, id: groupChatId, createdBy },
},
} = await client.mutate({
mutation: UPDATE_GROUPCHAT_STATUS,
Expand All @@ -83,7 +83,7 @@ export async function modifyGroupchatStatus(id, status) {
status,
},
});
return { name, groupChatId };
return { name, groupChatId, createdBy };
}

export async function searchChats(
Expand Down
1 change: 1 addition & 0 deletions server/dist/models/Groupchat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export declare class GroupChat {
id: string;
name: string;
description: string;
createdBy: string;
links: string[];
isCommunity: boolean;
courseInformation?: CourseInformation;
Expand Down
4 changes: 4 additions & 0 deletions server/dist/models/Groupchat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/dist/models/Groupchat.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions server/models/Groupchat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class GroupChat {

@Field() description: string;

@Field() createdBy: string;

@Field(() => [String])
links: string[];

Expand Down

0 comments on commit 7cefd77

Please sign in to comment.