import { H2, LoadingOverlay, Paragraph, SubmitButton, Theme, YStack } from '@my/ui' import { getBaseUrl } from 'app/utils/getBaseUrl' import { SchemaForm, formFields } from 'app/utils/SchemaForm' import { useSupabase } from 'app/utils/supabase/useSupabase' import { useUser } from 'app/utils/useUser' import { useState } from 'react' import { FormProvider, useForm } from 'react-hook-form' import { useRouter } from 'solito/router' import { z } from 'zod' const SignInSchema = z.object({ email: formFields.text.email().describe('Email // Enter your email'), }) export const SignInScreen = () => { const database = useSupabase() const router = useRouter() const { isLoadingSession } = useUser() const [email, setEmail] = useState('') const form = useForm>() const baseUrl = getBaseUrl() async function signInWithEmail({ email }: z.infer) { const { error } = await database.auth.signInWithOtp({ email, options: { emailRedirectTo: baseUrl }, }) if (error) { form.setError('email', { type: 'custom', message: "Failed to send passcode. Please check your email." }) } else { setEmail(email) router.push(`/sign-in-verify?email=${encodeURIComponent(email)}`) } } return ( ( submit()} br="$10"> Send Code )} > {(fields) => ( <>

Sign In

What is your email? I will send you a code with which you can sign in (or a sign up link if you do not have an account).
{Object.values(fields)} )}
{isLoadingSession && }
) }