simplificando app

This commit is contained in:
2026-06-18 17:13:24 +02:00
parent cdf2893b94
commit f977925880
16 changed files with 82 additions and 614 deletions
+5 -36
View File
@@ -1,6 +1,6 @@
"use client";
import { useEffect, useState } from "react";
import { useState } from "react";
import { SearchBar } from "@/components/SearchBar";
import { MovieHeader } from "@/components/MovieHeader";
import { MovieInsightPanel } from "@/components/MovieInsightPanel";
@@ -16,33 +16,6 @@ export default function HomePage() {
const [isLoadingMovie, setIsLoadingMovie] = useState(false);
const [movieError, setMovieError] = useState<string | null>(null);
// Preload a random interesting movie on initial page load to demonstrate the app
useEffect(() => {
const DEMO_IDS = [27205, 157336, 155, 550, 496243, 424]; // Inception, Interstellar, Dark Knight, Fight Club, Parasite, Schindler's List
const loadDemo = async () => {
const id = DEMO_IDS[Math.floor(Math.random() * DEMO_IDS.length)];
try {
const res = await fetch(`/api/movie/${id}`);
if (!res.ok) return;
const details: TmdbMovieDetails = await res.json();
const minimalSearch: TmdbSearchResult = {
id: details.id,
title: details.title,
release_date: details.release_date || "",
poster_path: details.poster_path,
overview: details.overview || "",
};
setSelectedMovie(minimalSearch);
setMovieDetails(details);
} catch {
// silently fall back to empty state if demo preload fails
}
};
if (!selectedMovie) {
void loadDemo();
}
}, []);
const handleSelect = async (movie: TmdbSearchResult) => {
setSelectedMovie(movie);
setMovieDetails(null);
@@ -77,7 +50,7 @@ export default function HomePage() {
Film Intel
</span>
<span className="hidden truncate text-xs text-stone-500 sm:inline">
Movie insight you won&apos;t find in one click
Reliable film ratings, explained
</span>
</div>
@@ -95,9 +68,8 @@ export default function HomePage() {
{!selectedMovie && (
<div className="flex flex-col items-center justify-center py-16 text-center">
<p className="max-w-md text-sm text-stone-600">
Search for any film using the bar above. We&apos;ll generate
ratings explained, skip guides, sensitivity warnings, production
facts, and more.
Search for any film using the bar above. We&apos;ll explain its
age rating and how it differs across countries.
</p>
</div>
)}
@@ -136,10 +108,7 @@ export default function HomePage() {
</div>
)}
<MovieInsightPanel
movieId={selectedMovie.id}
genres={movieDetails?.genres.map((g) => g.name) ?? []}
/>
<MovieInsightPanel movieId={selectedMovie.id} />
</div>
)}
</main>