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