Skip to content

Commit

Permalink
implement case-insensitive search functionality + fixed filters
Browse files Browse the repository at this point in the history
  • Loading branch information
teguono committed Nov 6, 2023
1 parent 619c398 commit a4215d2
Show file tree
Hide file tree
Showing 6 changed files with 5,954 additions and 11,466 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
8 changes: 5 additions & 3 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 @@ -71,15 +72,16 @@ const FutureVolunteerEvents = () => {
const sortMostRecent = () => {
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 = () => {
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 +140,7 @@ 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 a4215d2

Please sign in to comment.