2022-02-10 22:27:57 +01:00
|
|
|
import { GetProviderFromId, MWMedia, MWMediaType } from "scrapers";
|
2022-02-07 23:22:35 +01:00
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
|
|
|
export interface MediaCardProps {
|
|
|
|
media: MWMedia;
|
|
|
|
watchedPercentage: Number;
|
|
|
|
}
|
|
|
|
|
|
|
|
function MediaCardContent({ media, watchedPercentage }: MediaCardProps) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<p>{media.title} ({GetProviderFromId(media.providerId)?.displayName})</p>
|
|
|
|
<p>{watchedPercentage}% watched</p>
|
|
|
|
<hr/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function MediaCard(props: MediaCardProps) {
|
|
|
|
const provider = GetProviderFromId(props.media.providerId);
|
|
|
|
let link = "movie"
|
|
|
|
if (provider?.type === MWMediaType.SERIES)
|
|
|
|
link = "series";
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Link to={`/media/${link}`}>
|
|
|
|
<MediaCardContent {...props} />
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|