aboutsummaryrefslogtreecommitdiff
path: root/src/app/(main)/websites/WebsiteAddForm.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/app/(main)/websites/WebsiteAddForm.tsx
downloadumami-396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b.tar.xz
umami-396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b.zip
Initial commitHEADmain
Created from https://vercel.com/new
Diffstat (limited to 'src/app/(main)/websites/WebsiteAddForm.tsx')
-rw-r--r--src/app/(main)/websites/WebsiteAddForm.tsx60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/app/(main)/websites/WebsiteAddForm.tsx b/src/app/(main)/websites/WebsiteAddForm.tsx
new file mode 100644
index 0000000..df17ad5
--- /dev/null
+++ b/src/app/(main)/websites/WebsiteAddForm.tsx
@@ -0,0 +1,60 @@
+import { Button, Form, FormField, FormSubmitButton, Row, TextField } from '@umami/react-zen';
+import { useMessages, useUpdateQuery } from '@/components/hooks';
+import { DOMAIN_REGEX } from '@/lib/constants';
+
+export function WebsiteAddForm({
+ teamId,
+ onSave,
+ onClose,
+}: {
+ teamId?: string;
+ onSave?: () => void;
+ onClose?: () => void;
+}) {
+ const { formatMessage, labels, messages } = useMessages();
+ const { mutateAsync, error, isPending } = useUpdateQuery('/websites', { teamId });
+
+ const handleSubmit = async (data: any) => {
+ await mutateAsync(data, {
+ onSuccess: async () => {
+ onSave?.();
+ onClose?.();
+ },
+ });
+ };
+
+ return (
+ <Form onSubmit={handleSubmit} error={error?.message}>
+ <FormField
+ label={formatMessage(labels.name)}
+ data-test="input-name"
+ name="name"
+ rules={{ required: formatMessage(labels.required) }}
+ >
+ <TextField autoComplete="off" />
+ </FormField>
+
+ <FormField
+ label={formatMessage(labels.domain)}
+ data-test="input-domain"
+ name="domain"
+ rules={{
+ required: formatMessage(labels.required),
+ pattern: { value: DOMAIN_REGEX, message: formatMessage(messages.invalidDomain) },
+ }}
+ >
+ <TextField autoComplete="off" />
+ </FormField>
+ <Row justifyContent="flex-end" paddingTop="3" gap="3">
+ {onClose && (
+ <Button isDisabled={isPending} onPress={onClose}>
+ {formatMessage(labels.cancel)}
+ </Button>
+ )}
+ <FormSubmitButton data-test="button-submit" isDisabled={false}>
+ {formatMessage(labels.save)}
+ </FormSubmitButton>
+ </Row>
+ </Form>
+ );
+}