import React from "react";
import { Movie } from "./movie-wall";
import tmdb from "./tmdb";
import { WhereToWatch } from "./whereToWatch";
import CrossfadeImage from 'react-crossfade-image'
import { Config } from "../App";
export interface SidebarProps extends React.ComponentPropsWithRef<"div"> {
  movie: Movie;
  similarMoviesAvailable: boolean;
  watchProviders: {};
  config: Config;
}
export function Sidebar({ movie, similarMoviesAvailable, watchProviders, config }: SidebarProps) {
  const apology = config.language == "es" ?
    "Resumen no disponible" :
    config.language == "en" ?
      "Summary unavailable." :
      ""
  return <div id="sidebar">
    <h1>{movie?.title ?? "loading"}</h1>
    <a href={tmdb.makeMovieLink(movie)} target="_blank" rel="noopener noreferrer">
      <CrossfadeImage src={tmdb.makeImgUrl(movie.poster_path ?? "")} containerClass="chosen-movie-poster" style={{ objectFit: "cover", height: "100%" }} />
    </a>
    {similarMoviesAvailable ? "" : "No hay data suficiente para darte pelílculas relacionadas."}
    <p id="summary">{movie.overview === null ? "Loading"
      : movie.overview === "" ? apology
        : movie.overview}
    </p>
    <WhereToWatch watchProviders={watchProviders} config={config} />
  </div>


}
