blob: b909ef58ab70edf4eff8ea1eb96e6194c4648b84 (
plain) (
blame)
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
|
import { Box, Button, Form, FormButtons, FormSubmitButton } from '@umami/react-zen';
import type { ReactNode } from 'react';
import { useMessages } from '@/components/hooks';
export interface ConfirmationFormProps {
message: ReactNode;
buttonLabel?: ReactNode;
buttonVariant?: 'primary' | 'quiet' | 'danger';
isLoading?: boolean;
error?: string | Error;
onConfirm?: () => void;
onClose?: () => void;
}
export function ConfirmationForm({
message,
buttonLabel,
buttonVariant,
isLoading,
error,
onConfirm,
onClose,
}: ConfirmationFormProps) {
const { formatMessage, labels, getErrorMessage } = useMessages();
return (
<Form onSubmit={onConfirm} error={getErrorMessage(error)}>
<Box marginY="4">{message}</Box>
<FormButtons>
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
<FormSubmitButton
data-test="button-confirm"
isLoading={isLoading}
variant={buttonVariant}
isDisabled={false}
>
{buttonLabel || formatMessage(labels.ok)}
</FormSubmitButton>
</FormButtons>
</Form>
);
}
|