feat: add handle to AlertDialog

This commit is contained in:
Pavel Prichodko 2022-06-15 14:12:21 +02:00
parent 36aeebb629
commit 8dbe361c86
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
1 changed files with 5 additions and 1 deletions

View File

@ -40,6 +40,7 @@ interface DialogProps {
description: string
actionLabel: string
actionVariant?: ButtonProps['variant']
onAction: VoidFunction
cancelLabel?: string
onOpenAutoFocus?: DialogContentProps['onOpenAutoFocus']
onCloseAutoFocus?: DialogContentProps['onCloseAutoFocus']
@ -51,6 +52,7 @@ const AlertDialog = (props: DialogProps) => {
description,
actionLabel,
actionVariant,
onAction,
cancelLabel = 'Cancel',
...contentProps
} = props
@ -77,7 +79,9 @@ const AlertDialog = (props: DialogProps) => {
<Button>{cancelLabel}</Button>
</Primitive.Cancel>
<Primitive.Action asChild>
<Button variant={actionVariant}>{actionLabel}</Button>
<Button variant={actionVariant} onClick={onAction}>
{actionLabel}
</Button>
</Primitive.Action>
</Actions>
</Content>