Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement case-insensitive search functionality + fixed filters #59

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading