import { Modal, Text, Button, Group, Stack } from '@mantine/core'; import { useNavigationGuard } from '../../contexts/NavigationContext'; import { useTranslation } from 'react-i18next'; interface NavigationWarningModalProps { onApplyAndContinue?: () => Promise; onExportAndContinue?: () => Promise; } const NavigationWarningModal = ({ onApplyAndContinue, onExportAndContinue }: NavigationWarningModalProps) => { const { t } = useTranslation(); const { showNavigationWarning, hasUnsavedChanges, cancelNavigation, confirmNavigation, setHasUnsavedChanges } = useNavigationGuard(); const handleKeepWorking = () => { cancelNavigation(); }; const handleDiscardChanges = () => { setHasUnsavedChanges(false); confirmNavigation(); }; const handleApplyAndContinue = async () => { if (onApplyAndContinue) { await onApplyAndContinue(); } setHasUnsavedChanges(false); confirmNavigation(); }; const handleExportAndContinue = async () => { if (onExportAndContinue) { await onExportAndContinue(); } setHasUnsavedChanges(false); confirmNavigation(); }; if (!hasUnsavedChanges) { return null; } return ( {t("unsavedChanges", "You have unsaved changes to your PDF. What would you like to do?")} {onExportAndContinue && ( )} {onApplyAndContinue && ( )} ); }; export default NavigationWarningModal;