import { Card } from "@components/Card.tsx";
import { Movie } from "@lib/resource/movies.ts";
import { Series } from "@lib/resource/series.ts";
import { isLocalImage } from "@lib/string.ts";

export function MovieCard(
  { movie, sublink = "movies" }: { sublink?: string; movie: Movie | Series },
) {
  const { meta: { image = "/placeholder.svg" } = {} } = movie;

  const imageUrl = isLocalImage(image)
    ? `/api/images?image=${image}&width=200&height=200`
    : image;

  return (
    <Card
      title={movie.name}
      image={imageUrl}
      link={`/${sublink}/${movie.id}`}
    />
  );
}
