implement objectstats in movie detail page
This commit is contained in:
parent
a43a77d158
commit
c25e2af4c1
4 changed files with 24 additions and 13 deletions
|
@ -16,7 +16,7 @@ export default function MoviesSearchInput({ searchUrl }: MoviesSearchInput) {
|
||||||
|
|
||||||
function handleOnKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
|
function handleOnKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
window.location.href = `${searchUrl}?q=${value}`;
|
window.location.href = `${searchUrl}?query=${value}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default function CardMoviesListItem({ movie }: CardMoviesListItemProps) {
|
||||||
Disponible
|
Disponible
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="badge text-bg-secondary mb-2">
|
<span className="badge text-bg-warning mb-2">
|
||||||
Bientot dispo.
|
Bientot dispo.
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -2,13 +2,17 @@
|
||||||
import MoviesSearchInput from "../../components/MoviesSearchInput";
|
import MoviesSearchInput from "../../components/MoviesSearchInput";
|
||||||
import CardMoviesList from "../../components/lists/movies/CardMoviesList";
|
import CardMoviesList from "../../components/lists/movies/CardMoviesList";
|
||||||
import HomeLayout from "../../layouts/HomeLayout.astro";
|
import HomeLayout from "../../layouts/HomeLayout.astro";
|
||||||
import type { Movie, MovieDetail } from "../../types";
|
import type { MovieDetail } from "../../types";
|
||||||
|
|
||||||
const jwt = Astro.cookies.get("jwt")?.value as string;
|
const jwt = Astro.cookies.get("jwt")?.value as string;
|
||||||
const url = new URL(Astro.request.url);
|
|
||||||
|
|
||||||
const queryParams = new URLSearchParams();
|
const url = new URL(Astro.request.url);
|
||||||
const query = url.searchParams.get("q");
|
const query = url.searchParams.get("query");
|
||||||
|
const limit = url.searchParams.get("limit") ?? "18";
|
||||||
|
|
||||||
|
const queryParams = new URLSearchParams({
|
||||||
|
limit: limit,
|
||||||
|
});
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
queryParams.append("query", query);
|
queryParams.append("query", query);
|
||||||
|
@ -26,7 +30,6 @@ const res = await fetch(
|
||||||
);
|
);
|
||||||
|
|
||||||
const resBody = (await res.json()) as { movies: MovieDetail[] };
|
const resBody = (await res.json()) as { movies: MovieDetail[] };
|
||||||
const account = Astro.locals.account;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<HomeLayout title="Movies">
|
<HomeLayout title="Movies">
|
||||||
|
|
|
@ -35,12 +35,20 @@ const item = (await res.json()).movie as MovieDetail;
|
||||||
</div>
|
</div>
|
||||||
<div class="col align-self-center">
|
<div class="col align-self-center">
|
||||||
<div class="d-grid">
|
<div class="d-grid">
|
||||||
|
{
|
||||||
|
item.stats ? (
|
||||||
<a
|
<a
|
||||||
href={`/home/movies/${item.movie.id}`}
|
href={`/home/movies/${item.movie.id}`}
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
>
|
>
|
||||||
Watch
|
Watch
|
||||||
</a>
|
</a>
|
||||||
|
) : (
|
||||||
|
<span class="badge text-bg-warning">
|
||||||
|
Bientot disponible
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue