Improve search functionality and update image links
Refactors navigation to use wouter for single-page application behavior, resolving issues with search query parsing and duplicate declarations. Updates image URLs in `gallery-data.json`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 3d4c4d6f-16fc-4faa-8264-303195c3f560 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/jdAEdU5 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
5ba9717fec
commit
a466452e2a
@ -29,11 +29,11 @@ export default function Header() {
|
||||
const handleSearch = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (searchQuery.trim().length >= 2) {
|
||||
const url = `/search?q=${encodeURIComponent(searchQuery.trim())}`;
|
||||
const q = encodeURIComponent(searchQuery.trim());
|
||||
setSearchOpen(false);
|
||||
setSearchQuery("");
|
||||
setMobileOpen(false);
|
||||
window.location.href = url;
|
||||
navigate(`/search?q=${q}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { useLocation } from "wouter";
|
||||
import { Link } from "wouter";
|
||||
import { Link, useSearch } from "wouter";
|
||||
import { Search, Play, FileText, ArrowLeft } from "lucide-react";
|
||||
import Header from "@/components/header";
|
||||
|
||||
@ -26,19 +25,19 @@ interface SearchResult {
|
||||
}
|
||||
|
||||
export default function SearchPage() {
|
||||
const qs = typeof window !== "undefined" ? window.location.search : "";
|
||||
const initialQuery = new URLSearchParams(qs).get("q") || "";
|
||||
const searchString = useSearch();
|
||||
const initialQuery = new URLSearchParams(searchString).get("q") || "";
|
||||
const [query, setQuery] = useState(initialQuery);
|
||||
const [searchTerm, setSearchTerm] = useState(initialQuery);
|
||||
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const q = new URLSearchParams(window.location.search).get("q") || "";
|
||||
const q = new URLSearchParams(searchString).get("q") || "";
|
||||
if (q && q !== searchTerm) {
|
||||
setQuery(q);
|
||||
setSearchTerm(q);
|
||||
}
|
||||
}, [qs]);
|
||||
}, [searchString]);
|
||||
|
||||
const handleQueryChange = (val: string) => {
|
||||
setQuery(val);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user