aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/timeline/PostPropertyChangeDialog.tsx
blob: fc55185c6c09d65c5b69fa0f0c754e178a1662bf (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
import * as React from "react";

import { getHttpTimelineClient, HttpTimelinePostInfo } from "@/http/timeline";

import OperationDialog from "../common/dialog/OperationDialog";

function PostPropertyChangeDialog(props: {
  open: boolean;
  onClose: () => void;
  post: HttpTimelinePostInfo;
  onSuccess: (post: HttpTimelinePostInfo) => void;
}): React.ReactElement | null {
  const { open, onClose, post, onSuccess } = props;

  return (
    <OperationDialog
      title="timeline.changePostPropertyDialog.title"
      onClose={onClose}
      open={open}
      inputScheme={[
        {
          label: "timeline.changePostPropertyDialog.time",
          type: "datetime",
          initValue: post.time,
        },
      ]}
      onProcess={([time]) => {
        return getHttpTimelineClient().patchPost(
          post.timelineOwnerV2,
          post.timelineNameV2,
          post.id,
          {
            time: time === "" ? undefined : new Date(time).toISOString(),
          }
        );
      }}
      onSuccessAndClose={onSuccess}
    />
  );
}

export default PostPropertyChangeDialog;