blob: c960b3c261df104bbcfd510fdb4a9680326cf30f (
plain)
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
|
import * as React from "react";
import { useNavigate } from "react-router-dom";
import { Trans } from "react-i18next";
import { getHttpTimelineClient, HttpTimelineInfo } from "@/http/timeline";
import OperationDialog from "../common/dialog/OperationDialog";
interface TimelineDeleteDialog {
timeline: HttpTimelineInfo;
open: boolean;
close: () => void;
}
const TimelineDeleteDialog: React.FC<TimelineDeleteDialog> = (props) => {
const navigate = useNavigate();
const { timeline } = props;
return (
<OperationDialog
open={props.open}
onClose={props.close}
title="timeline.deleteDialog.title"
themeColor="danger"
inputPrompt={() => {
return (
<Trans
i18nKey="timeline.deleteDialog.inputPrompt"
values={{ name: timeline.nameV2 }}
>
0<code className="mx-2">1</code>2
</Trans>
);
}}
inputScheme={[
{
type: "text",
},
]}
inputValidator={([value]) => {
if (value !== timeline.nameV2) {
return { 0: "timeline.deleteDialog.notMatch" };
} else {
return null;
}
}}
onProcess={() => {
return getHttpTimelineClient().deleteTimeline(
timeline.owner.username,
timeline.nameV2
);
}}
onSuccessAndClose={() => {
navigate("/", { replace: true });
}}
/>
);
};
export default TimelineDeleteDialog;
|