Files
shop-server/client/src/shared/ui/AdminDialog/AdminDialog.tsx
T
2026-05-13 22:07:46 +05:00

37 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { ReactNode } from 'react'
import Alert from '@mui/material/Alert'
import Button from '@mui/material/Button'
import Dialog from '@mui/material/Dialog'
import DialogActions from '@mui/material/DialogActions'
import DialogContent from '@mui/material/DialogContent'
import DialogTitle from '@mui/material/DialogTitle'
import Typography from '@mui/material/Typography'
type Props = {
open: boolean
onClose: () => void
title: ReactNode
children: ReactNode
actions?: ReactNode
loading?: boolean
error?: string | null
maxWidth?: 'xs' | 'sm' | 'md' | 'lg'
}
export function AdminDialog({ open, onClose, title, children, actions, loading, error, maxWidth = 'sm' }: Props) {
return (
<Dialog open={open} onClose={onClose} fullWidth maxWidth={maxWidth}>
<DialogTitle>{title}</DialogTitle>
<DialogContent>
{loading && <Typography>Загрузка</Typography>}
{error && <Alert severity="error">{error}</Alert>}
{!loading && !error && children}
</DialogContent>
<DialogActions>
{actions}
<Button onClick={onClose}>Закрыть</Button>
</DialogActions>
</Dialog>
)
}