diff --git a/src/app/pages/SignInPage/page.js b/src/app/pages/SignInPage/page.js
deleted file mode 100644
index 66832a3..0000000
--- a/src/app/pages/SignInPage/page.js
+++ /dev/null
@@ -1,330 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import Link from "next/link";
-import Button1 from "../../ui/buttons/button1";
-import { account } from "../../lib/appwrite";
-import { useRouter } from "next/navigation";
-import { useAuth } from "../../context/AuthContext";
-
-
-
-export default function SignInPage() {
- const [darkMode, setDarkMode] = useState(false);
- const { setIsAuthenticated } = useAuth();
- const router = useRouter();
- const [formData, setFormData] = useState({
- email: "",
- password: "",
- rememberMe: false,
- });
- const [showPassword, setShowPassword] = useState(false);
- const [loading, setLoading] = useState(false);
-
- useEffect(() => {
- const checkAuth = async () => {
- try {
- const user = await account.get();
- if (user) {
- localStorage.setItem("isLoggedIn", "true");
- router.push("/dashboard");
- }
- } catch (error) {
- console.warn("No active session:", error);
- localStorage.removeItem("isLoggedIn");
- }
- };
- checkAuth();
- }, [router]);
-
- const handleChange = (e) => {
- const { name, value, type, checked } = e.target;
- setFormData({
- ...formData,
- [name]: type === "checkbox" ? checked : value,
- });
- };
-
- const handleSubmit = async (e) => {
- e.preventDefault();
- setLoading(true);
-
- try {
- // Use the correct method name: createEmailPasswordSession
- const session = await account.createEmailPasswordSession(
- formData.email,
- formData.password
- );
-
- if (session) {
- const user = await account.get();
-
- if (user) {
- localStorage.setItem("isLoggedIn", "true");
- setIsAuthenticated(true);
- router.push("/dashboard");
- }
- }
- } catch (error) {
- // console.error("Login error:", error);
-
- // Improved error handling
- let errorMessage = 'Login failed. Please try again.';
- if (error.type === 'user_invalid_credentials') {
- errorMessage = 'Invalid email or password';
- } else if (error.type === 'general_argument_invalid') {
- errorMessage = 'Invalid email format';
- }
-
- alert(errorMessage);
- } finally {
- setLoading(false);
- }
- };
-
- return (
-
- {/* Left Side - Form */}
-
-
-
-
- Back to dashboard
-
-
-
-
- Sign In
-
-
- Enter your email and password to sign in!
-
-
-
-
-
-
-
- Don't have an accoun?{" "}
-
- Sign Up
-
-
-
-
-
-
- {/* Right Side - Decorative */}
- {/*
-
-
-
-
-
-
-
- Free and Open-Source Tailwind CSS Admin Dashboard Template
-
-
-
-
*/}
-
- {/* Dark Mode Toggler */}
-
-
- );
-}
\ No newline at end of file
diff --git a/src/app/pages/SignUpPage/page.js b/src/app/pages/SignUpPage/page.js
deleted file mode 100644
index 66d55cf..0000000
--- a/src/app/pages/SignUpPage/page.js
+++ /dev/null
@@ -1,360 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
-import { account, ID } from "../../lib/appwrite";
-import { useAuth } from "../../context/AuthContext";
-import Button1 from "../../ui/buttons/button1";
-
-export default function SignUpPage() {
- const [darkMode, setDarkMode] = useState(false);
- const [formData, setFormData] = useState({
- fname: "",
- lname: "",
- email: "",
- password: "",
- agreeTerms: false,
- });
- const [showPassword, setShowPassword] = useState(false);
- const [loading, setLoading] = useState(false);
- const router = useRouter();
- const { setIsAuthenticated } = useAuth();
-
- useEffect(() => {
- const checkAuth = async () => {
- try {
- const user = await account.get();
- if (user) {
- localStorage.setItem("isLoggedIn", "true");
- router.push("/dashboard");
- }
- } catch (error) {
- console.warn("No active session:", error);
- localStorage.removeItem("isLoggedIn");
- }
- };
- checkAuth();
- }, [router]);
-
- const handleChange = (e) => {
- const { name, value, type, checked } = e.target;
- setFormData({
- ...formData,
- [name]: type === "checkbox" ? checked : value,
- });
- };
-
- const handleSubmit = async (e) => {
- e.preventDefault();
-
- if (!formData.agreeTerms) {
- alert("You must agree to the terms and conditions");
- return;
- }
-
- setLoading(true);
- try {
- // Create user account
- await account.create(
- ID.unique(),
- formData.email,
- formData.password,
- `${formData.fname} ${formData.lname}`
- );
-
- // Create session immediately after signup
- await account.createEmailPasswordSession(formData.email, formData.password);
-
- const user = await account.get();
- if (user) {
- localStorage.setItem("isLoggedIn", "true");
- setIsAuthenticated(true);
- router.push("/dashboard");
- }
- } catch (error) {
- console.error("Signup error:", error);
- alert(`Signup failed: ${error.message}`);
- } finally {
- setLoading(false);
- }
- };
-
- return (
-
-
- {/* Form */}
-
-
-
-
- Back to dashboard
-
-
-
-
-
- Sign Up
-
-
- Enter your email and password to sign up!
-
-
-
-
-
-
- Already have an account?
-
- Sign In
-
-
-
-
-
-
-
- {/* Toggler */}
-
{/* Removed 'hidden' class */}
-
-
-
-
- );
-}
\ No newline at end of file
diff --git a/src/app/signup/page.js b/src/app/signup/page.js
deleted file mode 100644
index 0a4b9bf..0000000
--- a/src/app/signup/page.js
+++ /dev/null
@@ -1,415 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
-import { account, ID } from "../lib/appwrite";
-import { useAuth } from "../context/AuthContext";
-import Button1 from "../ui/buttons/button1";
-
-export default function SignUpPage() {
- const [darkMode, setDarkMode] = useState(false);
- const [formData, setFormData] = useState({
- fname: "",
- lname: "",
- email: "",
- password: "",
- agreeTerms: false,
- });
- const [errors, setErrors] = useState({
- agreeTerms: "",
- general: "",
- });
- const [showPassword, setShowPassword] = useState(false);
- const [loading, setLoading] = useState(false);
- const router = useRouter();
- const { setIsAuthenticated } = useAuth();
-
- useEffect(() => {
- const checkAuth = async () => {
- try {
- const user = await account.get();
- if (user) {
- localStorage.setItem("isLoggedIn", "true");
- router.push("/dashboard");
- }
- } catch (error) {
- console.warn("No active session:", error);
- localStorage.removeItem("isLoggedIn");
- }
- };
- checkAuth();
- }, [router]);
-
- const handleChange = (e) => {
- const { name, value, type, checked } = e.target;
- setFormData({
- ...formData,
- [name]: type === "checkbox" ? checked : value,
- });
- // Clear error when user interacts with the field
- if (name === "agreeTerms") {
- setErrors({ ...errors, agreeTerms: "" });
- }
- };
-
- const validateForm = () => {
- let isValid = true;
- const newErrors = { ...errors };
-
- if (!formData.agreeTerms) {
- newErrors.agreeTerms = "You must agree to the terms and conditions";
- isValid = false;
- } else {
- newErrors.agreeTerms = "";
- }
-
- setErrors(newErrors);
- return isValid;
- };
-
- const handleSubmit = async (e) => {
- e.preventDefault();
-
- if (!validateForm()) {
- return;
- }
-
- setLoading(true);
- try {
- await account.create(
- ID.unique(),
- formData.email,
- formData.password,
- `${formData.fname} ${formData.lname}`
- );
- await account.createEmailPasswordSession(formData.email, formData.password);
- const user = await account.get();
- if (user) {
- localStorage.setItem("isLoggedIn", "true");
- setIsAuthenticated(true);
- router.push("/dashboard");
- }
- } catch (error) {
- console.error("Signup error:", error);
- setErrors({
- ...errors,
- general: error.message || "Signup failed. Please try again.",
- });
- } finally {
- setLoading(false);
- }
- };
-
- return (
-
-
- {/* Left side - Form */}
-
-
-
-
-
- Back to dashboard
-
-
-
-
-
- Sign Up
-
-
- Enter your details to create an account!
-
-
-
- {errors.general && (
-
- {errors.general}
-
- )}
-
-
-
-
-
- Already have an account?
-
- Sign In
-
-
-
-
-
-
- {/* Right side - Decorative */}
- {/*
-
-
-
-
-
-
-
- Free and Open-Source Tailwind CSS Admin Dashboard Template
-
-
-
-
*/}
-
- {/* Dark Mode Toggler */}
-
-
-
-
-
- );
-}
\ No newline at end of file