mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Warn user in WebUI of unsaved changes #911
This commit is contained in:
30
interface/src/components/routing/BlockNavigation.tsx
Normal file
30
interface/src/components/routing/BlockNavigation.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { FC } from 'react';
|
||||
import type { Blocker } from '@remix-run/router';
|
||||
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';
|
||||
|
||||
import { useI18nContext } from '../../i18n/i18n-react';
|
||||
|
||||
interface BlockNavigationProps {
|
||||
blocker: Blocker;
|
||||
}
|
||||
|
||||
const BlockNavigation: FC<BlockNavigationProps> = ({ blocker }) => {
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
return (
|
||||
<Dialog open={blocker.state === 'blocked'}>
|
||||
<DialogTitle>{LL.BLOCK_NAVIGATE_1()}</DialogTitle>
|
||||
<DialogContent dividers>{LL.BLOCK_NAVIGATE_2()}</DialogContent>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" onClick={() => blocker.reset?.()} color="secondary">
|
||||
{LL.STAY()}
|
||||
</Button>
|
||||
<Button variant="contained" onClick={() => blocker.proceed?.()} color="primary" autoFocus>
|
||||
{LL.LEAVE()}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default BlockNavigation;
|
||||
Reference in New Issue
Block a user