1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-21 14:47:41 +01:00
smov/src/components/MovieRow.js

34 lines
1 KiB
JavaScript
Raw Normal View History

2021-07-14 00:31:37 +02:00
import React from 'react'
import { Arrow } from './Arrow'
import './MovieRow.css'
import { PercentageOverlay } from './PercentageOverlay'
2021-07-14 00:31:37 +02: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") {
2021-07-21 00:49:33 +02:00
progress = progressData?.[props.source]?.movie?.[props.slug]?.full
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}&nbsp;
<span className="year">({props.year})</span>
2021-07-14 00:31:37 +02:00
</div>
<div className="watch">
<p>Watch {props.type}</p>
2021-07-14 00:31:37 +02:00
<Arrow/>
</div>
<PercentageOverlay percentage={percentage} />
2021-07-14 00:31:37 +02:00
</div>
)
}