From 1237f45142cdee53aacdac2d3232b84d969db548 Mon Sep 17 00:00:00 2001
From: Pheonix <150040105+ArshiBansal@users.noreply.github.com>
Date: Fri, 22 May 2026 15:57:34 +0530
Subject: [PATCH] added back to home feature
---
src/pages/Contact/Contact.tsx | 89 ++++++++++-----
src/pages/Login/Login.tsx | 118 +++++++++++++++-----
src/pages/Signup/Signup.tsx | 203 +++++++++++++++++++++-------------
3 files changed, 278 insertions(+), 132 deletions(-)
diff --git a/src/pages/Contact/Contact.tsx b/src/pages/Contact/Contact.tsx
index a0bfccbd..c9175686 100644
--- a/src/pages/Contact/Contact.tsx
+++ b/src/pages/Contact/Contact.tsx
@@ -6,16 +6,22 @@ import {
Send,
X,
CheckCircle,
+ ArrowLeft,
} from "lucide-react";
+import { useNavigate } from "react-router-dom";
+
import { ThemeContext } from "../../context/ThemeContext";
import type { ThemeContextType } from "../../context/ThemeContext";
function Contact() {
const [showPopup, setShowPopup] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
+
const themeContext = useContext(ThemeContext) as ThemeContextType;
const { mode } = themeContext;
+ const navigate = useNavigate();
+
const handleSubmit = async () => {
setIsSubmitting(true);
@@ -51,6 +57,33 @@ function Contact() {
+ {/* Back to Home Button */}
+
+
navigate("/")}
+ className={`group relative inline-flex items-center gap-2 overflow-hidden rounded-2xl px-5 py-3 text-sm sm:text-base font-semibold shadow-lg backdrop-blur-xl border transition-all duration-300 hover:scale-105 hover:-translate-y-0.5 active:scale-95 ${
+ mode === "dark"
+ ? "bg-white/10 text-white border-white/20 hover:bg-white/20"
+ : "bg-white/80 text-gray-800 border-gray-200 hover:bg-white"
+ }`}
+ >
+ {/* Glow Effect */}
+
+
+ {/* Icon */}
+
+
+ {/* Text */}
+ Back to Home
+
+
+
{/* Header Section */}
@@ -65,6 +98,7 @@ function Contact() {
className="w-10 h-10 sm:w-14 sm:h-14 object-contain"
/>
+
+
Let's Connect
+
- We're here to help you track and manage your GitHub
- repositories more effectively
+ We're here to help you track and manage your GitHub repositories
+ more effectively
@@ -128,8 +164,10 @@ function Contact() {
Icon: Github,
},
];
+
const { title, iconBg, detail, sub, Icon } =
contactTypes[index];
+
return (
+
{title}
+
{detail}
+
{sub}
@@ -209,13 +242,12 @@ function Contact() {
Full Name
+
Email Address
+
Subject
+
Select a subject
+
General Inquiry
Bug Report
Feature Request
@@ -285,13 +316,12 @@ function Contact() {
Message
+
@@ -332,9 +363,11 @@ function Contact() {
}`}
>
+
Thank you for contacting us! We will get back to you shortly.
+
{
- const [formData, setFormData] = useState({ email: "", password: "" });
+ const [formData, setFormData] = useState({
+ email: "",
+ password: "",
+ });
const [message, setMessage] = useState("");
const [isLoading, setIsLoading] = useState(false);
@@ -30,10 +34,13 @@ const Login: React.FC = () => {
setIsLoading(true);
try {
- const response = await axios.post(`${backendUrl}/api/auth/login`, formData);
+ const response = await axios.post(
+ `${backendUrl}/api/auth/login`,
+ formData,
+ );
setMessage(response.data.message);
- if (response.data.message === 'Login successful') {
+ if (response.data.message === "Login successful") {
navigate("/");
}
} catch (error: unknown) {
@@ -57,34 +64,85 @@ const Login: React.FC = () => {
>
{/* Animated background elements */}
+ {/* ✅ BACK TO HOME BUTTON (ADDED) */}
+
+
navigate("/")}
+ className={`group flex items-center gap-2 px-4 py-2 rounded-xl backdrop-blur-xl border transition-all duration-300 hover:scale-105 active:scale-95 ${
+ mode === "dark"
+ ? "bg-white/10 text-white border-white/20 hover:bg-white/20"
+ : "bg-white/70 text-gray-800 border-gray-200 hover:bg-white"
+ }`}
+ >
+
+ Back to Home
+
+
+
{/* Branding */}
-
+
-
+
GitHubTracker
-
+
Track your GitHub journey
{/* Form Card */}
-
-
+
+
Welcome Back
@@ -134,18 +192,24 @@ const Login: React.FC = () => {
{/* Message */}
{message && (
-
+
{message}
)}
- {/* Footer Text */}
+ {/* Footer */}
-
+
Don't have an account?
{
-
+
);
};
-export default Login;
\ No newline at end of file
+export default Login;
diff --git a/src/pages/Signup/Signup.tsx b/src/pages/Signup/Signup.tsx
index 2ac51dcc..880607c7 100644
--- a/src/pages/Signup/Signup.tsx
+++ b/src/pages/Signup/Signup.tsx
@@ -2,7 +2,7 @@ import React, { useState, useContext } from "react";
import axios from "axios";
import { useNavigate, Link } from "react-router-dom";
import { motion } from "framer-motion";
-import { User, Mail, Lock, Eye, EyeOff } from "lucide-react";
+import { User, Mail, Lock, Eye, EyeOff, ArrowLeft } from "lucide-react";
import { ThemeContext } from "../../context/ThemeContext";
import type { ThemeContextType } from "../../context/ThemeContext";
@@ -20,14 +20,17 @@ const SignUp: React.FC = () => {
email: "",
password: "",
});
+
const [message, setMessage] = useState("");
const [errors, setErrors] = useState({
username: "",
email: "",
password: "",
});
+
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
+
const navigate = useNavigate();
const themeContext = useContext(ThemeContext) as ThemeContextType;
const { mode } = themeContext;
@@ -35,7 +38,9 @@ const SignUp: React.FC = () => {
const handleChange = (e: React.ChangeEvent) => {
const { name, value } = e.target;
setFormData({ ...formData, [name]: value });
+
let errorMessage = "";
+
if (name === "username") {
if (!value.trim()) {
errorMessage = "Username is required";
@@ -43,6 +48,7 @@ const SignUp: React.FC = () => {
errorMessage = "Only letters are allowed";
}
}
+
if (name === "email") {
if (!value.trim()) {
errorMessage = "Email is required";
@@ -50,50 +56,71 @@ const SignUp: React.FC = () => {
errorMessage = "Enter a valid email";
}
}
+
if (name === "password") {
if (!value.trim()) {
errorMessage = "Password is required";
- } else if (!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/.test(value)) {
- errorMessage = "Password must be 8+ characters with letters and numbers";
+ } else if (
+ !/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/.test(value)
+ ) {
+ errorMessage =
+ "Password must be 8+ characters with letters and numbers";
}
}
+
setErrors((prev) => ({ ...prev, [name]: errorMessage }));
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
+
const usernameError = !formData.username.trim()
? "Username is required"
: !/^[A-Za-z\s]+$/.test(formData.username)
- ? "Only letters are allowed"
- : "";
+ ? "Only letters are allowed"
+ : "";
+
const emailError = !formData.email.trim()
? "Email is required"
: !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email.trim())
- ? "Enter a valid email"
- : "";
+ ? "Enter a valid email"
+ : "";
+
const passwordError = !formData.password.trim()
? "Password is required"
- : !/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/.test(formData.password)
- ? "Password must be 8+ characters with letters and numbers"
- : "";
+ : !/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/.test(
+ formData.password,
+ )
+ ? "Password must be 8+ characters with letters and numbers"
+ : "";
+
if (usernameError || emailError || passwordError) {
- setErrors({ username: usernameError, email: emailError, password: passwordError });
+ setErrors({
+ username: usernameError,
+ email: emailError,
+ password: passwordError,
+ });
return;
}
+
setIsLoading(true);
+
try {
- const response = await axios.post(`${backendUrl}/api/auth/signup`,
- formData // Include cookies for session
+ const response = await axios.post(
+ `${backendUrl}/api/auth/signup`,
+ formData,
);
- setMessage(response.data.message); // Show success message from backend
- // Navigate to login page after successful signup
- if (response.data.message === 'User created successfully') {
+ setMessage(response.data.message);
+
+ if (response.data.message === "User created successfully") {
navigate("/login");
}
} catch (error: any) {
- setMessage(error.response?.data?.message || "Something went wrong. Please try again.");
+ setMessage(
+ error.response?.data?.message ||
+ "Something went wrong. Please try again.",
+ );
} finally {
setIsLoading(false);
}
@@ -107,6 +134,7 @@ const SignUp: React.FC = () => {
: "bg-gradient-to-br from-slate-100 via-purple-100 to-slate-100"
}`}
>
+ {/* Background */}
{
mode === "dark" ? "bg-pink-500" : "bg-pink-300"
} rounded-full blur-3xl opacity-30 animate-pulse`}
/>
-
+ {/* ✅ BACK TO HOME BUTTON ADDED */}
+
navigate("/")}
+ className={`mb-6 flex items-center gap-2 px-4 py-2 rounded-xl backdrop-blur-xl border transition-all duration-300 hover:scale-105 active:scale-95 ${
+ mode === "dark"
+ ? "bg-white/10 text-white border-white/20 hover:bg-white/20"
+ : "bg-white/70 text-gray-800 border-gray-200 hover:bg-white"
+ }`}
+ >
+
+ Back to Home
+
+
+ {/* Header */}
-
-
+
+
-
GitHubTracker
-
Join your GitHub journey
+
+
+ GitHubTracker
+
+
+
+ Join your GitHub journey
+
+ {/* Form */}
{
: "bg-white border-gray-200 text-black"
}`}
>
-
-
+
Create Account
{message && (
-
- {message}
-
+ {message}
)}
-
- Already have an account?{" "}
-
- Sign in here
-
-
+
+ Already have an account? Sign in
+
-
-
);
};