diff --git a/src/app/(investment)/deals/page.tsx b/src/app/(investment)/deals/page.tsx index 799cad4..519205c 100644 --- a/src/app/(investment)/deals/page.tsx +++ b/src/app/(investment)/deals/page.tsx @@ -1,11 +1,11 @@ "use client"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Clock3Icon, UserIcon, UsersIcon } from "lucide-react"; import { Separator } from "@/components/ui/separator"; import { ProjectCard } from "@/components/projectCard"; -import { getAllTagsQuery, getALlFundedStatusQuery, getAllBusinessTypeQuery } from "@/lib/data/dropdownQuery"; +import { getALlFundedStatusQuery, getAllBusinessTypeQuery } from "@/lib/data/dropdownQuery"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; import { useQuery } from "@supabase-cache-helpers/postgrest-react-query"; import { searchProjectsQuery, FilterParams, FilterProjectQueryParams } from "@/lib/data/projectQuery"; @@ -13,7 +13,29 @@ import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import Link from "next/link"; -const ProjectSection = ({ filteredProjects }) => { +interface Project { + project_id: string; + project_name: string; + published_time: string; + project_short_description: string; + card_image_url: string; + project_status: { + value: string; + }; + min_investment: number; + total_investment: number; + target_investment: number; + investment_deadline: string; + tags: { + tag_name: string; + }[]; + business_type: { + value: string; + }; + business_location: string; +} + +const ProjectSection = ({ filteredProjects }: { filteredProjects: Project[] }) => { interface Tags { tag_name: string; } @@ -117,7 +139,7 @@ export default function Deals() { const [sortByTimeFilter, setSortByTimeFilter] = useState("all"); const [businessTypeFilter, setBusinessTypeFilter] = useState("all"); const [tagFilter, setTagFilter] = useState([]); - const [projectStatusFilter, setprojectStatusFilter] = useState("all"); + const [projectStatusFilter, setProjectStatusFilter] = useState("all"); const [page, setPage] = useState(1); const [pageSize, setPageSize] = useState(4); @@ -139,7 +161,6 @@ export default function Deals() { pageSize, }; - const { data: tags, isLoading: isLoadingTags, error: tagsLoadingError } = useQuery(getAllTagsQuery(supabase)); const { data: projectStatus, isLoading: isLoadingFunded, @@ -160,11 +181,20 @@ export default function Deals() { const clearAll = () => { setSearchTerm(""); setTagFilter([]); - setprojectStatusFilter("all"); + setProjectStatusFilter("all"); setBusinessTypeFilter("all"); setSortByTimeFilter("all"); }; + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + + useEffect(() => { + setSearchTerm(searchTermVisual); + }, [searchTermVisual]); + return (
@@ -175,8 +205,7 @@ export default function Deals() { All companies are vetted & pass due diligence.

- {/* {JSON.stringify(projects, null, 4)} */} - + {/* Search Input and Filters */}
{/* Business Type Filter */} - setBusinessTypeFilter(value)}> @@ -234,7 +263,7 @@ export default function Deals() { {/* Project Status Filter */} - setProjectStatusFilter(key)}> @@ -262,11 +291,54 @@ export default function Deals() {
+ + {/* Active Filters */} {/* Project Cards Section */} - + {isLoadingProjects ? ( +
Loading...
+ ) : projectsLoadingError ? ( +
Error loading projects.
+ ) : projects ? ( + + ) : ( +
No projects found!
+ )} + {/* Pagination Controls */} +
+ + +
+ Page Size: + +
+ + +
);