diff --git a/bun.lockb b/bun.lockb index aa6a593..df4263a 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 9dbae8a..0f43654 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,27 @@ { - "name": "trepa-web", - "type": "module", - "version": "0.0.1", - "scripts": { - "dev": "bunx --bun astro dev", - "build": "rm -rf dist && bunx --bun astro check && bunx --bun astro build", - "preview": "bunx --bun astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/check": "^0.8.1", - "@astrojs/node": "^8.3.2", - "@astrojs/react": "^3.6.0", - "@types/react": "^18.3.3", - "@types/react-dom": "^18.3.0", - "astro": "^4.11.5", - "bootstrap": "^5.3.3", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-icons": "^5.2.1", - "typescript": "^5.5.3" - }, - "devDependencies": { - "@biomejs/biome": "1.8.3" - } + "name": "trepa-web", + "type": "module", + "version": "0.0.1", + "scripts": { + "dev": "bunx --bun astro dev", + "build": "rm -rf dist && bunx --bun astro check && bunx --bun astro build", + "preview": "bunx --bun astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/check": "^0.8.2", + "@astrojs/node": "^8.3.2", + "@astrojs/react": "^3.6.0", + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", + "astro": "^4.12.2", + "bootstrap": "^5.3.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-icons": "^5.2.1", + "typescript": "^5.5.4" + }, + "devDependencies": { + "@biomejs/biome": "1.8.3" + } } diff --git a/src/components/MoviesSearchInput.tsx b/src/components/MoviesSearchInput.tsx index eda929c..bd29c10 100644 --- a/src/components/MoviesSearchInput.tsx +++ b/src/components/MoviesSearchInput.tsx @@ -16,7 +16,7 @@ export default function MoviesSearchInput({ searchUrl }: MoviesSearchInput) { function handleOnKeyDown(e: React.KeyboardEvent) { if (e.key === "Enter") { - window.location.href = `${searchUrl}?q=${value}`; + window.location.href = `${searchUrl}?query=${value}`; } } diff --git a/src/components/lists/movies/CardMoviesList.tsx b/src/components/lists/movies/CardMoviesList.tsx index d9380ad..6f1fd7b 100644 --- a/src/components/lists/movies/CardMoviesList.tsx +++ b/src/components/lists/movies/CardMoviesList.tsx @@ -1,14 +1,14 @@ -import type { Movie } from "../../../types"; +import type { MovieDetail } from "../../../types"; import CardMoviesListItem from "./CardMoviesListItem"; interface CardMoviesListProps { - movies: Movie[]; + movies: MovieDetail[]; } export default function CardMoviesList({ movies }: CardMoviesListProps) { const items = movies.map((elt) => { return ( -
+
); diff --git a/src/components/lists/movies/CardMoviesListItem.tsx b/src/components/lists/movies/CardMoviesListItem.tsx index a7c2ce8..4f6015b 100644 --- a/src/components/lists/movies/CardMoviesListItem.tsx +++ b/src/components/lists/movies/CardMoviesListItem.tsx @@ -1,8 +1,8 @@ import { FaEye } from "react-icons/fa"; -import type { Movie } from "../../../types"; +import type { Movie, MovieDetail } from "../../../types"; interface CardMoviesListItemProps { - movie: Movie; + movie: MovieDetail; } export default function CardMoviesListItem({ movie }: CardMoviesListItemProps) { @@ -10,7 +10,7 @@ export default function CardMoviesListItem({ movie }: CardMoviesListItemProps) {
- {movie.title} + {movie.movie.title}
@@ -33,8 +33,19 @@ export default function CardMoviesListItem({ movie }: CardMoviesListItemProps) { >
+ {movie.stats ? ( + + Disponible + + ) : ( + + Bientot dispo. + + )} + +
diff --git a/src/pages/home/index.astro b/src/pages/home/index.astro index 719ce9d..a982a8b 100644 --- a/src/pages/home/index.astro +++ b/src/pages/home/index.astro @@ -2,16 +2,20 @@ import MoviesSearchInput from "../../components/MoviesSearchInput"; import CardMoviesList from "../../components/lists/movies/CardMoviesList"; import HomeLayout from "../../layouts/HomeLayout.astro"; -import type { Movie } from "../../types"; +import type { MovieDetail } from "../../types"; const jwt = Astro.cookies.get("jwt")?.value as string; -const url = new URL(Astro.request.url); -const queryParams = new URLSearchParams(); -const query = url.searchParams.get("q"); +const url = new URL(Astro.request.url); +const query = url.searchParams.get("query"); +const limit = url.searchParams.get("limit") ?? "18"; + +const queryParams = new URLSearchParams({ + limit: limit, +}); if (query) { - queryParams.append("q", query); + queryParams.append("query", query); } const res = await fetch( @@ -25,8 +29,7 @@ const res = await fetch( }, ); -const resBody = (await res.json()) as { movies: Movie[] }; -const account = Astro.locals.account; +const resBody = (await res.json()) as { movies: MovieDetail[] }; --- diff --git a/src/pages/home/movies/[id].astro b/src/pages/home/movies/[id].astro index 5a54344..a893bbe 100644 --- a/src/pages/home/movies/[id].astro +++ b/src/pages/home/movies/[id].astro @@ -1,7 +1,6 @@ --- -import { FaEye } from "react-icons/fa"; import HomeLayout from "../../../layouts/HomeLayout.astro"; -import type { Movie } from "../../../types"; +import type { Movie, MovieDetail } from "../../../types"; const jwt = Astro.cookies.get("jwt")?.value as string; const { id } = Astro.params; @@ -14,17 +13,17 @@ const res = await fetch(`${import.meta.env.API_URL}/movies/${id}`, { }, }); -const movie = (await res.json()).movie as Movie; +const item = (await res.json()).movie as MovieDetail; --- - + <> -

{movie.title}

+

{item.movie.title}