import { dialogCloseHandler } from "@ente/shared/components/DialogBox/TitleWithCloseButton"; import EnteButton from "@ente/shared/components/EnteButton"; import { Box, Button, Dialog, DialogProps, Stack, Typography, } from "@mui/material"; import { t } from "i18next"; import React, { useState } from "react"; import { DialogBoxAttributesV2 } from "./types"; type IProps = React.PropsWithChildren< Omit & { onClose: () => void; attributes: DialogBoxAttributesV2; } >; export default function DialogBoxV2({ attributes, children, open, onClose, ...props }: IProps) { const [loading, setLoading] = useState(false); if (!attributes) { return <>; } const handleClose = dialogCloseHandler({ staticBackdrop: attributes.staticBackdrop, nonClosable: attributes.nonClosable, onClose: onClose, }); const { PaperProps, ...rest } = props; return ( {attributes.icon && ( svg": { fontSize: "32px", }, }} > {attributes.icon} )} {attributes.title && ( {attributes.title} )} {children || (attributes?.content && ( {attributes.content} ))} {(attributes.proceed || attributes.close || attributes.buttons?.length) && ( {attributes.proceed && ( { await attributes.proceed.action(setLoading); onClose(); }} disabled={attributes.proceed.disabled} > {attributes.proceed.text} )} {attributes.close && ( )} {attributes.buttons && attributes.buttons.map((b) => ( ))} )} ); }