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
86
87
88
89
90
91
92
93
94
|
import { FunctionComponent, useMemo } from "react";
import { Link } from "react-router-dom";
import { Anchor, Badge, Group } from "@mantine/core";
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ColumnDef } from "@tanstack/react-table";
import {
useMovieAction,
useMovieSubtitleModification,
useMovieWantedPagination,
} from "@/apis/hooks";
import Language from "@/components/bazarr/Language";
import { task, TaskGroup } from "@/modules/task";
import WantedView from "@/pages/views/WantedView";
import { BuildKey } from "@/utilities";
const WantedMoviesView: FunctionComponent = () => {
const { download } = useMovieSubtitleModification();
const columns = useMemo<ColumnDef<Wanted.Movie>[]>(
() => [
{
header: "Name",
accessorKey: "title",
cell: ({
row: {
original: { title, radarrId },
},
}) => {
const target = `/movies/${radarrId}`;
return (
<Anchor component={Link} to={target}>
{title}
</Anchor>
);
},
},
{
header: "Missing",
accessorKey: "missing_subtitles",
cell: ({
row: {
original: { radarrId, missing_subtitles: missingSubtitles },
},
}) => {
return (
<Group gap="sm">
{missingSubtitles.map((item, idx) => (
<Badge
color={download.isPending ? "gray" : undefined}
leftSection={<FontAwesomeIcon icon={faSearch} />}
key={BuildKey(idx, item.code2)}
style={{ cursor: "pointer" }}
onClick={() => {
task.create(
item.name,
TaskGroup.SearchSubtitle,
download.mutateAsync,
{
radarrId,
form: {
language: item.code2,
hi: item.hi,
forced: item.forced,
},
},
);
}}
>
<Language.Text value={item}></Language.Text>
</Badge>
))}
</Group>
);
},
},
],
[download],
);
const { mutateAsync } = useMovieAction();
const query = useMovieWantedPagination();
return (
<WantedView
name="Movies"
columns={columns}
query={query}
searchAll={() => mutateAsync({ action: "search-wanted" })}
></WantedView>
);
};
export default WantedMoviesView;
|