2021-07-14 00:31:37 +02:00
|
|
|
import React from 'react'
|
|
|
|
import { Arrow } from './Arrow'
|
|
|
|
import './MovieRow.css'
|
2021-07-15 21:24:11 +02:00
|
|
|
import { PercentageOverlay } from './PercentageOverlay'
|
2021-07-14 00:31:37 +02:00
|
|
|
|
|
|
|
// title: string
|
|
|
|
// onClick: () => void
|
|
|
|
export function MovieRow(props) {
|
2021-07-15 21:24:11 +02:00
|
|
|
const progressData = JSON.parse(localStorage.getItem("video-progress") || "{}")
|
|
|
|
let progress;
|
|
|
|
let percentage = null;
|
2021-08-06 18:57:58 +02:00
|
|
|
|
|
|
|
if (props.type === "movie") {
|
2021-07-21 00:49:33 +02:00
|
|
|
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
|
2021-08-06 18:57:58 +02:00
|
|
|
|
|
|
|
if (progress) {
|
2021-07-15 21:24:11 +02:00
|
|
|
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 00:31:37 +02:00
|
|
|
return (
|
|
|
|
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
|
|
|
|
<div className="left">
|
2021-08-06 18:57:58 +02:00
|
|
|
{props.title}<span className="seasonEpisodeSubtitle">{props.place ? ` - S${props.place.season}:E${props.place.episode}` : ''}</span>
|
2021-07-14 11:18:07 +02:00
|
|
|
<span className="year">({props.year})</span>
|
2021-07-14 00:31:37 +02:00
|
|
|
</div>
|
2021-08-06 18:57:58 +02:00
|
|
|
|
2021-07-14 00:31:37 +02:00
|
|
|
<div className="watch">
|
2021-07-14 10:43:45 +02:00
|
|
|
<p>Watch {props.type}</p>
|
2021-07-14 00:31:37 +02:00
|
|
|
<Arrow/>
|
|
|
|
</div>
|
2021-08-06 18:57:58 +02:00
|
|
|
|
2021-08-06 15:39:54 +02:00
|
|
|
<PercentageOverlay percentage={props.percentage || percentage} />
|
2021-07-14 00:31:37 +02:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|