Skip to content

Commit

Permalink
Merge branch 'main' into fix-edit-past-event
Browse files Browse the repository at this point in the history
  • Loading branch information
jasozh committed Jun 8, 2024
2 parents 41ddc57 + 9d442dd commit 186cbd1
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 66 deletions.
79 changes: 64 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
</p>
</div>



<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
Expand All @@ -35,34 +33,35 @@
</ol>
</details>

<!-- ABOUT THE PROJECT -->

## About the Project

<!-- ABOUT THE PROJECT -->
## About The Project
This project aims to develop a volunteer management system for Lagos Food Bank Initiative. The system will allow volunteers to sign up for shifts, and for LFBI to manage volunteers and hours.
This project aims to develop a volunteer management system for Lagos Food Bank Initiative. The system will allow volunteers to sign up for shifts, and for LFBI to manage volunteers and hours.

### Built With

* [![Next][Next.js]][Next-url]
* [![React][React.js]][React-url]
* [![Express][Express.js]][Express-url]
* [![Postresql][Prisma.io]][Prisma-url]
- [![Next][Next.js]][Next-url]
- [![React][React.js]][React-url]
- [![Express][Express.js]][Express-url]
- [![Postresql][Prisma.io]][Prisma-url]

<!-- GETTING STARTED -->
## Getting Started

## Getting Started

> Folder structure
> Folder structure
.
├── frontend # Next.js client
├── backend # Express server
└── README.md

### Prerequisites
* Nodejs
* PostreSQL
* Docker

- Nodejs
- PostreSQL
- Docker

### Installation

Expand All @@ -85,9 +84,60 @@ This project aims to develop a volunteer management system for Lagos Food Bank I

> Note: See individual project files for more information on how to build and deploy the project.

## Contributors

### Spring 2024

- Leads
- Akinfolami Akin-Alamu
- Jason Zheng
- Developers
- Arushi Aggarwal
- Owen Chen
- Hubert He
- Trung-Nghia Le
- Brandon Lerit
- Diego Marques
- Tanvi Mavani
- David Valarezo

### Fall 2023

- Leads
- Akinfolami Akin-Alamu
- Jason Zheng
- Developers
- Sneha Rajaraman
- Daniel Thorne
- Louis Valencia
- Sophie Wang
- Yichen Yao
- Hannah Zhang
- Designers
- Ella Keen Allee
- Bella Besuud
- Mika Labadan

### Spring 2023

- Leads
- Akinfolami Akin-Alamu
- Jason Zheng
- Developers
- Jiayi Bai
- Daniel Botros
- Sneha Rajaraman
- Sophie Wang
- Yichen Yao
- Hannah Zhang
- Designers
- Bella Besuud
- Mika Labadan
- Julia Papp

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->

[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
[Next-url]: https://nextjs.org/
[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
Expand All @@ -96,4 +146,3 @@ This project aims to develop a volunteer management system for Lagos Food Bank I
[Express.js]: https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB
[Express-url]: https://expressjs.com/
[Prisma-url]: https://www.prisma.io/

39 changes: 24 additions & 15 deletions backend/src/events/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,14 @@ const addAttendee = async (eventID: string, userID: string) => {
eventLocation,
textBody
);
await sendEmail(
userEmail,
"Your registration was successful.",
updatedHtml
);
const userPreferences = await userController.getUserPreferences(userID);
if (userPreferences?.preferences?.sendEmailNotification === true) {
await sendEmail(
userEmail,
"Your registration was successful.",
updatedHtml
);
}
}
if (eventIsInThePast) {
return Promise.reject("Event is past, cannot enroll new user");
Expand Down Expand Up @@ -425,11 +428,14 @@ const deleteAttendee = async (
eventLocation,
textBody
);
await sendEmail(
userEmail,
"Your event cancellation was successful.",
updatedHtml
);
const userPreferences = await userController.getUserPreferences(userID);
if (userPreferences?.preferences?.sendEmailNotification === true) {
await sendEmail(
userEmail,
"Your event cancellation was successful.",
updatedHtml
);
}
}

// update db
Expand Down Expand Up @@ -511,11 +517,14 @@ const confirmUser = async (eventID: string, userID: string) => {
eventLocation,
textBody
);
await sendEmail(
userEmail,
"Your attendance has been confirmed",
updatedHtml
);
const userPreferences = await userController.getUserPreferences(userID);
if (userPreferences?.preferences?.sendEmailNotification === true) {
await sendEmail(
userEmail,
"Your attendance has been confirmed",
updatedHtml
);
}
}

