import { FC, useState } from "react"; import { useForm, Controller } from "react-hook-form"; import { Eye, EyeOff, XCircle } from "lucide-react"; // ui import { Input, Button, TOAST_TYPE, setToast } from "@plane/ui"; // helpers import { checkEmailValidity } from "helpers/string.helper"; // hooks import { useUser } from "hooks/store"; // services import { AuthService } from "services/auth.service"; const authService = new AuthService(); interface InstanceSetupEmailFormValues { email: string; password: string; } export interface IInstanceSetupEmailForm { handleNextStep: (email: string) => void; } export const InstanceSetupSignInForm: FC = (props) => { const { handleNextStep } = props; // states const [showPassword, setShowPassword] = useState(false); // store hooks const { fetchCurrentUser } = useUser(); // form info const { control, formState: { errors, isSubmitting }, handleSubmit, setValue, } = useForm({ defaultValues: { email: "", password: "", }, }); const handleFormSubmit = async (formValues: InstanceSetupEmailFormValues) => { const payload = { email: formValues.email, password: formValues.password, }; await authService .instanceAdminSignIn(payload) .then(async () => { await fetchCurrentUser(); handleNextStep(formValues.email); }) .catch((err) => { setToast({ type: TOAST_TYPE.ERROR, title: "Error!", message: err?.error ?? "Something went wrong. Please try again.", }); }); }; return (

Let{"'"}s secure your instance

Explore privacy options. Get AI features. Secure access.
Takes 2 minutes.

checkEmailValidity(value) || "Email is invalid", }} render={({ field: { value, onChange } }) => (
{value.length > 0 && ( setValue("email", "")} /> )}
)} /> (
{showPassword ? ( setShowPassword(false)} /> ) : ( setShowPassword(true)} /> )}
)} />

Use your email address if you are the instance admin.
Use your admin’s e-mail if you are not.

); };