diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/search/SearchResults.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/search/SearchResults.tsx deleted file mode 100644 index ad397589a7..0000000000 --- a/autogpt_platform/frontend/src/app/(platform)/marketplace/search/SearchResults.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { unstable_cache } from "next/cache"; -import { - getV2ListStoreAgents, - getV2ListStoreCreators, -} from "@/app/api/__generated__/endpoints/store/store"; -import { SearchResultsClient } from "./SearchResultsClient"; -import { StoreAgent, Creator } from "@/lib/autogpt-server-api"; - -// Cache the search results for 10 minutes based on search term and sort -const getCachedSearchResults = unstable_cache( - async (searchTerm: string, sort: string) => { - try { - const [agentsRes, creatorsRes] = await Promise.all([ - getV2ListStoreAgents({ - search_query: searchTerm, - sorted_by: sort, - }), - getV2ListStoreCreators({ - search_query: searchTerm, - }), - ]); - - return { - agents: ("agents" in agentsRes.data - ? agentsRes.data.agents || [] - : []) as StoreAgent[], - creators: ("creators" in creatorsRes.data - ? creatorsRes.data.creators || [] - : []) as Creator[], - }; - } catch (error) { - console.error("Error fetching search results:", error); - return { - agents: [] as StoreAgent[], - creators: [] as Creator[], - }; - } - }, - ["marketplace-search"], // Cache key prefix - { - revalidate: 600, // 10 minutes - tags: ["marketplace-search"], - }, -); - -export async function SearchResults({ - searchTerm, - sort, -}: { - searchTerm: string; - sort: string; -}) { - const { agents, creators } = await getCachedSearchResults(searchTerm, sort); - - const agentsCount = agents.length; - const creatorsCount = creators.length; - const totalCount = agentsCount + creatorsCount; - - if (totalCount === 0) { - return ( -
-

- No results found -

-

- Try adjusting your search terms or filters -

-
- ); - } - - return ( - - ); -} diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/search/SearchResultsClient.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/search/SearchResultsClient.tsx deleted file mode 100644 index cd49785f2c..0000000000 --- a/autogpt_platform/frontend/src/app/(platform)/marketplace/search/SearchResultsClient.tsx +++ /dev/null @@ -1,117 +0,0 @@ -"use client"; - -import { useState, useCallback } from "react"; -import { AgentsSection } from "@/components/agptui/composite/AgentsSection"; -import { FeaturedCreators } from "@/components/agptui/composite/FeaturedCreators"; -import { Separator } from "@/components/ui/separator"; -import { SearchFilterChips } from "@/components/agptui/SearchFilterChips"; -import { SortDropdown } from "@/components/agptui/SortDropdown"; -import { Creator, StoreAgent } from "@/lib/autogpt-server-api"; -import { useRouter, useSearchParams } from "next/navigation"; - -export function SearchResultsClient({ - initialAgents, - initialCreators, - agentsCount, - creatorsCount, - totalCount, -}: { - initialAgents: StoreAgent[]; - initialCreators: Creator[]; - agentsCount: number; - creatorsCount: number; - totalCount: number; -}) { - const [showAgents, setShowAgents] = useState(true); - const [showCreators, setShowCreators] = useState(true); - const [agents, setAgents] = useState(initialAgents); - const [creators, setCreators] = useState(initialCreators); - const router = useRouter(); - const searchParams = useSearchParams(); - - const handleFilterChange = (value: string) => { - if (value === "agents") { - setShowAgents(true); - setShowCreators(false); - } else if (value === "creators") { - setShowAgents(false); - setShowCreators(true); - } else { - setShowAgents(true); - setShowCreators(true); - } - }; - - const handleSortChange = useCallback( - (sortValue: string) => { - // Update URL with new sort parameter to trigger server-side re-fetch - const params = new URLSearchParams(searchParams.toString()); - params.set("sort", sortValue); - router.push(`/marketplace/search?${params.toString()}`); - - // Client-side sorting for immediate feedback - let sortBy = "recent"; - if (sortValue === "runs") { - sortBy = "runs"; - } else if (sortValue === "rating") { - sortBy = "rating"; - } - - const sortedAgents = [...agents].sort((a, b) => { - if (sortBy === "runs") { - return b.runs - a.runs; - } else if (sortBy === "rating") { - return b.rating - a.rating; - } else { - return ( - new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime() - ); - } - }); - - const sortedCreators = [...creators].sort((a, b) => { - if (sortBy === "runs") { - return b.agent_runs - a.agent_runs; - } else if (sortBy === "rating") { - return b.agent_rating - a.agent_rating; - } else { - // Creators don't have updated_at, sort by number of agents as fallback - return b.num_agents - a.num_agents; - } - }); - - setAgents(sortedAgents); - setCreators(sortedCreators); - }, - [agents, creators, router, searchParams], - ); - - return ( - <> -
- - -
- {/* Content section */} -
- {showAgents && agentsCount > 0 && ( -
- -
- )} - - {showAgents && agentsCount > 0 && creatorsCount > 0 && showCreators && ( - - )} - {showCreators && creatorsCount > 0 && ( - - )} -
- - ); -}