Remove categories and sorting options from the video search filters
Removes category/sort selection from UI and `/api/videos`, updates `getVideos`/`getVideoCount` in `storage.ts`, and removes `/api/categories` route. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aa92e7e2-ec62-4c92-b21b-02ef78a664c2 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/aa92e7e2-ec62-4c92-b21b-02ef78a664c2/Cz5fe6k
This commit is contained in:
@@ -12,25 +12,16 @@ interface VideosResponse {
|
||||
|
||||
export default function Home() {
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [selectedCategory, setSelectedCategory] = useState("All Categories");
|
||||
const [sortBy, setSortBy] = useState("latest");
|
||||
const [viewMode, setViewMode] = useState<"grid" | "list">("grid");
|
||||
const [offset, setOffset] = useState(0);
|
||||
const [allVideos, setAllVideos] = useState<Video[]>([]);
|
||||
|
||||
// Fetch categories
|
||||
const { data: categories = [] } = useQuery<string[]>({
|
||||
queryKey: ["/api/categories"],
|
||||
});
|
||||
|
||||
// Fetch videos
|
||||
const { data: videosResponse, isLoading, refetch } = useQuery<VideosResponse>({
|
||||
queryKey: ["/api/videos", {
|
||||
limit: 20,
|
||||
offset,
|
||||
search: searchQuery || undefined,
|
||||
category: selectedCategory !== "All Categories" ? selectedCategory : undefined,
|
||||
sort: sortBy
|
||||
search: searchQuery || undefined
|
||||
}],
|
||||
queryFn: async ({ queryKey }) => {
|
||||
const [, params] = queryKey as [string, any];
|
||||
@@ -61,42 +52,27 @@ export default function Home() {
|
||||
}
|
||||
}, [videosResponse, offset]);
|
||||
|
||||
// Reset videos when search/filter changes
|
||||
// Reset videos when search changes
|
||||
const handleSearch = (query: string) => {
|
||||
setSearchQuery(query);
|
||||
setOffset(0);
|
||||
setAllVideos([]);
|
||||
};
|
||||
|
||||
const handleCategoryChange = (category: string) => {
|
||||
setSelectedCategory(category);
|
||||
setOffset(0);
|
||||
setAllVideos([]);
|
||||
};
|
||||
|
||||
const handleSortChange = (sort: string) => {
|
||||
setSortBy(sort);
|
||||
setOffset(0);
|
||||
setAllVideos([]);
|
||||
};
|
||||
|
||||
const handleLoadMore = () => {
|
||||
setOffset(prev => prev + 20);
|
||||
};
|
||||
|
||||
// Force refetch when filters change
|
||||
// Force refetch when search changes
|
||||
useEffect(() => {
|
||||
refetch();
|
||||
}, [searchQuery, selectedCategory, sortBy, offset, refetch]);
|
||||
}, [searchQuery, offset, refetch]);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-bunny-dark">
|
||||
<SearchHeader
|
||||
onSearch={handleSearch}
|
||||
onCategoryChange={handleCategoryChange}
|
||||
onSortChange={handleSortChange}
|
||||
onViewChange={setViewMode}
|
||||
categories={categories}
|
||||
currentView={viewMode}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user