import { Button, PasswordInput, Stack, TextInput, Title } from '@mantine/core'; import { useForm } from '@mantine/form'; import { signIn } from 'next-auth/react'; import { useState } from 'react'; import { z } from 'zod'; import { api } from '~/utils/api'; import { useI18nZodResolver } from '~/utils/i18n-zod-resolver'; import { signUpFormSchema } from '~/validations/user'; import { OnboardingStepWrapper } from './common-wrapper'; export const StepCreateAccount = ({ next }: { next: () => void }) => { const [isSigninIn, setIsSigninIn] = useState(false); const { mutateAsync } = api.user.createOwnerAccount.useMutation(); const { i18nZodResolver } = useI18nZodResolver(); const form = useForm>({ validate: i18nZodResolver(signUpFormSchema), validateInputOnBlur: true, }); const handleSubmit = (values: z.infer) => { setIsSigninIn(true); void mutateAsync(values, { onSuccess: () => { signIn('credentials', { redirect: false, name: values.username, password: values.password, callbackUrl: '/', }).then((response) => { if (!response?.ok) { setIsSigninIn(false); return; } next(); }); }, }); }; return ( Create your administrator account
); };