MCPcopy Create free account
hub / github.com/Iduoad/Mrrakc / ExplorerMap

Function ExplorerMap

web/src/components/react/ExplorerMap.tsx:15–226  ·  view source on GitHub ↗
({ allPoints, children, title, backUrl }: Props)

Source from the content-addressed store, hash-verified

13}
14
15export default function ExplorerMap({ allPoints, children, title, backUrl }: Props) {
16 const [searchQuery, setSearchQuery] = useState('');
17 const [isFilterOpen, setIsFilterOpen] = useState(false);
18 const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
19 const [selectedProvinces, setSelectedProvinces] = useState<string[]>([]);
20 const [selectedTimePeriods, setSelectedTimePeriods] = useState<string[]>([]);
21 const [selectedPeople, setSelectedPeople] = useState<string[]>([]);
22
23 // Extract available options from data
24 const options = useMemo(() => {
25 const categories = new Set<string>();
26 const provinces = new Set<string>();
27 const timePeriods = new Set<string>();
28 const people = new Set<string>();
29
30 allPoints.forEach(point => {
31 if (point.category) categories.add(point.category);
32 if (point.location.province) provinces.add(point.location.province);
33 point.timePeriods?.forEach(tp => timePeriods.add(tp));
34 point.people?.forEach(p => people.add(p.id)); // Using ID for now, could map to names
35 });
36
37 return {
38 categories: Array.from(categories).sort(),
39 provinces: Array.from(provinces).sort(),
40 timePeriods: Array.from(timePeriods).sort(),
41 people: Array.from(people).sort()
42 };
43 }, [allPoints]);
44
45 // Filter points
46 const filteredPoints = useMemo(() => {
47 return allPoints.filter(point => {
48 // Search
49 if (searchQuery) {
50 const query = searchQuery.toLowerCase();
51 const matchesSearch =
52 point.name.toLowerCase().includes(query) ||
53 point.description.toLowerCase().includes(query);
54 if (!matchesSearch) return false;
55 }
56
57 // Categories
58 if (selectedCategories.length > 0 && !selectedCategories.includes(point.category)) {
59 return false;
60 }
61
62 // Provinces
63 if (selectedProvinces.length > 0 && point.location.province && !selectedProvinces.includes(point.location.province)) {
64 return false;
65 }
66
67 // Time Periods
68 if (selectedTimePeriods.length > 0) {
69 const hasPeriod = point.timePeriods?.some(tp => selectedTimePeriods.includes(tp));
70 if (!hasPeriod) return false;
71 }
72

Callers

nothing calls this directly

Calls 1

toggleFilterFunction · 0.85

Tested by

no test coverage detected