All files / src/utils/components/feature-access UpgradeDialog.jsx

33.33% Statements 1/3
0% Branches 0/4
0% Functions 0/1
33.33% Lines 1/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127              7x                                                                                                                                                                                                                                              
import { Box, Button, Dialog, DialogActions, DialogContent, IconButton, Stack, Typography } from "@mui/material";
import { alpha, useTheme } from "@mui/material/styles";
import CloseIcon from "@mui/icons-material/Close";
import LockOutlinedIcon from "@mui/icons-material/LockOutlined";
import UpgradeDialogContent from "@/utils/components/feature-access/UpgradeDialogContent";
import { SHARED_IDS } from "@/utils/helpers/testIds";
 
const UpgradeDialog = ({
    open,
    onClose,
    title,
    featureKey = null,
    featureLabel,
    featureMeta,
    minPlan,
    currentPlan,
    planName,
    id = SHARED_IDS.upgradeDialog,
}) => {
    const theme = useTheme();
 
    return (
        <Dialog
            id={id}
            open={open}
            onClose={onClose}
            maxWidth="xs"
            fullWidth
            aria-labelledby={`${id}-title`}
            slotProps={{
                backdrop: {
                    sx: {
                        backgroundColor: alpha(theme.palette.grey[900], 0.48),
                    },
                },
            }}
            PaperProps={{
                sx: {
                    borderRadius: 3,
                    border: `1px solid ${alpha(theme.palette.grey[500], 0.12)}`,
                    boxShadow: theme.customShadows?.dialog ?? theme.shadows[8],
                    overflow: "visible",
                },
            }}
        >
            <IconButton
                id={`${id}-button-close`}
                aria-label="Close"
                onClick={onClose}
                size="small"
                sx={{
                    position: "absolute",
                    right: 14,
                    top: 14,
                    zIndex: 1,
                    width: 32,
                    height: 32,
                    bgcolor: alpha(theme.palette.grey[500], 0.08),
                    color: "text.secondary",
                    "&:hover": { bgcolor: alpha(theme.palette.grey[500], 0.16) },
                }}
            >
                <CloseIcon sx={{ fontSize: 18 }} />
            </IconButton>
 
            <DialogContent sx={{ pt: 3, pb: 0, px: 3 }}>
                <Stack spacing={2} sx={{ pr: 3 }}>
                    <Stack direction="row" spacing={1.5} alignItems="center">
                        <Box
                            sx={{
                                width: 44,
                                height: 44,
                                borderRadius: "50%",
                                bgcolor: alpha(theme.palette.primary.main, 0.1),
                                color: "primary.main",
                                display: "flex",
                                alignItems: "center",
                                justifyContent: "center",
                                flexShrink: 0,
                            }}
                        >
                            <LockOutlinedIcon sx={{ fontSize: 22 }} />
                        </Box>
                        <Typography
                            id={`${id}-title`}
                            variant="subtitle1"
                            component="h2"
                            sx={{ fontWeight: 600, lineHeight: 1.35, pr: 2 }}
                        >
                            {title}
                        </Typography>
                    </Stack>
 
                    <UpgradeDialogContent
                        showTitle={false}
                        featureKey={featureKey}
                        featureLabel={featureLabel}
                        featureMeta={featureMeta}
                        minPlan={minPlan}
                        currentPlan={currentPlan}
                        planName={planName}
                    />
                </Stack>
            </DialogContent>
 
            <DialogActions sx={{ px: 3, pb: 3, pt: 2.5 }}>
                <Button
                    id={`${id}-button-got-it`}
                    variant="contained"
                    color="primary"
                    onClick={onClose}
                    fullWidth
                    sx={{
                        py: 1,
                        fontWeight: 600,
                        fontSize: "0.9375rem",
                    }}
                >
                    Got it
                </Button>
            </DialogActions>
        </Dialog>
    );
};
 
export default UpgradeDialog;