diff --git a/src/components/Home/FavoritesSection/FavoritesSection.tsx b/src/components/Home/FavoritesSection/FavoritesSection.tsx index f90f87be2..75114d38c 100644 --- a/src/components/Home/FavoritesSection/FavoritesSection.tsx +++ b/src/components/Home/FavoritesSection/FavoritesSection.tsx @@ -1,8 +1,17 @@ import { useNavigate } from "@tanstack/react-router"; -import { ChevronLeft, ChevronRight, GitBranch, Play, Star, X } from "lucide-react"; +import { + ChevronLeft, + ChevronRight, + GitBranch, + Play, + Star, + X, +} from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; +import { Icon } from "@/components/ui/icon"; +import { Input } from "@/components/ui/input"; import { InlineStack } from "@/components/ui/layout"; import { Paragraph, Text } from "@/components/ui/typography"; import { type FavoriteItem, useFavorites } from "@/hooks/useFavorites"; @@ -57,16 +66,32 @@ const FavoriteChip = ({ item }: { item: FavoriteItem }) => { export const FavoritesSection = () => { const { favorites } = useFavorites(); const [page, setPage] = useState(0); + const [query, setQuery] = useState(""); - const totalPages = Math.ceil(favorites.length / PAGE_SIZE); - // Reset to last valid page if favorites shrink (e.g. after removing items) + const filtered = query.trim() + ? favorites.filter((f) => { + const q = query.toLowerCase(); + return ( + f.id.toLowerCase().includes(q) || f.name.toLowerCase().includes(q) + ); + }) + : favorites; + + const totalPages = Math.ceil(filtered.length / PAGE_SIZE); + // Reset to last valid page if filtered results shrink const safePage = Math.min(page, Math.max(0, totalPages - 1)); - const paginated = favorites.slice(safePage * PAGE_SIZE, (safePage + 1) * PAGE_SIZE); + const paginated = filtered.slice( + safePage * PAGE_SIZE, + (safePage + 1) * PAGE_SIZE, + ); return (