diff --git a/frontend/components/auth/AuthForm.tsx b/frontend/components/auth/AuthForm.tsx
index 349e640..ca56e91 100644
--- a/frontend/components/auth/AuthForm.tsx
+++ b/frontend/components/auth/AuthForm.tsx
@@ -1,24 +1,23 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { cn } from "@/lib/utils";
-import { useState, useEffect } from "react";
-import { login, signup } from "@/app/auth/actions";
-import Link from "next/link";
-import { ArrowLeft, Eye, EyeOff } from "lucide-react";
-import { useSearchParams } from "next/navigation";
-import { motion, AnimatePresence } from "framer-motion";
-import { BorderBeam } from "@/components/magicui/border-beam";
+import React, { useState, useEffect } from 'react';
+import { useClient } from 'next-auth-client';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { cn } from '@/lib/utils';
+import { login, signup } from '@/app/auth/actions';
+import Link from 'next/link';
+import { ArrowLeft, Eye, EyeOff } from 'lucide-react';
+import { useSearchParams } from 'next/navigation';
+import { motion, AnimatePresence } from 'framer-motion';
+import { BorderBeam } from '@/components/magicui/border-beam';
interface AuthFormProps {
- initialFormType?: "login" | "signup";
+ initialFormType?: 'login' | 'signup';
}
-export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
+export function AuthForm({ initialFormType = 'login' }: AuthFormProps) {
const searchParams = useSearchParams();
- const urlType = searchParams.get("type") as "login" | "signup" | null;
+ const urlType = searchParams.get('type') as 'login' | 'signup' | null;
const [formType, setFormType] = useState<"login" | "signup">(
urlType || initialFormType
@@ -37,12 +36,12 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
}, [urlType]);
const toggleForm = () => {
- const newType = formType === "login" ? "signup" : "login";
+ const newType = formType === 'login' ? 'signup' : 'login';
setFormType(newType);
setError(null);
setMessage(null);
// Update URL when toggling
- window.history.pushState({}, "", `/auth?type=${newType}`);
+ window.history.pushState({}, '', `/auth?type=${newType}`);
};
async function onSubmit(formData: FormData) {
@@ -51,12 +50,12 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
setMessage(null);
try {
- if (formType === "signup") {
- const password = formData.get("password") as string;
- const confirmPassword = formData.get("confirmPassword") as string;
+ if (formType === 'signup') {
+ const password = formData.get('password') as string;
+ const confirmPassword = formData.get('confirmPassword') as string;
if (password !== confirmPassword) {
- setError("Passwords do not match");
+ setError('Passwords do not match');
setIsLoading(false);
return;
}
@@ -65,7 +64,7 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
if (error) {
setError(error);
} else {
- setMessage("Account created successfully.");
+ setMessage('Account created successfully.');
}
} else {
const { error } = await login(formData);
@@ -74,8 +73,8 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
}
}
} catch (error) {
- console.error("Authentication error:", error);
- setError("Authentication failed. Please try again.");
+ console.error('Authentication error:', error);
+ setError('Authentication failed. Please try again.');
} finally {
setIsLoading(false);
}
@@ -91,12 +90,12 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
- {formType === "login" ? "Welcome back" : "Create an account"}
+ {formType === 'login' ? 'Welcome back' : 'Create an account'}
- {formType === "login"
- ? "Enter your credentials to access your account"
- : "Enter your details to create your account"}
+ {formType === 'login'
+ ? 'Enter your credentials to access your account'
+ : 'Enter your details to create your account'}
@@ -110,15 +109,14 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
Login
Sign up
@@ -127,8 +125,8 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
@@ -158,12 +156,12 @@ export function AuthForm({ initialFormType = "login" }: AuthFormProps) {
-
+
- ) : formType === "login" ? (
- "Sign in"
+ ) : formType === 'login' ? (
+ 'Sign in'
) : (
- "Create account"
+ 'Create account'
)}