-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
781 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import {AppBar, Box, type BoxProps, Dialog, type DialogProps, IconButton, Toolbar, Typography} from '@mui/material'; | ||
import {CloseRounded} from '@mui/icons-material'; | ||
import {Transition} from '@/components/DeleteDialog.component.tsx'; | ||
|
||
export type TFullScreenDialogProps = DialogProps & { | ||
title: string; | ||
onClose: () => void; | ||
appBarActions?: React.ReactNode; | ||
boxProps?: BoxProps; | ||
}; | ||
|
||
export const FullScreenDialog: React.FC<TFullScreenDialogProps> = ({ | ||
title, | ||
onClose, | ||
appBarActions, | ||
boxProps, | ||
...dialogProps | ||
}) => { | ||
return ( | ||
<Dialog fullScreen TransitionComponent={Transition} PaperProps={{elevation: 0}} {...dialogProps}> | ||
<AppBar | ||
elevation={0} | ||
sx={{position: 'relative', border: 0, borderBottom: theme => `1px solid ${theme.palette.divider}`}}> | ||
<Toolbar sx={{border: 'none'}}> | ||
<Typography | ||
sx={{ | ||
flex: 1, | ||
fontWeight: 700, | ||
color: 'inherit', | ||
textDecoration: 'none', | ||
}} | ||
variant="h5" | ||
component="div"> | ||
{title} | ||
</Typography> | ||
|
||
{appBarActions} | ||
<IconButton edge="start" color="inherit" onClick={onClose} aria-label="close"> | ||
<CloseRounded /> | ||
</IconButton> | ||
</Toolbar> | ||
</AppBar> | ||
|
||
<Box {...boxProps} sx={{p: 2, ...boxProps?.sx}}> | ||
{dialogProps.children} | ||
</Box> | ||
</Dialog> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import {Button, Tooltip, type ButtonProps} from '@mui/material'; | ||
import {useSnackbarContext} from '@/components/Snackbar'; | ||
|
||
export type TDownloadButtonProps = ButtonProps & { | ||
exportFormat: /*'CSV' |*/ 'JSON'; | ||
exportFileName: string; | ||
data: object; | ||
withTooltip?: boolean; | ||
}; | ||
|
||
export const DownloadButton: React.FC<TDownloadButtonProps> = ({ | ||
exportFormat, | ||
exportFileName, | ||
data, | ||
...buttonProps | ||
}) => { | ||
const {showSnackbar} = useSnackbarContext(); | ||
const downloadBtnRef = React.useRef<HTMLAnchorElement | null>(null); | ||
|
||
const downloadContent = () => { | ||
if (!downloadBtnRef.current) | ||
return showSnackbar({ | ||
message: 'Download button not found', | ||
action: <Button onClick={downloadContent}>Retry</Button>, | ||
}); | ||
downloadBtnRef.current.setAttribute( | ||
'href', | ||
`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(data, null, 2))}`, | ||
); | ||
downloadBtnRef.current?.setAttribute('download', `${exportFileName}.${exportFormat.toLowerCase()}`); | ||
downloadBtnRef.current.click(); | ||
showSnackbar({message: 'Download started'}); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
{buttonProps.withTooltip ? ( | ||
<Tooltip title={`Download as ${exportFormat}`}> | ||
<Button {...buttonProps} onClick={downloadContent} /> | ||
</Tooltip> | ||
) : ( | ||
<Button {...buttonProps} onClick={downloadContent} /> | ||
)} | ||
<a aria-hidden ref={downloadBtnRef} /> | ||
</React.Fragment> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DownloadButton.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.