Spaces:
Running
Running
gpt-engineer-app[bot]
commited on
Commit
·
6decbb1
1
Parent(s):
bfd3ad3
Filter conferences by deadline
Browse filesAdded a toggle to show past conferences and made it so that only upcoming conferences are shown by default.
- src/pages/Index.tsx +33 -6
src/pages/Index.tsx
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
|
|
| 1 |
import Header from "@/components/Header";
|
| 2 |
import FilterBar from "@/components/FilterBar";
|
| 3 |
import ConferenceCard from "@/components/ConferenceCard";
|
| 4 |
import conferencesData from "@/data/conferences.yml";
|
| 5 |
import { Conference } from "@/types/conference";
|
| 6 |
import { useState, useMemo, useEffect } from "react";
|
|
|
|
|
|
|
| 7 |
|
| 8 |
const Index = () => {
|
| 9 |
const [selectedTag, setSelectedTag] = useState("All");
|
| 10 |
const [searchQuery, setSearchQuery] = useState("");
|
|
|
|
| 11 |
|
| 12 |
// Add debug logging
|
| 13 |
useEffect(() => {
|
|
@@ -22,16 +26,25 @@ const Index = () => {
|
|
| 22 |
|
| 23 |
return conferencesData
|
| 24 |
.filter((conf: Conference) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
const matchesTag = selectedTag === "All" || conf.tags.includes(selectedTag);
|
| 26 |
const matchesSearch = searchQuery === "" ||
|
| 27 |
conf.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
| 28 |
(conf.full_name && conf.full_name.toLowerCase().includes(searchQuery.toLowerCase()));
|
|
|
|
| 29 |
return matchesTag && matchesSearch;
|
| 30 |
})
|
| 31 |
-
.sort((a: Conference, b: Conference) =>
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
|
| 36 |
// Add debug logging for filtered conferences
|
| 37 |
useEffect(() => {
|
|
@@ -44,8 +57,22 @@ const Index = () => {
|
|
| 44 |
|
| 45 |
return (
|
| 46 |
<div className="min-h-screen bg-neutral-light">
|
| 47 |
-
<Header
|
| 48 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 50 |
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 51 |
{filteredConferences.map((conference: Conference) => (
|
|
|
|
| 1 |
+
|
| 2 |
import Header from "@/components/Header";
|
| 3 |
import FilterBar from "@/components/FilterBar";
|
| 4 |
import ConferenceCard from "@/components/ConferenceCard";
|
| 5 |
import conferencesData from "@/data/conferences.yml";
|
| 6 |
import { Conference } from "@/types/conference";
|
| 7 |
import { useState, useMemo, useEffect } from "react";
|
| 8 |
+
import { Switch } from "@/components/ui/switch"
|
| 9 |
+
import { parseISO, isValid, isPast } from "date-fns";
|
| 10 |
|
| 11 |
const Index = () => {
|
| 12 |
const [selectedTag, setSelectedTag] = useState("All");
|
| 13 |
const [searchQuery, setSearchQuery] = useState("");
|
| 14 |
+
const [showPastConferences, setShowPastConferences] = useState(false);
|
| 15 |
|
| 16 |
// Add debug logging
|
| 17 |
useEffect(() => {
|
|
|
|
| 26 |
|
| 27 |
return conferencesData
|
| 28 |
.filter((conf: Conference) => {
|
| 29 |
+
// Filter by deadline (past/future)
|
| 30 |
+
const deadlineDate = conf.deadline && conf.deadline !== 'TBD' ? parseISO(conf.deadline) : null;
|
| 31 |
+
const isUpcoming = !deadlineDate || !isValid(deadlineDate) || !isPast(deadlineDate);
|
| 32 |
+
if (!showPastConferences && !isUpcoming) return false;
|
| 33 |
+
|
| 34 |
+
// Filter by tag and search query
|
| 35 |
const matchesTag = selectedTag === "All" || conf.tags.includes(selectedTag);
|
| 36 |
const matchesSearch = searchQuery === "" ||
|
| 37 |
conf.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
| 38 |
(conf.full_name && conf.full_name.toLowerCase().includes(searchQuery.toLowerCase()));
|
| 39 |
+
|
| 40 |
return matchesTag && matchesSearch;
|
| 41 |
})
|
| 42 |
+
.sort((a: Conference, b: Conference) => {
|
| 43 |
+
const dateA = a.deadline && a.deadline !== 'TBD' ? parseISO(a.deadline).getTime() : Infinity;
|
| 44 |
+
const dateB = b.deadline && b.deadline !== 'TBD' ? parseISO(b.deadline).getTime() : Infinity;
|
| 45 |
+
return dateA - dateB;
|
| 46 |
+
});
|
| 47 |
+
}, [selectedTag, searchQuery, showPastConferences]);
|
| 48 |
|
| 49 |
// Add debug logging for filtered conferences
|
| 50 |
useEffect(() => {
|
|
|
|
| 57 |
|
| 58 |
return (
|
| 59 |
<div className="min-h-screen bg-neutral-light">
|
| 60 |
+
<Header />
|
| 61 |
+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
| 62 |
+
<div className="flex items-center justify-between py-4">
|
| 63 |
+
<FilterBar selectedTag={selectedTag} onTagSelect={setSelectedTag} />
|
| 64 |
+
<div className="flex items-center gap-2">
|
| 65 |
+
<label htmlFor="show-past" className="text-sm text-neutral-600">
|
| 66 |
+
Show past conferences
|
| 67 |
+
</label>
|
| 68 |
+
<Switch
|
| 69 |
+
id="show-past"
|
| 70 |
+
checked={showPastConferences}
|
| 71 |
+
onCheckedChange={setShowPastConferences}
|
| 72 |
+
/>
|
| 73 |
+
</div>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
| 77 |
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 78 |
{filteredConferences.map((conference: Conference) => (
|