aboutsummaryrefslogtreecommitdiff
path: root/components/anime/viewMode/listMode.js
blob: a6a1cf642cf861151b4a457c74e834434e1c36d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Link from "next/link";

export default function ListMode({
  info,
  episode,
  artStorage,
  providerId,
  progress,
  dub,
}) {
  const time = artStorage?.[episode?.id]?.timeWatched;
  const duration = artStorage?.[episode?.id]?.duration;
  let prog = (time / duration) * 100;
  if (prog > 90) prog = 100;

  return (
    <Link
      key={episode.number}
      href={`/en/anime/watch/${info.id}/${providerId}?id=${encodeURIComponent(
        episode.id
      )}&num=${episode.number}${dub ? `&dub=${dub}` : ""}`}
      className={`flex gap-3 py-4 hover:bg-secondary odd:bg-secondary/30 even:bg-primary`}
    >
      <div className="flex w-full">
        <span className="shrink-0 px-4 text-center text-white/50">
          {episode.number}
        </span>
        <p
          className={`w-full line-clamp-1 ${
            progress
              ? progress && episode.number <= progress
                ? "text-[#5f5f5f]"
                : "text-white"
              : prog === 100
              ? "text-[#5f5f5f]"
              : "text-white"
          }`}
        >
          {episode?.title || `Episode ${episode.number}`}
        </p>
        <p className="capitalize text-sm text-white/50 px-4">{providerId}</p>
      </div>
    </Link>
  );
}