import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { UserCreateOneSchema } from "@repo/db/shared"; import { useState } from "react"; import { useAuth } from "../hooks/use-auth"; import { Redirect } from "wouter"; import { Button } from "../components/ui/button"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "../components/ui/form"; import { Input } from "../components/ui/input"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "../components/ui/tabs"; import { Checkbox } from "../components/ui/checkbox"; import { Card, CardContent } from "../components/ui/card"; import { BriefcaseMedical, CheckCircle, Torus } from "lucide-react"; const loginSchema = UserCreateOneSchema.extend({ rememberMe: z.boolean().optional(), }); const registerSchema = UserCreateOne.extend({ confirmPassword: z.string().min(6, { message: "Password must be at least 6 characters long", }), agreeTerms: z.literal(true, { errorMap: () => ({ message: "You must agree to the terms and conditions" }), }), }).refine((data:any) => data.password === data.confirmPassword, { message: "Passwords don't match", path: ["confirmPassword"], }); type LoginFormValues = z.infer; type RegisterFormValues = z.infer; export default function AuthPage() { const [activeTab, setActiveTab] = useState("login"); const { user, loginMutation, registerMutation } = useAuth(); const loginForm = useForm({ resolver: zodResolver(loginSchema), defaultValues: { username: "", password: "", rememberMe: false, }, }); const registerForm = useForm({ resolver: zodResolver(registerSchema), defaultValues: { username: "", password: "", confirmPassword: "", agreeTerms: false, }, }); const onLoginSubmit = (data: LoginFormValues) => { loginMutation.mutate({ username: data.username, password: data.password, }); }; const onRegisterSubmit = (data: RegisterFormValues) => { registerMutation.mutate({ username: data.username, password: data.password, }); }; // Redirect if already logged in if (user) { return ; } return (
{/* Auth Forms */}

DentalConnect

Patient Management System

Login Register
( Username )} /> ( Password )} />
(
)} /> Forgot password?
( Username )} /> ( Password )} /> ( Confirm Password )} /> (
I agree to the Terms and Conditions
)} />
{/* Hero Section */}

Welcome to DentalConnect

The complete solution for dental practice management. Streamline your patient records, appointments, and more.

  • Easily manage patient records
  • Track patient insurance information
  • Secure and compliant data storage
  • Simple and intuitive interface
); }