sudo-archive/src/components/MovieRow.js

34 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-07-13 22:31:37 +00:00
import React from 'react'
import { Arrow } from './Arrow'
import './MovieRow.css'
import { PercentageOverlay } from './PercentageOverlay'
2021-07-13 22:31:37 +00:00
// 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?.lookmovie?.movie?.[props.slug]?.full
if(progress) {
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
}
}
2021-07-13 22:31:37 +00:00
return (
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
<div className="left">
2021-07-14 09:18:07 +00:00
{props.title}&nbsp;
<span className="year">({props.year})</span>
2021-07-13 22:31:37 +00:00
</div>
<div className="watch">
<p>Watch {props.type}</p>
2021-07-13 22:31:37 +00:00
<Arrow/>
</div>
<PercentageOverlay percentage={percentage} />
2021-07-13 22:31:37 +00:00
</div>
)
}