'use client'; import { emailLoginFormSchema } from '@repo/shared/lib/schemas/auth'; import { BetterAuth } from '@repo/shared/services/auth-client'; import { useForm } from '@tanstack/react-form'; import { Button } from '@workspace/ui/components/button'; import { Card, CardContent, CardFooter, CardHeader, } from '@workspace/ui/components/card'; import { Input } from '@workspace/ui/components/input'; import { Label } from '@workspace/ui/components/label'; import { Separator } from '@workspace/ui/components/separator'; import { Flex, Grid } from '@workspace/ui/design-system/spacing'; import Spinner from '@workspace/ui/design-system/spinner'; import { H3, LinkCode, Muted, Small, XSmall, } from '@workspace/ui/design-system/typography'; import FormMessage from '@workspace/ui/global/form/form-message'; import { Effect } from 'effect'; import { standardSchemaV1 } from 'effect/Schema'; import { ChevronsRight } from 'lucide-react'; import Link from 'next/link'; import { webRuntime } from '@/runtimes/web-runtime'; type AuthFormModes = 'sign-in' | 'sign-up'; const program = Effect.gen(function* () { const betterAuth = yield* BetterAuth; const authClient = yield* betterAuth.getClient; return { authClient }; }); const AuthForm = ({ mode, }: { mode: TFormMode; }) => { const programData = webRuntime.runSync(program); const form = useForm({ defaultValues: { email: '', password: '', }, validators: { onSubmit: standardSchemaV1(emailLoginFormSchema), }, onSubmit: async (values) => {}, }); return (

{mode === 'sign-in' ? 'Welcome Back' : 'Create Your Account'}

{mode === 'sign-in' ? 'Sign in to your CCE Connect account to continue' : 'Join CCE Connect and start your journey with us today'}
{ e.preventDefault(); e.stopPropagation(); form.handleSubmit(); }} > {(field) => ( <> field.handleChange(e.target.value)} placeholder="Enter your email address" value={field.state.value} /> )} {mode === 'sign-in' && ( Forgot your password? )} {(field) => ( <> field.handleChange(e.target.value)} placeholder={ mode === 'sign-in' ? 'Enter your password' : 'Create a strong password' } type="password" value={field.state.value} /> )} [state.canSubmit, state.isSubmitting]} > {([canSubmit, isSubmitting]) => ( )} {mode === 'sign-in' ? 'Or sign in with' : 'Or sign up with'}
{mode === 'sign-in' ? "Don't have an account?" : 'Already have an account?'}{' '} {mode === 'sign-in' ? 'Create one here' : 'Sign in here'}
); }; export default AuthForm;