Skip to content

Commit

Permalink
Merge pull request #59 from ChangePlusPlusVandy/searchbar-fixes
Browse files Browse the repository at this point in the history
implement case-insensitive search functionality + fixed filters
  • Loading branch information
JiashuHarryHuang authored Nov 9, 2023
2 parents 619c398 + cb0897b commit b5ecdd6
Show file tree
Hide file tree
Showing 5 changed files with 5,962 additions and 11,468 deletions.
21 changes: 0 additions & 21 deletions .env.local.template

This file was deleted.

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

1 comment on commit b5ecdd6

@vercel
Copy link

@vercel vercel bot commented on b5ecdd6 Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bookem-user – ./

bookem-user-bookem.vercel.app
bookem-user-git-main-bookem.vercel.app
bookem-user-old.vercel.app

Please sign in to comment.