- Rewrite messages.ts to plain string key maps (remove MessageDescriptor) - Rewrite useMessages hook to expose t from useTranslations() directly - Rename formatMessage → t across 193 consumer files - Replace custom FormattedMessage component with next-intl t.rich() - Update 52 language files to use rich text tags (<b>, <a>) - Remove all direct imports from @/components/messages in favor of useMessages() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
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 { t, labels, getErrorMessage } = useMessages();
|
|
|
|
return (
|
|
<Form onSubmit={onConfirm} error={getErrorMessage(error)}>
|
|
<Box marginY="4">{message}</Box>
|
|
<FormButtons>
|
|
<Button onPress={onClose}>{t(labels.cancel)}</Button>
|
|
<FormSubmitButton
|
|
data-test="button-confirm"
|
|
isLoading={isLoading}
|
|
variant={buttonVariant}
|
|
isDisabled={false}
|
|
>
|
|
{buttonLabel || t(labels.ok)}
|
|
</FormSubmitButton>
|
|
</FormButtons>
|
|
</Form>
|
|
);
|
|
}
|