diff options
| author | Fuwn <[email protected]> | 2026-01-24 13:09:50 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-24 13:09:50 +0000 |
| commit | 396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b (patch) | |
| tree | b9df4ca6a70db45cfffbae6fdd7252e20fb8e93c /src/app/(main)/teams/TeamJoinForm.tsx | |
| download | umami-main.tar.xz umami-main.zip | |
Created from https://vercel.com/new
Diffstat (limited to 'src/app/(main)/teams/TeamJoinForm.tsx')
| -rw-r--r-- | src/app/(main)/teams/TeamJoinForm.tsx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/app/(main)/teams/TeamJoinForm.tsx b/src/app/(main)/teams/TeamJoinForm.tsx new file mode 100644 index 0000000..6978078 --- /dev/null +++ b/src/app/(main)/teams/TeamJoinForm.tsx @@ -0,0 +1,40 @@ +import { + Button, + Form, + FormButtons, + FormField, + FormSubmitButton, + TextField, +} from '@umami/react-zen'; +import { useMessages, useUpdateQuery } from '@/components/hooks'; + +export function TeamJoinForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) { + const { formatMessage, labels, getErrorMessage } = useMessages(); + const { mutateAsync, error, touch } = useUpdateQuery('/teams/join'); + + const handleSubmit = async (data: any) => { + await mutateAsync(data, { + onSuccess: async () => { + touch('teams:members'); + onSave?.(); + onClose?.(); + }, + }); + }; + + return ( + <Form onSubmit={handleSubmit} error={getErrorMessage(error)}> + <FormField + label={formatMessage(labels.accessCode)} + name="accessCode" + rules={{ required: formatMessage(labels.required) }} + > + <TextField autoComplete="off" /> + </FormField> + <FormButtons> + <Button onPress={onClose}>{formatMessage(labels.cancel)}</Button> + <FormSubmitButton variant="primary">{formatMessage(labels.join)}</FormSubmitButton> + </FormButtons> + </Form> + ); +} |