diff --git a/app/page.tsx b/app/page.tsx index 48f2e02..1ee36b7 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,151 +1,69 @@ -import { Suspense } from "react"; import ExploreBtn from "@/components/ExploreBtn"; import EventCard from "@/components/EventCard"; -import SearchFilters from "@/components/SearchFilters"; -import Footer from "@/components/Footer"; -import RecommendedFeed from "@/components/RecommendedFeed"; +import SearchFilters from "@/components/SearchFilters"; // Added missing import +import Footer from "@/components/Footer"; // Added missing import import { IEvent } from "@/database"; -import { getAllEvents, getRecommendedEvents } from "@/lib/actions/event.actions"; +import { cacheLife } from "next/cache"; +import { getAllEvents } from "@/lib/actions/event.actions"; interface PageProps { searchParams: Promise<{ query?: string; mode?: string; tag?: string; - sortBy?: string; }>; } -export default async function Page({ searchParams }: PageProps) { - const resolvedSearchParams = await searchParams; +const Page = async ({ searchParams }: PageProps) => { + + // 1. Resolve search variables from the URL router interface + const resolvedParams = await searchParams; - const validSortBy = ["date_asc", "date_desc", "name_asc", "name_desc", "popularity"] as const; - type SortByType = (typeof validSortBy)[number]; - const rawSortBy = resolvedSearchParams.sortBy?.trim(); - const sortBy = validSortBy.includes(rawSortBy as SortByType) - ? (rawSortBy as SortByType) - : undefined; - - const filters = { - query: resolvedSearchParams.query?.trim() || undefined, - mode: resolvedSearchParams.mode?.trim() || undefined, - tag: resolvedSearchParams.tag?.trim() || undefined, - sortBy, - }; - - // 1. Fetch general events (no pagination on home — high limit to get all for category sections) - const { events } = await getAllEvents(filters, 1, 100); - - // 2. Target tags for recommendation - const userInterestedTags = ["Next.js", "React", "Frontend", "Hackathon"]; - - // 3. Fetch matching recommendations from the backend action - const recommendedEvents = await getRecommendedEvents(userInterestedTags); - - // Filters for individual categories - const hackathons = events.filter( - (event: IEvent) => event.tags?.includes("Hackathon") - ); - - const seminars = events.filter( - (event: IEvent) => event.tags?.includes("Seminar") - ); - - const internships = events.filter( - (event: IEvent) => event.tags?.includes("Internship") - ); - - const jobs = events.filter( - (event: IEvent) => event.tags?.includes("Job") - ); + // 2. Fixed Destructuring: Receives plain array directly from your updated action + const events = await getAllEvents({ + query: resolvedParams.query, + mode: resolvedParams.mode, + tag: resolvedParams.tag, + }); return (
-

- The Hub for Every Dev
Event You Can't Miss -

- -

- Hackathons, Meetups, and Conferences, All in One Place -

+

The Hub for Every Dev
Event You Can't Miss

+

Hackathons, Meetups, and Conferences, All in One Place

- {/* Live Production Recommendation Feed Banner */} - - + {/* 3. Insert the newly generated Search and Filter component bar */}
- }> - - +
- {events && events.length > 0 ? ( -
- - {/* Hackathons */} -
-

🔥 Hackathons

-
    - {hackathons.map((event: IEvent) => ( -
  • - -
  • - ))} -
-
- - {/* Seminars */} -
-

📚 Seminars

-
    - {seminars.map((event: IEvent) => ( -
  • - -
  • - ))} -
-
- - {/* Internships */} -
-

💼 Internships

-
    - {internships.map((event: IEvent) => ( -
  • - -
  • - ))} -
-
- - {/* Jobs */} -
-

🚀 Jobs

-
    - {jobs.map((event: IEvent) => ( -
  • - -
  • - ))} -
-
- -
- ) : ( -
-

- No events found -

- -

- We couldn't find any listings matching your search constraints. - Try checking your spelling or adjusting filters. -

-
- )} - +
+

Featured Events

+ + {/* 4. Display list layout conditionally or deliver clean placeholder states */} + {events && events.length > 0 ? ( +
    + {events.map((event: IEvent) => ( +
  • + +
  • + ))} +
+ ) : ( + /* Smooth Contextual Empty State displayed dynamically */ +
+

No events found

+ {/* Fixed Linting Error: Escaped the apostrophe here */} +

+ We couldn't find any listings matching your search constraints. Try checking your spelling or adjusting filters. +

+
+ )} +
- ); -} \ No newline at end of file + ) +} + +export default Page;