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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { FunctionComponent, useCallback, useMemo } from "react";
import { Badge } from "react-bootstrap";
import { Link } from "react-router-dom";
import { Column } from "react-table";
import { movieUpdateWantedByRange } from "../../@redux/actions";
import { useWantedMovies } from "../../@redux/hooks";
import { useReduxAction } from "../../@redux/hooks/base";
import { MoviesApi } from "../../apis";
import { AsyncButton, LanguageText } from "../../components";
import { BuildKey } from "../../utilites";
import GenericWantedView from "../generic";
interface Props {}
const WantedMoviesView: FunctionComponent<Props> = () => {
const wantedMovies = useWantedMovies();
const loader = useReduxAction(movieUpdateWantedByRange);
const searchAll = useCallback(
() => MoviesApi.action({ action: "search-wanted" }),
[]
);
const columns: Column<Wanted.Movie>[] = useMemo<Column<Wanted.Movie>[]>(
() => [
{
Header: "Name",
accessor: "title",
Cell: (row) => {
const target = `/movies/${row.row.original.radarrId}`;
return (
<Link to={target}>
<span>{row.value}</span>
</Link>
);
},
},
{
Header: "Missing",
accessor: "missing_subtitles",
Cell: ({ row, value, update }) => {
const wanted = row.original;
const hi = wanted.hearing_impaired;
const movieid = wanted.radarrId;
return value.map((item, idx) => (
<AsyncButton
as={Badge}
key={BuildKey(idx, item.code2)}
className="mx-1 mr-2"
variant="secondary"
promise={() =>
MoviesApi.downloadSubtitles(movieid, {
language: item.code2,
hi,
forced: false,
})
}
onSuccess={() => update && update(row, movieid)}
>
<LanguageText className="pr-1" text={item}></LanguageText>
<FontAwesomeIcon size="sm" icon={faSearch}></FontAwesomeIcon>
</AsyncButton>
));
},
},
],
[]
);
return (
<GenericWantedView
type="movies"
columns={columns}
state={wantedMovies}
loader={loader}
searchAll={searchAll}
></GenericWantedView>
);
};
export default WantedMoviesView;
|