import React from 'react'; import axios from 'axios'; import { useHistory } from 'react-router'; import { Trans } from 'react-i18next'; import { apiBaseUrl } from '../config'; import { useUserLoggedIn } from '../data/user'; import OperationDialog from '../common/OperationDialog'; interface TimelineDeleteDialog { open: boolean; name: string; close: () => void; } const TimelineDeleteDialog: React.FC = (props) => { const user = useUserLoggedIn(); const history = useHistory(); const { name } = props; return ( { return ( 0{{ name }}2 ); }} inputScheme={[ { type: 'text', validator: (value) => { if (value !== name) { return 'timeline.deleteDialog.notMatch'; } else { return null; } }, }, ]} onProcess={() => { return axios.delete( `${apiBaseUrl}/timelines/${name}?token=${user.token}` ); }} onSuccessAndClose={() => { history.replace('/'); }} /> ); }; export default TimelineDeleteDialog;