import { Text } from "preact-i18n"; import { useState } from "preact/hooks"; import { useForm } from "react-hook-form"; import styles from "./Onboarding.module.scss"; import { takeError } from "../../revoltjs/util"; import Button from "../../../components/ui/Button"; import FormField from "../../../pages/login/FormField"; import Preloader from "../../../components/ui/Preloader"; interface Props { onClose: () => void; callback: (username: string, loginAfterSuccess?: true) => Promise; } export function OnboardingModal({ onClose, callback }: Props) { const { handleSubmit, register } = useForm(); const [loading, setLoading] = useState(false); const [error, setError] = useState(undefined); async function onSubmit({ username }: { username: string }) { setLoading(true); callback(username, true) .then(onClose) .catch((err: any) => { setError(takeError(err)); setLoading(false); }); } return (

{loading ? ( ) : ( <>

)}
); }