import { AlertDialog as Dialog, AlertDialogBody, AlertDialogFooter, AlertDialogHeader, AlertDialogContent, AlertDialogOverlay, useDisclosure, Button, } from '@chakra-ui/react'; import { useRef, useState } from 'react'; import ReactMarkdown from 'react-markdown'; import { useNuiEvent } from '../../hooks/useNuiEvent'; import { fetchNui } from '../../utils/fetchNui'; import { useLocales } from '../../providers/LocaleProvider'; export interface AlertProps { header: string; content: string; centered?: boolean; cancel?: boolean; } const AlertDialog: React.FC = () => { const { locale } = useLocales(); const { isOpen, onOpen, onClose } = useDisclosure(); const cancelRef = useRef(null); const [dialogData, setDialogData] = useState({ header: '', content: '', }); const closeAlert = (button: string) => { onClose(); fetchNui('closeAlert', button); }; useNuiEvent('sendAlert', (data: AlertProps) => { setDialogData(data); onOpen(); }); return ( <> closeAlert('cancel')} > {dialogData.header} {dialogData.content} {dialogData.cancel && ( )} ); }; export default AlertDialog;