import { gql } from '@apollo/client'; import { Box, Button, Card, Heading, Icon, Stack, Text } from '@chakra-ui/react'; import { BookChapterDeleteMutation } from '@generated/types'; import { Link } from '@tanstack/react-router'; import { bookFragment } from '../fragments'; import { useToastMutation } from '../hooks/useToastMutation'; import { bookChapterQuery } from '../pages/work/book/$bookId/chapter/$chapterId/view'; import { bookChapterListQuery } from '../pages/work/book/$bookId/overview/contents'; export function BookChapterCard({ bookId, chapterId, title, isAuthor }: { readonly bookId: string; readonly chapterId: string; readonly title: string; readonly isAuthor: boolean; }) { const { update: chapterDelete } = useToastMutation({ mutation, successMsg: 'Chapter deleted successfully', refetchQueries: [bookChapterListQuery, bookChapterQuery] }); return ( {title} {isAuthor && ( <> )} ); } const mutation = gql` mutation BookChapterDelete($id: ID!) { bookChapterDelete(id: $id) { ...Book } } ${bookFragment} `;