From 99faf14929736529eaf3dfde10f743ad3d8296d9 Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Fri, 26 Sep 2025 16:15:01 +0100 Subject: [PATCH] Navigation warning --- .../public/locales/en-GB/translation.json | 8 ++- .../shared/NavigationWarningModal.tsx | 67 ++++++++++--------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json index 89ace5ea2..c16b849c0 100644 --- a/frontend/public/locales/en-GB/translation.json +++ b/frontend/public/locales/en-GB/translation.json @@ -1,4 +1,10 @@ { + "unsavedChanges": "You have unsaved changes to your PDF. What would you like to do?", + "unsavedChangesTitle": "Unsaved Changes", + "keepWorking": "Keep Working", + "discardChanges": "Discard Changes", + "applyAndContinue": "Apply & Continue", + "exportAndContinue": "Export & Continue", "language": { "direction": "ltr" }, @@ -3439,4 +3445,4 @@ }, "termsAndConditions": "Terms & Conditions", "logOut": "Log out" -} \ No newline at end of file +} diff --git a/frontend/src/components/shared/NavigationWarningModal.tsx b/frontend/src/components/shared/NavigationWarningModal.tsx index c7f591c71..ede7b4bba 100644 --- a/frontend/src/components/shared/NavigationWarningModal.tsx +++ b/frontend/src/components/shared/NavigationWarningModal.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Modal, Text, Button, Group, Stack } from '@mantine/core'; import { useNavigationGuard } from '../../contexts/NavigationContext'; +import { useTranslation } from 'react-i18next'; interface NavigationWarningModalProps { onApplyAndContinue?: () => Promise; @@ -11,6 +12,8 @@ const NavigationWarningModal = ({ onApplyAndContinue, onExportAndContinue }: NavigationWarningModalProps) => { + + const { t } = useTranslation(); const { showNavigationWarning, hasUnsavedChanges, @@ -28,7 +31,7 @@ const NavigationWarningModal = ({ confirmNavigation(); }; - const handleApplyAndContinue = async () => { + const _handleApplyAndContinue = async () => { if (onApplyAndContinue) { await onApplyAndContinue(); } @@ -52,55 +55,59 @@ const NavigationWarningModal = ({ - You have unsaved changes to your PDF. What would you like to do? + {t("unsavedChanges", "You have unsaved changes to your PDF. What would you like to do?")} - - - - + + + - - {onApplyAndContinue && ( + + - )} - - {onExportAndContinue && ( - - )} + + {/* TODO:: Add this back in when it works */} + {/* {onApplyAndContinue && ( + + )} */} + + {onExportAndContinue && ( + + )} + ); }; -export default NavigationWarningModal; \ No newline at end of file +export default NavigationWarningModal;