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;
|
|
|
|
if(props.type === "movie") {
|
2021-07-21 00:49:33 +02:00
|
|
|
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
|
2021-07-15 21:24:11 +02:00
|
|
|
if(progress) {
|
|
|
|
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-07-14 11:18:07 +02:00
|
|
|
{props.title}
|
|
|
|
<span className="year">({props.year})</span>
|
2021-07-14 00:31:37 +02:00
|
|
|
</div>
|
|
|
|
<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-07-15 21:24:11 +02:00
|
|
|
<PercentageOverlay percentage={percentage} />
|
2021-07-14 00:31:37 +02:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|