Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | import Button from 'antd/lib/button'; import message from 'antd/lib/message'; import * as React from 'react'; import { Mutation } from 'react-apollo'; import { IArticle } from '../../../../shared'; import { SETTINGS_ARTICLES } from '../queries'; import { DELETE_ARTICLE } from './mutations'; const DeleteArticleButton = ({ _id, title }: IArticle) => { const handleClick = (deleteArticle: any) => async () => { try { await deleteArticle({ variables: { _id } }); message.success(`Článek "${title}" byl smazán`); } catch (e) { message.error(e.message); } }; return ( <Mutation mutation={DELETE_ARTICLE} refetchQueries={[{ query: SETTINGS_ARTICLES }]} > {(deleteArticle, { loading, error }) => { return ( <Button type="danger" shape="circle" icon="delete" loading={loading} onClick={handleClick(deleteArticle)} /> ); }} </Mutation> ); }; export default DeleteArticleButton; |