remove button stack when no buttons present

This commit is contained in:
Abhinav 2023-03-31 12:47:00 +05:30
parent 7c12826d9c
commit 815ae666f3

View file

@ -42,13 +42,13 @@ export default function DialogBoxV2({
<Dialog
open={open}
onClose={handleClose}
{...props}
PaperProps={{
sx: {
padding: '8px 12px',
maxWidth: '360px',
},
}}>
}}
{...props}>
<Stack spacing={'36px'} p={'16px'}>
<Stack spacing={'19px'}>
{attributes.icon && (
@ -73,53 +73,57 @@ export default function DialogBoxV2({
</Typography>
))}
</Stack>
<Stack
spacing={'8px'}
direction={
attributes.buttonDirection === 'row'
? 'row-reverse'
: 'column'
}
flex={1}>
{attributes.proceed && (
<Button
size="large"
color={attributes.proceed?.variant}
onClick={() => {
attributes.proceed.action();
onClose();
}}
disabled={attributes.proceed.disabled}>
{attributes.proceed.text}
</Button>
)}
{attributes.close && (
<Button
size="large"
color={attributes.close?.variant ?? 'secondary'}
onClick={() => {
attributes.close.action &&
attributes.close?.action();
onClose();
}}>
{attributes.close?.text ?? t('OK')}
</Button>
)}
{attributes.buttons &&
attributes.buttons.map((b) => (
{(attributes.proceed ||
attributes.close ||
attributes.buttons?.length) && (
<Stack
spacing={'8px'}
direction={
attributes.buttonDirection === 'row'
? 'row-reverse'
: 'column'
}
flex={1}>
{attributes.proceed && (
<Button
size="large"
key={b.text}
color={b.variant}
color={attributes.proceed?.variant}
onClick={() => {
b.action();
attributes.proceed.action();
onClose();
}}
disabled={b.disabled}>
{b.text}
disabled={attributes.proceed.disabled}>
{attributes.proceed.text}
</Button>
))}
</Stack>
)}
{attributes.close && (
<Button
size="large"
color={attributes.close?.variant ?? 'secondary'}
onClick={() => {
attributes.close.action &&
attributes.close?.action();
onClose();
}}>
{attributes.close?.text ?? t('OK')}
</Button>
)}
{attributes.buttons &&
attributes.buttons.map((b) => (
<Button
size="large"
key={b.text}
color={b.variant}
onClick={() => {
b.action();
onClose();
}}
disabled={b.disabled}>
{b.text}
</Button>
))}
</Stack>
)}
</Stack>
</Dialog>
);