diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx index 514de9c..50fc611 100644 --- a/src/app/register/page.tsx +++ b/src/app/register/page.tsx @@ -1,382 +1,50 @@ "use client"; import { useState } from "react"; -import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; -import NavbarStyleFullscreen from "@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen"; -import FooterLogoReveal from "@/components/sections/footer/FooterLogoReveal"; -import { Eye, EyeOff, AlertCircle, CheckCircle } from "lucide-react"; - -interface FormData { - firstName: string; - lastName: string; - email: string; - password: string; - confirmPassword: string; - userType: "student" | "teacher" | ""; -} - -interface FormErrors { - firstName?: string; - lastName?: string; - email?: string; - password?: string; - confirmPassword?: string; - userType?: string; -} export default function RegisterPage() { - const navItems = [ - { name: "Ana Sayfa", id: "/" }, - { name: "Öğretmenler", id: "/teachers" }, - { name: "Etkinlikler", id: "events" }, - { name: "Çalışma Programı", id: "schedule" }, - ]; + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); - const [formData, setFormData] = useState({ - firstName: "", lastName: "", email: "", password: "", confirmPassword: "", userType: ""}); - - const [errors, setErrors] = useState({}); - const [showPassword, setShowPassword] = useState(false); - const [showConfirmPassword, setShowConfirmPassword] = useState(false); - const [isSubmitting, setIsSubmitting] = useState(false); - const [submitSuccess, setSubmitSuccess] = useState(false); - - const validateForm = (): boolean => { - const newErrors: FormErrors = {}; - - if (!formData.firstName.trim()) { - newErrors.firstName = "Ad gereklidir"; - } else if (formData.firstName.length < 2) { - newErrors.firstName = "Ad en az 2 karakter olmalıdır"; - } - - if (!formData.lastName.trim()) { - newErrors.lastName = "Soyad gereklidir"; - } else if (formData.lastName.length < 2) { - newErrors.lastName = "Soyad en az 2 karakter olmalıdır"; - } - - if (!formData.email.trim()) { - newErrors.email = "E-posta gereklidir"; - } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) { - newErrors.email = "Geçerli bir e-posta adresi girin"; - } - - if (!formData.password) { - newErrors.password = "Şifre gereklidir"; - } else if (formData.password.length < 8) { - newErrors.password = "Şifre en az 8 karakter olmalıdır"; - } else if (!/[A-Z]/.test(formData.password)) { - newErrors.password = "Şifre en az bir büyük harf içermelidir"; - } else if (!/[0-9]/.test(formData.password)) { - newErrors.password = "Şifre en az bir rakam içermelidir"; - } - - if (formData.password !== formData.confirmPassword) { - newErrors.confirmPassword = "Şifreler eşleşmiyor"; - } - - if (!formData.userType) { - newErrors.userType = "Kullanıcı türünü seçin"; - } - - setErrors(newErrors); - return Object.keys(newErrors).length === 0; - }; - - const handleChange = ( - e: React.ChangeEvent - ) => { - const { name, value } = e.target; - setFormData((prev) => ({ - ...prev, - [name]: value, - })); - if (errors[name as keyof FormErrors]) { - setErrors((prev) => ({ - ...prev, - [name]: undefined, - })); - } - }; - - const handleSubmit = async (e: React.FormEvent) => { + const handleRegister = async (e: React.FormEvent) => { e.preventDefault(); - - if (!validateForm()) { - return; - } - - setIsSubmitting(true); - try { - const response = await fetch("/api/auth/register", { - method: "POST", headers: { - "Content-Type": "application/json"}, - body: JSON.stringify({ - firstName: formData.firstName, - lastName: formData.lastName, - email: formData.email, - password: formData.password, - userType: formData.userType, - }), - }); - - if (response.ok) { - setSubmitSuccess(true); - setFormData({ - firstName: "", lastName: "", email: "", password: "", confirmPassword: "", userType: ""}); - setTimeout(() => { - setSubmitSuccess(false); - }, 5000); - } else { - const data = await response.json(); - setErrors({ email: data.message || "Kayıt başarısız oldu" }); - } - } catch (error) { - setErrors({ email: "Bir hata oluştu. Lütfen tekrar deneyin." }); - } finally { - setIsSubmitting(false); + console.log("Registering with:", email, password); + } catch (err) { + console.log("Registration failed"); } }; return ( - - - -
-
-
-

Hesap Oluştur

-

Eğitim yolculuğunuza bugün başlayın

-
- - {submitSuccess && ( -
- -
-

Başarılı!

-

- Hesabınız başarıyla oluşturuldu. Şimdi giriş yapabilirsiniz. -

-
-
- )} - - -
- - - {errors.userType && ( -
- - {errors.userType} -
- )} -
- -
- - - {errors.firstName && ( -
- - {errors.firstName} -
- )} -
- -
- - - {errors.lastName && ( -
- - {errors.lastName} -
- )} -
- -
- - - {errors.email && ( -
- - {errors.email} -
- )} -
- -
- -
- - -
- {errors.password && ( -
- - {errors.password} -
- )} -
- -
- -
- - -
- {errors.confirmPassword && ( -
- - {errors.confirmPassword} -
- )} -
- - - - -
-

- Zaten hesabınız var mı?{" "} - - Giriş yapın - -

-
-
-
- - -
+ setConfirmPassword(e.target.value)} + placeholder="Confirm Password" + className="w-full p-2 mb-4 border rounded" + /> + + + ); }