import React from 'react'; import { Modal, Text, Button, Group, Stack } from '@mantine/core'; import { useFileContext } from '../../contexts/FileContext'; interface NavigationWarningModalProps { onApplyAndContinue?: () => Promise; onExportAndContinue?: () => Promise; } const NavigationWarningModal = ({ onApplyAndContinue, onExportAndContinue }: NavigationWarningModalProps) => { const { showNavigationWarning, hasUnsavedChanges, confirmNavigation, cancelNavigation, setHasUnsavedChanges } = useFileContext(); 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 ( You have unsaved changes to your PDF. What would you like to do? {onApplyAndContinue && ( )} {onExportAndContinue && ( )} ); }; export default NavigationWarningModal;