mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { useMessages, useUpdateQuery } from '@/components/hooks';
|
|
import {
|
|
Button,
|
|
Form,
|
|
FormButtons,
|
|
FormField,
|
|
FormSubmitButton,
|
|
TextField,
|
|
} from '@umami/react-zen';
|
|
|
|
export function TeamAddForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) {
|
|
const { formatMessage, 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={formatMessage(labels.name)}>
|
|
<TextField autoComplete="off" />
|
|
</FormField>
|
|
<FormButtons>
|
|
<Button isDisabled={isPending} onPress={onClose}>
|
|
{formatMessage(labels.cancel)}
|
|
</Button>
|
|
<FormSubmitButton variant="primary" isDisabled={isPending}>
|
|
{formatMessage(labels.save)}
|
|
</FormSubmitButton>
|
|
</FormButtons>
|
|
</Form>
|
|
);
|
|
}
|