aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/TypeConfirmationForm.tsx
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-24 13:09:50 +0000
committerFuwn <[email protected]>2026-01-24 13:09:50 +0000
commit396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b (patch)
treeb9df4ca6a70db45cfffbae6fdd7252e20fb8e93c /src/components/common/TypeConfirmationForm.tsx
downloadumami-main.tar.xz
umami-main.zip
Initial commitHEADmain
Created from https://vercel.com/new
Diffstat (limited to 'src/components/common/TypeConfirmationForm.tsx')
-rw-r--r--src/components/common/TypeConfirmationForm.tsx55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/components/common/TypeConfirmationForm.tsx b/src/components/common/TypeConfirmationForm.tsx
new file mode 100644
index 0000000..1121fa7
--- /dev/null
+++ b/src/components/common/TypeConfirmationForm.tsx
@@ -0,0 +1,55 @@
+import {
+ Button,
+ Form,
+ FormButtons,
+ FormField,
+ FormSubmitButton,
+ TextField,
+} from '@umami/react-zen';
+import { useMessages } from '@/components/hooks';
+
+export function TypeConfirmationForm({
+ confirmationValue,
+ buttonLabel,
+ buttonVariant,
+ isLoading,
+ error,
+ onConfirm,
+ onClose,
+}: {
+ confirmationValue: string;
+ buttonLabel?: string;
+ buttonVariant?: 'primary' | 'outline' | 'quiet' | 'danger' | 'zero';
+ isLoading?: boolean;
+ error?: string | Error;
+ onConfirm?: () => void;
+ onClose?: () => void;
+}) {
+ const { formatMessage, labels, messages, getErrorMessage } = useMessages();
+ if (!confirmationValue) {
+ return null;
+ }
+
+ return (
+ <Form onSubmit={onConfirm} error={getErrorMessage(error)}>
+ <p>
+ {formatMessage(messages.actionConfirmation, {
+ confirmation: confirmationValue,
+ })}
+ </p>
+ <FormField
+ label={formatMessage(labels.confirm)}
+ name="confirm"
+ rules={{ validate: value => value === confirmationValue }}
+ >
+ <TextField autoComplete="off" />
+ </FormField>
+ <FormButtons>
+ <Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
+ <FormSubmitButton isLoading={isLoading} variant={buttonVariant}>
+ {buttonLabel || formatMessage(labels.ok)}
+ </FormSubmitButton>
+ </FormButtons>
+ </Form>
+ );
+}