movie-web/src/components/MovieRow.js
2021-08-07 09:55:39 +01:00

39 lines
1.2 KiB
JavaScript

import React from 'react'
import { Arrow } from './Arrow'
// import { Cross } from './Crosss'
import { PercentageOverlay } from './PercentageOverlay'
import './MovieRow.css'
// title: string
// onClick: () => void
export function MovieRow(props) {
const progressData = JSON.parse(localStorage.getItem("video-progress") || "{}")
let progress;
let percentage = null;
if (props.type === "movie") {
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
if (progress) {
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
}
}
return (
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
<div className="left">
{/* <Cross /> */}
{props.title}<span className="seasonEpisodeSubtitle">{props.place ? ` - S${props.place.season}:E${props.place.episode}` : ''}</span>&nbsp;
<span className="year">({props.year})</span>
</div>
<div className="watch">
<p>Watch {props.type}</p>
<Arrow/>
</div>
<PercentageOverlay percentage={props.percentage || percentage} />
</div>
)
}