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:
Norbert Maciaszek
2025-08-15 15:20:04 +02:00
parent 3a7669e26d
commit 7373d64123
6 changed files with 73 additions and 17 deletions

View File

@@ -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>