Skip to content

Commit 785915a

Browse files
Merge pull request #4755 from OneCommunityGlobal/Akshith-fuzzy-search-activities
Akshith - Added typo tolerance through fuzzy search
2 parents 3524523 + cc0816c commit 785915a

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/components/CommunityPortal/Activities/ActivityList.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useState, useEffect, useMemo } from 'react';
33
import { useSelector, useStore } from 'react-redux';
44
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
55
import styles from './ActivityList.module.css';
6+
// import { useHistory } from 'react-router-dom';
7+
import { fuzzySearch } from '../../../utils/fuzzySearch';
68
import { mockActivities } from './mockActivities';
79

810
function ActivityList() {
@@ -106,15 +108,15 @@ function ActivityList() {
106108
.filter(activity => showPastEvents || activity._dateObj >= startOfToday)
107109
.filter(activity => {
108110
return (
109-
(!filter.type || activity.type === filter.type) &&
111+
(!filter.type || fuzzySearch(activity.type, filter.type, 0.5)) &&
110112
(!filter.date || activity.date === filter.date) &&
111-
(!filter.location ||
112-
activity.location.toLowerCase().startsWith(filter.location.toLowerCase()))
113+
(!filter.location || fuzzySearch(activity.location, filter.location, 0.5))
113114
);
114115
})
115116
.sort((a, b) => {
116117
const dateA = new Date(a.date);
117118
const dateB = new Date(b.date);
119+
118120
return sortOrder === 'earliest' ? dateA - dateB : dateB - dateA;
119121
});
120122

src/routes.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,11 @@ export default (
889889
exact
890890
component={EventParticipation}
891891
/>
892+
<CPProtectedRoute
893+
path="/communityportal/reports/participation"
894+
exact
895+
component={EventParticipation}
896+
/>
892897
<CPProtectedRoute
893898
path="/communityportal/reports/event/personalization"
894899
exact

0 commit comments

Comments
 (0)