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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
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 {
useEpisodeSubtitleModification,
useEpisodeWantedPagination,
useSeriesAction,
} 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 WantedSeriesView: FunctionComponent = () => {
const { download } = useEpisodeSubtitleModification();
const columns = useMemo<ColumnDef<Wanted.Episode>[]>(
() => [
{
header: "Name",
accessorKey: "seriesTitle",
cell: ({
row: {
original: { sonarrSeriesId, seriesTitle },
},
}) => {
const target = `/series/${sonarrSeriesId}`;
return (
<Anchor className="table-primary" component={Link} to={target}>
{seriesTitle}
</Anchor>
);
},
},
{
header: "Episode",
accessorKey: "episode_number",
},
{
accessorKey: "episodeTitle",
},
{
header: "Missing",
accessorKey: "missing_subtitles",
cell: ({
row: {
original: {
sonarrSeriesId,
sonarrEpisodeId,
missing_subtitles: missingSubtitles,
},
},
}) => {
const seriesId = sonarrSeriesId;
const episodeId = sonarrEpisodeId;
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,
{
seriesId,
episodeId,
form: {
language: item.code2,
hi: item.hi,
forced: item.forced,
},
},
);
}}
>
<Language.Text value={item}></Language.Text>
</Badge>
))}
</Group>
);
},
},
],
[download],
);
const { mutateAsync } = useSeriesAction();
const query = useEpisodeWantedPagination();
return (
<WantedView
name="Series"
columns={columns}
query={query}
searchAll={() => mutateAsync({ action: "search-wanted" })}
></WantedView>
);
};
export default WantedSeriesView;
|