Skip to content

Commit

Permalink
Merge branch 'main' into dashboard-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JiashuHarryHuang committed Nov 15, 2023
2 parents e74a4ca + c51eca8 commit f32c6fe
Show file tree
Hide file tree
Showing 19 changed files with 417 additions and 273 deletions.
5 changes: 4 additions & 1 deletion components/Event/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EVENT_CONTACT_ICON_HEIGHT,
} from '@/utils/constants';
import { Media } from '@/lib/media';
import Link from 'next/link';

/**
* Contain Contact info
Expand Down Expand Up @@ -42,7 +43,9 @@ const Contact = ({ phone, email }: { phone: string; email: string }) => (
width={EVENT_CONTACT_ICON_WIDTH}
height={EVENT_CONTACT_ICON_HEIGHT}
/>
<IconText>{email}</IconText>
<IconText>
<Link href={'mailto:' + email}>{email}</Link>
</IconText>
</IconBox>
</BigIconBox>
</ContactBox>
Expand Down
4 changes: 2 additions & 2 deletions components/Event/Event.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueriedVolunteerEventData } from 'bookem-shared/src/types/database';
import { QueriedVolunteerEventDTO } from 'bookem-shared/src/types/database';
import React, { useState } from 'react';
import Header from '@/components/Event/Header';
import BookIcon from '@/components/Event/BookIcon';
Expand All @@ -21,7 +21,7 @@ import { BOOKEM_THEME } from '@/utils/constants';
* Event Detail
* @param event Data about the event
*/
const Event = ({ event }: { event: QueriedVolunteerEventData }) => {
const Event = ({ event }: { event: QueriedVolunteerEventDTO }) => {
/**
* True: display About
* False: display Contact
Expand Down
10 changes: 5 additions & 5 deletions components/Event/EventName.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueriedVolunteerEventData } from 'bookem-shared/src/types/database';
import { QueriedVolunteerEventDTO } from 'bookem-shared/src/types/database';
import React, { useEffect } from 'react';
import {
EventNameBox,
Expand All @@ -15,7 +15,7 @@ import Image from 'next/image';
* Calculate the length of the event volunteers
* If event.volunteers is undefined, return 0
*/
export const getEventLength = (event: QueriedVolunteerEventData) => {
export const getEventLength = (event: QueriedVolunteerEventDTO) => {
if (event.volunteers && event.volunteers.length)
return event.volunteers.length;
else return 0;
Expand All @@ -33,7 +33,7 @@ const EventName = ({
}: {
signedUp: boolean;
setSignedUp: (signedUp: boolean) => void;
event: QueriedVolunteerEventData;
event: QueriedVolunteerEventDTO;
signUpEvent: () => void;
}) => {
const { data: session } = useSession();
Expand All @@ -54,7 +54,7 @@ const EventName = ({
<Media greaterThanOrEqual="sm">
<NameAndSpot>
<b>{event.name}</b>
{event.tags.length > 0 && <p>({event.program.tagName})</p>}
{event.tags.length > 0 && <p>({event.program?.name})</p>}
<br />
{getEventLength(event)}/{event.maxSpot} spots filled
</NameAndSpot>
Expand All @@ -66,7 +66,7 @@ const EventName = ({
{/* Mobile */}
<Media lessThan="sm">
<NameAndSpot>
<b>{event.name}</b> <span>({event.program?.tagName}) </span>
<b>{event.name}</b> <span>({event.program?.name}) </span>
<br />
<StatusBox>
<Image src="/event/dot.svg" alt="" width={10} height={10} />
Expand Down
4 changes: 2 additions & 2 deletions components/Event/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignupButton } from '@/styles/components/Event/event.styles';
import { QueriedVolunteerEventData } from 'bookem-shared/src/types/database';
import { QueriedVolunteerEventDTO } from 'bookem-shared/src/types/database';
import { useSession } from 'next-auth/react';
import React, { useEffect } from 'react';
import { getEventLength } from '@/components/Event/EventName';
Expand All @@ -20,7 +20,7 @@ const Footer = ({
}: {
signedUp: boolean;
setSignedUp: (signedUp: boolean) => void;
event: QueriedVolunteerEventData;
event: QueriedVolunteerEventDTO;
signUpEvent: () => void;
}) => {
// Get user id in session
Expand Down
5 changes: 1 addition & 4 deletions components/Home/PastActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const dummyEventData: QueriedVolunteerEventData = {
},
phone: '123-456-7890',
email: '[email protected]',
program: {
_id: new mongoose.Types.ObjectId(),
tagName: 'BNFK',
},
program: new mongoose.Types.ObjectId(),
requireApplication: true,
volunteers: [],
tags: [],
Expand Down
4 changes: 2 additions & 2 deletions components/Volunteer/FilterEventsPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const FilterEventsPopup = ({
<>
<Background />
<Container ref={wrapperRef}>
<FilterText onClick={sortLeastRecent}>Most Recent</FilterText>
<FilterText onClick={sortMostRecent}>Least Recent</FilterText>
<FilterText onClick={sortMostRecent}>Most Recent</FilterText>
<FilterText onClick={sortLeastRecent}>Least Recent</FilterText>
<span />
<FilterText onClick={sortDescendingSpots}>Most Spots</FilterText>
<FilterText onClick={sortAscendingSpots}>Least Spots</FilterText>
Expand Down
19 changes: 14 additions & 5 deletions components/Volunteer/FutureVolunteerEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { fetchData } from '@/utils/utils';
import { Media } from '@/lib/media';
import LongEventCard from '../shared/LongEventCard';
import Link from 'next/link';
import { start } from 'repl';

const FutureVolunteerEvents = () => {
// Holds text in input box
Expand Down Expand Up @@ -68,18 +69,24 @@ const FutureVolunteerEvents = () => {
};

// Sorts events in order of most to least recent
const sortMostRecent = () => {
const sortLeastRecent = () => {
if (!events) return;
const copy = [...events];
copy.sort((a, b) => a.startDate.valueOf() - b.startDate.valueOf());
copy.sort(
(a, b) =>
new Date(b.startDate).valueOf() - new Date(a.startDate).valueOf()
);
setEvents(copy);
};

// Sorts events in order of least to most recent
const sortLeastRecent = () => {
const sortMostRecent = () => {
if (!events) return;
const copy = [...events];
copy.sort((b, a) => a.startDate.valueOf() - b.startDate.valueOf());
copy.sort(
(a, b) =>
new Date(a.startDate).valueOf() - new Date(b.startDate).valueOf()
);
setEvents(copy);
};

Expand Down Expand Up @@ -138,7 +145,9 @@ const FutureVolunteerEvents = () => {
{/* Container for events that show up based on query input */}
<ImagesWrapper>
{events
.filter(event => event.name.includes(query))
.filter(event =>
event.name.toLowerCase().includes(query.toLowerCase())
)
.map(event => (
<EventCard
key={event._id.toString()}
Expand Down
Loading

0 comments on commit f32c6fe

Please sign in to comment.