import React, { useRef } from 'react' import agent from '../api/agent' import { useNavigate } from 'react-router-dom' import { Data } from '../models/game' import { AlertDialog, AlertDialogBody, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, Button, Icon, Text } from '@chakra-ui/react' type Props = { id: string open: boolean setOpen: Function setLoading: Function game: Data } export default function DeleteDialogue({ id, open, setOpen, setLoading, game, }: Props) { const history = useNavigate() const handleClose = () => { setOpen(false) } const deleteGame = async (id: string) => { setLoading(true) try { await agent.Games.delete(id) setLoading(false) handleClose() history(`/games/`) } catch (err) { console.error(err) setLoading(false) } } const cancelRef = useRef(null) return ( Delete? Are you sure you would like to delete {game.title}? ) }