From eba0a2613cd54895d73aa9d4b40fb67a5b04ba41 Mon Sep 17 00:00:00 2001 From: shadil-rayyan Date: Thu, 4 Dec 2025 00:39:19 +0530 Subject: [PATCH 1/6] fix navbar and loading screen --- components/Navbar.tsx | 2 +- components/loadingScrenn.tsx | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 22a7b56..4170a21 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -33,7 +33,7 @@ const Navbar = () => {
{/* Logo Section */}
- Project Archive + NearBy Hostel
{/* Authentication Button */} diff --git a/components/loadingScrenn.tsx b/components/loadingScrenn.tsx index 9c2bb1a..f7f61f2 100644 --- a/components/loadingScrenn.tsx +++ b/components/loadingScrenn.tsx @@ -15,7 +15,7 @@ const LoadingScreen = () => { return (
-

Project Archive

+

Nearby Hostel

); }; diff --git a/package.json b/package.json index 0e8781d..dc9bf68 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev -p 3001", + "dev": "next dev ", "build": "next build", "start": "next start", "lint": "next lint", From 167644e19bcbf26250f4fffac81b216f6bb1541d Mon Sep 17 00:00:00 2001 From: shadil-rayyan Date: Thu, 4 Dec 2025 00:44:43 +0530 Subject: [PATCH 2/6] fix login screen and removed pkd only --- app/login/page.tsx | 180 ++++++++++++++++++++++++++++++++++--------- lib/firebase/auth.ts | 15 +--- 2 files changed, 149 insertions(+), 46 deletions(-) diff --git a/app/login/page.tsx b/app/login/page.tsx index 68abc37..5e8b568 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -1,38 +1,148 @@ "use client"; -import { useState } from 'react'; -import { signInWithGoogle } from '@/lib/firebase/auth'; - -export default function LoginPage() { - const [loading, setLoading] = useState(false); - const [error, setError] = useState(''); - - const handleLoginWithGoogle = async () => { - setLoading(true); - setError(''); - try { - await signInWithGoogle(); - } catch (err: any) { - if (err.code === 'auth/cancelled-popup-request' || err.code === 'auth/popup-closed-by-user') { - setError('Login was cancelled. Please try again.'); - } else { - setError('Login failed. Please try again.'); - } - } finally { - setLoading(false); - } - }; - - return ( -
- - {error &&
{error}
} +import { useState } from "react"; +import { signInWithGoogle } from "@/lib/firebase/auth"; +import { useRouter } from "next/navigation"; + +export default function AuthPage() { + const [error, setError] = useState(null); + const [loading, setLoading] = useState(false); + const router = useRouter(); + + const handleLoginWithGoogle = async () => { + setLoading(true); + setError(null); + try { + const result = await signInWithGoogle(); + const user = result?.user; + + if (user) { + const idToken = await user.getIdToken(); + document.cookie = `__session=${idToken}; path=/; `; + console.log("User logged in:", user); + console.log("token stored in cookie:", idToken); + } + if (result?.isAdmin) { + router.push("/admin"); + } else { + router.push("/"); + } + } catch (err) { + console.error("Failed to log in with Google:", err); + setError( + err instanceof Error ? err.message : "Failed to log in with Google" + ); + } finally { + setLoading(false); + } + }; + + return ( +
+ {/* Subtle background decorations */} +
+
+
+ +
+ {/* Main card */} +
+ {/* Header */} +
+
+ + + +
+

+ Welcome +

+

+ Sign in to continue your journey +

+
+ + {/* Google Login Button */} + + + {/* Error message */} + {error && ( +
+

+ {error} +

+
+ )}
- ); -} + + {/* Footer text */} +

+ Secure authentication powered by Google +

+ +
+
+ ); +} \ No newline at end of file diff --git a/lib/firebase/auth.ts b/lib/firebase/auth.ts index 2bc834d..2a8157f 100644 --- a/lib/firebase/auth.ts +++ b/lib/firebase/auth.ts @@ -1,5 +1,5 @@ // Import User and other necessary types/functions from Firebase Auth -import { signInWithPopup, GoogleAuthProvider, User, UserCredential } from 'firebase/auth'; +import { signInWithPopup, GoogleAuthProvider, User, UserCredential , getAuth } from 'firebase/auth'; import { doc, getDoc } from 'firebase/firestore'; import { auth, firestore } from './config'; // Ensure you are correctly importing from your Firebase config @@ -9,7 +9,7 @@ export function onAuthStateChanged(callback: (authUser: User | null) => void) { } // Function for Google sign-in and role check -export async function signInWithGoogle(): Promise<{ isAdmin: boolean }> { +export async function signInWithGoogle(): Promise<{ user:User; isAdmin: boolean }> { const provider = new GoogleAuthProvider(); provider.setCustomParameters({ display: "popup" }); // Force popup @@ -22,14 +22,7 @@ export async function signInWithGoogle(): Promise<{ isAdmin: boolean }> { throw new Error('Google sign-in failed'); } - // Restrict login to only emails from "gecskp.ac.in" - // Restrict login to only emails from "gecskp.ac.in", except for a specific admin email -const allowedEmailPattern = /^[a-zA-Z0-9]+@gecskp\.ac\.in$/; -const adminOverrideEmail = "codecompass2024@gmail.com"; -if (user.email !== adminOverrideEmail && !allowedEmailPattern.test(user.email)) { - throw new Error('Only GEC SKP emails are allowed'); -} @@ -38,7 +31,7 @@ if (user.email !== adminOverrideEmail && !allowedEmailPattern.test(user.email)) const isAdmin = userDoc.exists() && userDoc.data()?.role === 'admin'; - return { isAdmin }; + return {user, isAdmin }; } catch (error) { console.error('Error signing in with Google:', error); throw error; @@ -54,4 +47,4 @@ export async function signOutWithGoogle(): Promise { console.error('Error signing out with Google:', error); throw error; } -} +} \ No newline at end of file From 053b60e34cab6d465d4c91e868295b78a452208c Mon Sep 17 00:00:00 2001 From: shadil-rayyan Date: Thu, 4 Dec 2025 01:00:27 +0530 Subject: [PATCH 3/6] remove the tabsection in home page and also added the seed.ts file --- app/page.tsx | 2 +- lib/seed.ts | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 lib/seed.ts diff --git a/app/page.tsx b/app/page.tsx index ea7041a..1d459fa 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -41,7 +41,7 @@ export default function Home() {
- + {/* */}
diff --git a/lib/seed.ts b/lib/seed.ts new file mode 100644 index 0000000..57049ac --- /dev/null +++ b/lib/seed.ts @@ -0,0 +1,146 @@ +import { db } from "@/lib/db"; +import { + users, + hostels, + categories, + categoryOptionValues, + hostelOptions, + hostelImages, + ratings, + comments, +} from "@/lib/schema"; + +async function seed() { + try { + // ---------------- Insert Dummy Users ---------------- + const insertedUsers = await db.insert(users).values([ + { userRole: "student", displayName: "Alice" }, + { userRole: "student", displayName: "Bob" }, + { userRole: "student", displayName: "Charlie" }, + ]).returning({ id: users.uid, displayName: users.displayName }); + + console.log("✅ Dummy users inserted"); + + const getUserId = (displayName: string) => { + const user = insertedUsers.find(u => u.displayName === displayName); + if (!user) throw new Error(`User not found: ${displayName}`); + return user.id; + }; + + // ---------------- Insert Categories ---------------- + const insertedCategories = await db.insert(categories).values([ + { category: "Amenities" }, + { category: "Distance" }, + { category: "Hostel Type" }, + { category: "Gender" }, + ]).returning({ id: categories.categoryId, name: categories.category }); + + console.log("✅ Categories inserted"); + + const catId = (name: string) => { + const category = insertedCategories.find(c => c.name === name); + if (!category) throw new Error(`Category not found: ${name}`); + return category.id; + }; + + // ---------------- Insert Category Option Values ---------------- + const insertedOptions = await db.insert(categoryOptionValues).values([ + { optionName: "Food", categoryId: catId("Amenities") }, + { optionName: "WiFi", categoryId: catId("Amenities") }, + { optionName: "AC", categoryId: catId("Amenities") }, + { optionName: "Water Heater", categoryId: catId("Amenities") }, + + { optionName: "Near 500m", categoryId: catId("Distance") }, + { optionName: "1km", categoryId: catId("Distance") }, + { optionName: "More than 1km", categoryId: catId("Distance") }, + + { optionName: "PG", categoryId: catId("Hostel Type") }, + { optionName: "Rented", categoryId: catId("Hostel Type") }, + + + { optionName: "Boys", categoryId: catId("Gender") }, + { optionName: "Girls", categoryId: catId("Gender") }, + ]).returning({ id: categoryOptionValues.optionId, name: categoryOptionValues.optionName }); + + console.log("✅ Category options inserted"); + + const getOptionId = (name: string) => { + const option = insertedOptions.find(o => o.name === name); + if (!option) throw new Error(`Option not found: ${name}`); + return option.id; + }; + + // ---------------- Insert Hostels ---------------- + const insertedHostels = await db.insert(hostels).values([ + { + hostelName: "Kerala PG Hostel", + hostelDescription: "Comfortable PG for boys with all basic amenities.", + location: "https://maps.google.com/?q=Kerala+PG+Hostel", + address: "Near College, Kerala", + phoneNumber: "+918000111222", + email: "pgkerala@example.com", + website: "https://pgkerala.example.com", + createdByUid: getUserId("Alice"), + }, + { + hostelName: "Girls Hostel Kerala", + hostelDescription: "Safe and well-maintained hostel for girls.", + location: "https://maps.google.com/?q=Girls+Hostel+Kerala", + address: "College Road, Kerala", + phoneNumber: "+918000333444", + email: "girlskerala@example.com", + website: "https://girlskerala.example.com", + createdByUid: getUserId("Bob"), + }, + ]).returning({ id: hostels.hostelId, name: hostels.hostelName }); + + console.log("✅ Hostels inserted"); + + // ---------------- Insert Hostel Options ---------------- + const hostelOptionData = [ + { hostelId: insertedHostels[0].id, categoryId: catId("Amenities"), optionId: getOptionId("Food") }, + { hostelId: insertedHostels[0].id, categoryId: catId("Amenities"), optionId: getOptionId("WiFi") }, + { hostelId: insertedHostels[0].id, categoryId: catId("Amenities"), optionId: getOptionId("AC") }, + { hostelId: insertedHostels[0].id, categoryId: catId("Distance"), optionId: getOptionId("Near 500m") }, + { hostelId: insertedHostels[0].id, categoryId: catId("Hostel Type"), optionId: getOptionId("PG") }, + { hostelId: insertedHostels[0].id, categoryId: catId("Gender"), optionId: getOptionId("Boys") }, + + { hostelId: insertedHostels[1].id, categoryId: catId("Amenities"), optionId: getOptionId("WiFi") }, + { hostelId: insertedHostels[1].id, categoryId: catId("Amenities"), optionId: getOptionId("Water Heater") }, + { hostelId: insertedHostels[1].id, categoryId: catId("Distance"), optionId: getOptionId("1km") }, + { hostelId: insertedHostels[1].id, categoryId: catId("Hostel Type"), optionId: getOptionId("Rented") }, + { hostelId: insertedHostels[1].id, categoryId: catId("Gender"), optionId: getOptionId("Girls") }, + ]; + + await db.insert(hostelOptions).values(hostelOptionData); + console.log("✅ Hostel options linked"); + + // ---------------- Insert Hostel Images ---------------- + await db.insert(hostelImages).values([ + { hostelId: insertedHostels[0].id, imageUrl: "https://example.com/pg1.jpg", isPrimary: true }, + { hostelId: insertedHostels[1].id, imageUrl: "https://example.com/girls1.jpg", isPrimary: true }, + ]); + console.log("✅ Hostel images inserted"); + + // ---------------- Insert Ratings ---------------- + await db.insert(ratings).values([ + { hostelId: insertedHostels[0].id, userId: getUserId("Alice"), overallRating: "4.5" }, + { hostelId: insertedHostels[1].id, userId: getUserId("Bob"), overallRating: "4.8" }, + ]); + console.log("✅ Ratings inserted"); + + // ---------------- Insert Comments ---------------- + await db.insert(comments).values([ + { hostelId: insertedHostels[0].id, userId: getUserId("Alice"), commentText: "Nice PG with great facilities.", userName: "Alice", userEmail: "alice@example.com", isVerified: true }, + { hostelId: insertedHostels[1].id, userId: getUserId("Bob"), commentText: "Safe and comfortable hostel.", userName: "Bob", userEmail: "bob@example.com", isVerified: true }, + ]); + console.log("✅ Comments inserted"); + + console.log("🎉 Hostel seeding completed successfully!"); + } catch (err) { + console.error("❌ Seeding failed:", err); + process.exit(1); + } +} + +seed(); \ No newline at end of file From 21ff9a2628c0f33633a9a0a59da41b1a1d8231a6 Mon Sep 17 00:00:00 2001 From: shadil-rayyan Date: Mon, 15 Dec 2025 13:03:25 +0530 Subject: [PATCH 4/6] intergrated bottem nav to the project --- app/layout.tsx | 3 ++- components/bottomNavbar.tsx | 52 +++++++++++++++++++++++++++++++++++++ data/nav.ts | 9 +++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 components/bottomNavbar.tsx create mode 100644 data/nav.ts diff --git a/app/layout.tsx b/app/layout.tsx index 2838ddd..c4e60b6 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,7 +1,7 @@ import type { Metadata } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import "./globals.css"; - +import BottomNavBar from "@/components/bottomNavbar"; const geistSans = Geist({ variable: "--font-geist-sans", subsets: ["latin"], @@ -29,6 +29,7 @@ export default function RootLayout({ > {children} + ); } diff --git a/components/bottomNavbar.tsx b/components/bottomNavbar.tsx new file mode 100644 index 0000000..287b342 --- /dev/null +++ b/components/bottomNavbar.tsx @@ -0,0 +1,52 @@ +"use client"; +import Link from "next/link"; +import { useState } from "react"; +import { bottomTabs } from "@/data/nav"; + +const BottomNavBar = () => { + const [activeTab, setActiveTab] = useState("home"); + const [hoveredTab, setHoveredTab] = useState(null); + + + + + return ( + + ); +}; + +export default BottomNavBar; diff --git a/data/nav.ts b/data/nav.ts new file mode 100644 index 0000000..c05657d --- /dev/null +++ b/data/nav.ts @@ -0,0 +1,9 @@ +import { Book, Calendar2, Calendar, Home2, Money } from "iconsax-react"; + +export const bottomTabs = [ + { name: "home", icon: Home2, href: "https://gecian-hub.netlify.app/", label: "Home" }, + { name: "studymaterial", icon: Book, href: "https://www.ktunotes.in/", label: "Study" }, + { name: "attendance", icon: Calendar2, href: "https://gecian-hub.netlify.app/attendance/calendar", label: "Attendance" }, + { name: "finance", icon: Money, href: "https://gecian-hub.netlify.app/expense", label: "Finance" }, + { name: "event", icon: Calendar, href: "https://gecian-hub.netlify.app/events", label: "Event" }, +]; From 3c9db72be99293bd80491fa5fac841aa48a03ca2 Mon Sep 17 00:00:00 2001 From: shadil-rayyan Date: Mon, 15 Dec 2025 15:30:15 +0530 Subject: [PATCH 5/6] intergrated bottem nav and back button as well --- app/layout.tsx | 4 +++- components/Navbar.tsx | 13 ++++++++++++- components/bottomNavbar.tsx | 20 ++++++++++---------- package-lock.json | 17 +++++++++++++---- package.json | 1 + 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index c4e60b6..ceb025d 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -28,8 +28,10 @@ export default function RootLayout({ className={`${geistSans.variable} ${geistMono.variable} antialiased`} > {children} + + + - ); } diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 4170a21..3613cf3 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -5,6 +5,7 @@ import Link from "next/link"; import { onAuthStateChanged } from "@/lib/firebase/auth"; import { signOut, getAuth, User } from "firebase/auth"; // Adjust the import path based on your Firebase setup import { useRouter } from "next/navigation"; +import { ArrowLeftIcon} from "lucide-react"; const Navbar = () => { const [user, setUser] = useState(null); @@ -31,7 +32,15 @@ const Navbar = () => { return (