robosats/frontend/src/components/Dialogs/StoreToken.tsx

80 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-09-09 17:18:04 +00:00
import React from 'react';
import { useTranslation } from 'react-i18next';
2022-05-08 22:07:49 +00:00
import {
Dialog,
DialogTitle,
2022-09-09 17:18:04 +00:00
Tooltip,
2022-05-08 22:07:49 +00:00
IconButton,
TextField,
2022-09-09 17:18:04 +00:00
DialogActions,
2022-05-08 22:07:49 +00:00
DialogContent,
DialogContentText,
2022-09-09 17:18:04 +00:00
Button,
2022-05-08 22:07:49 +00:00
Grid,
2022-09-09 17:18:04 +00:00
} from '@mui/material';
import { systemClient } from '../../services/System';
2022-09-09 17:18:04 +00:00
import ContentCopy from '@mui/icons-material/ContentCopy';
2022-05-08 22:07:49 +00:00
interface Props {
2022-05-08 22:07:49 +00:00
open: boolean;
onClose: () => void;
copyIconColor: string;
onClickCopy: () => void;
onClickBack: () => void;
onClickDone: () => void;
}
2022-05-08 22:07:49 +00:00
const StoreTokenDialog = ({
2022-09-09 17:18:04 +00:00
open,
2022-05-08 22:07:49 +00:00
onClose,
copyIconColor,
onClickCopy,
onClickBack,
onClickDone,
}: Props): JSX.Element => {
const { t } = useTranslation();
return (
2022-09-09 17:18:04 +00:00
<Dialog open={open} onClose={onClose}>
<DialogTitle>{t('Store your robot token')}</DialogTitle>
2022-05-08 22:07:49 +00:00
<DialogContent>
<DialogContentText>
2022-09-09 17:18:04 +00:00
{t(
'You might need to recover your robot avatar in the future: store it safely. You can simply copy it into another application.',
)}
2022-05-08 22:07:49 +00:00
</DialogContentText>
2022-09-09 17:18:04 +00:00
<br />
<Grid align='center'>
2022-05-08 22:07:49 +00:00
<TextField
2022-09-09 17:18:04 +00:00
sx={{ width: '100%', maxWidth: '550px' }}
2022-05-08 22:07:49 +00:00
disabled
2022-09-09 17:18:04 +00:00
label={t('Back it up!')}
value={systemClient.getCookie('robot_token')}
2022-05-08 22:07:49 +00:00
variant='filled'
size='small'
InputProps={{
2022-09-09 17:18:04 +00:00
endAdornment: (
<Tooltip disableHoverListener enterTouchDelay={0} title={t('Copied!')}>
<IconButton onClick={onClickCopy}>
<ContentCopy color={copyIconColor} />
</IconButton>
</Tooltip>
),
}}
/>
2022-05-08 22:07:49 +00:00
</Grid>
</DialogContent>
<DialogActions>
2022-09-09 17:18:04 +00:00
<Button onClick={onClickBack} autoFocus>
{t('Go back')}
</Button>
<Button onClick={onClickDone}>{t('Done')}</Button>
2022-05-08 22:07:49 +00:00
</DialogActions>
</Dialog>
2022-09-09 17:18:04 +00:00
);
};
2022-05-08 22:07:49 +00:00
export default StoreTokenDialog;