- 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>
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import {
|
|
Button,
|
|
Form,
|
|
FormButtons,
|
|
FormField,
|
|
FormSubmitButton,
|
|
TextField,
|
|
} from '@umami/react-zen';
|
|
import { useMessages, useUpdateQuery } from '@/components/hooks';
|
|
import { UserSelect } from '@/components/input/UserSelect';
|
|
|
|
export function TeamAddForm({
|
|
onSave,
|
|
onClose,
|
|
isAdmin,
|
|
}: {
|
|
onSave: () => void;
|
|
onClose: () => void;
|
|
isAdmin: boolean;
|
|
}) {
|
|
const { t, labels, getErrorMessage } = useMessages();
|
|
const { mutateAsync, error, isPending } = useUpdateQuery('/teams');
|
|
|
|
const handleSubmit = async (data: any) => {
|
|
await mutateAsync(data, {
|
|
onSuccess: async () => {
|
|
onSave?.();
|
|
onClose?.();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Form onSubmit={handleSubmit} error={getErrorMessage(error)}>
|
|
<FormField name="name" label={t(labels.name)}>
|
|
<TextField autoComplete="off" />
|
|
</FormField>
|
|
{isAdmin && (
|
|
<FormField name="ownerId" label={t(labels.teamOwner)}>
|
|
<UserSelect buttonProps={{ style: { outline: 'none' } }} />
|
|
</FormField>
|
|
)}
|
|
<FormButtons>
|
|
<Button isDisabled={isPending} onPress={onClose}>
|
|
{t(labels.cancel)}
|
|
</Button>
|
|
<FormSubmitButton variant="primary" isDisabled={isPending}>
|
|
{t(labels.save)}
|
|
</FormSubmitButton>
|
|
</FormButtons>
|
|
</Form>
|
|
);
|
|
}
|