return await prisma.eventEnrollment.update({
Expand Down
32 changes: 18 additions & 14 deletions backend/src/users/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const getUsers = async (
},
include: {
profile: true,
preferences: true,
events: eventId
? {
where: {
Expand Down Expand Up @@ -605,20 +606,23 @@ const editRole = async (userId: string, role: string) => {
var textBodyVS = "Your role has changed from volunteer to supervisor.";

if (process.env.NODE_ENV != "test") {
if (prevUserRole === "SUPERVISOR" && role === "ADMIN") {
const updatedHtml = replaceUserInputs(
stringUserUpdate,
userName,
textBodySA
);
await sendEmail(userEmail, "Your email subject", updatedHtml);
} else if (prevUserRole === "VOLUNTEER" && role === "SUPERVISOR") {
const updatedHtml = replaceUserInputs(
stringUserUpdate,
userName,
textBodyVS
);
await sendEmail(userEmail, "Your role has changed.", updatedHtml);
const userPreferences = await userController.getUserPreferences(userId);
if (userPreferences?.preferences?.sendEmailNotification === true) {
if (prevUserRole === "SUPERVISOR" && role === "ADMIN") {
const updatedHtml = replaceUserInputs(
stringUserUpdate,
userName,
textBodySA
);
await sendEmail(userEmail, "Your email subject", updatedHtml);
} else if (prevUserRole === "VOLUNTEER" && role === "SUPERVISOR") {
const updatedHtml = replaceUserInputs(
stringUserUpdate,
userName,
textBodyVS
);
await sendEmail(userEmail, "Your role has changed.", updatedHtml);
}
}
}
return prisma.user.update({
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/atoms/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React, { ReactNode, forwardRef, Ref } from "react";
import MuiAlert from "@mui/material/Alert";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import CancelIcon from "@mui/icons-material/Cancel";
import ErrorIcon from "@mui/icons-material/Error";

interface AlertProps {
children: ReactNode;
variety: "success" | "error";
variety: "success" | "error" | "warning";
onClose: () => void;
[key: string]: any;
}
Expand All @@ -28,6 +29,9 @@ const Alert = forwardRef(
bgcolor = "error.light";
icon = <CancelIcon color="error" fontSize="inherit" />;
break;
case "warning":
bgcolor = "warning.light";
icon = <ErrorIcon color="warning" fontSize="inherit" />;
}

return (
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/atoms/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CircularProgress from "@mui/material/CircularProgress";
interface ButtonProps {
children: ReactNode;
icon?: ReactNode;
variety?: "primary" | "secondary" | "tertiary" | "error";
variety?: "primary" | "secondary" | "tertiary" | "error" | "mainError";
size?: "small" | "medium";
loading?: boolean;
[key: string]: any;
Expand Down Expand Up @@ -53,6 +53,9 @@ const Button = ({
variant = "outlined";
color = "error";
break;
case "mainError":
variant = "contained";
color = "error";
}

return (
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/components/organisms/EventCardNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ViewEventsEvent } from "@/utils/types";
import { format } from "date-fns";
import Link from "next/link";
import { displayDateInfo } from "@/utils/helpers";
import Chip from "../atoms/Chip";

interface EventCardNewProps {
event: ViewEventsEvent;
Expand All @@ -18,7 +19,12 @@ const EventCardContent = ({ event }: EventCardNewProps) => {
const formattedEndTime = format(new Date(event.endDate), "hh:mm a");
const timeRange = `${formattedStartTime} - ${formattedEndTime}`;
const date = new Date(event.startDate);
const dateInfo = displayDateInfo(date);
const dateInfo =
event.status === "CANCELED" ? (
<Chip size="small" label="Canceled" color="error" />
) : (
displayDateInfo(date)
);
const url =
event.role === "Supervisor"
? `/events/${event.id}/attendees`
Expand All @@ -29,7 +35,11 @@ const EventCardContent = ({ event }: EventCardNewProps) => {
return (
<div>
<div className="flex flex-row gap-4">
<div className="font-semibold text-orange-500">
<div
className={`font-semibold ${
event.status === "CANCELED" ? "text-red-600" : "text-orange-500"
}`}
>
<IconText icon={<FiberManualRecordIcon className="text-xs" />}>
{dateInfo}
</IconText>
Expand Down
Loading

0 comments on commit 186cbd1

Please sign in to comment.