Implement loading spinner and Polish translations: add Spinner component for loading states in Search and SearchList, update UI text to Polish for improved localization, and enhance Pagination styles for better visibility.
This commit is contained in:
@@ -9,18 +9,20 @@ import { useRef } from "react";
|
||||
import { useOutsideClick } from "@/hooks/useOutsideClick";
|
||||
import { Button } from "@/components/atoms/Button";
|
||||
import { MovieList } from "@/components/molecules/MovieList";
|
||||
import { Spinner } from "@/components/atoms/Spinner";
|
||||
|
||||
export const Search = () => {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||
const [response, setResponse] = useState<SearchResult | null>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const isLoading = query.length > 2 && !response;
|
||||
const { results, total_pages, total_results = 0 } = response ?? {};
|
||||
|
||||
const handleSearch = async (query: string) => {
|
||||
setQuery(query);
|
||||
setResponse(null);
|
||||
if (query.length < 3) {
|
||||
setResponse(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,6 +67,11 @@ export const Search = () => {
|
||||
autoFocus={true}
|
||||
/>
|
||||
</div>
|
||||
{isLoading && (
|
||||
<div className="col-span-full mt-2 lg:mt-30 text-center ">
|
||||
<Spinner />
|
||||
</div>
|
||||
)}
|
||||
{results && (
|
||||
<div className="col-span-full mt-2 lg:mt-10 text-center ">
|
||||
<p className="text-white">{total_results} movies found</p>
|
||||
|
||||
Reference in New Issue
Block a user