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

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

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

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

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

export default PostPropertyChangeDialog;