diff --git a/apps/login/src/components/invite-form.tsx b/apps/login/src/components/invite-form.tsx deleted file mode 100644 index 35c0bec028..0000000000 --- a/apps/login/src/components/invite-form.tsx +++ /dev/null @@ -1,143 +0,0 @@ -"use client"; - -import { inviteUser } from "@/lib/server/invite"; -import { useTranslations } from "next-intl"; -import { useRouter } from "next/navigation"; -import { useState } from "react"; -import { FieldValues, useForm } from "react-hook-form"; -import { Alert } from "./alert"; -import { BackButton } from "./back-button"; -import { Button, ButtonVariants } from "./button"; -import { TextInput } from "./input"; -import { Spinner } from "./spinner"; - -type Inputs = - | { - firstname: string; - lastname: string; - email: string; - } - | FieldValues; - -type Props = { - firstname?: string; - lastname?: string; - email?: string; - organization?: string; -}; - -export function InviteForm({ - email, - firstname, - lastname, - organization, -}: Props) { - const t = useTranslations("register"); - - const { register, handleSubmit, formState } = useForm({ - mode: "onBlur", - defaultValues: { - email: email ?? "", - firstName: firstname ?? "", - lastname: lastname ?? "", - }, - }); - - const [loading, setLoading] = useState(false); - const [error, setError] = useState(""); - - const router = useRouter(); - - async function submitAndContinue(values: Inputs) { - setLoading(true); - const response = await inviteUser({ - email: values.email, - firstName: values.firstname, - lastName: values.lastname, - organization: organization, - }) - .catch(() => { - setError("Could not create invitation Code"); - return; - }) - .finally(() => { - setLoading(false); - }); - - if (response && typeof response === "object" && "error" in response) { - setError(response.error); - return; - } - - if (!response) { - setError("Could not create invitation Code"); - return; - } - - const params = new URLSearchParams({}); - - if (response) { - params.append("userId", response); - } - - return router.push(`/invite/success?` + params); - } - - const { errors } = formState; - - return ( -
-
-
- -
-
- -
-
- -
-
- - {error && ( -
- {error} -
- )} - -
- - -
-
- ); -}