From c8bc1b6355919702184905a2a2918a72bc5838e7 Mon Sep 17 00:00:00 2001 From: biwasbhandari Date: Fri, 25 Apr 2025 14:06:54 +0545 Subject: [PATCH 1/4] feat: landing page --- src/app/page.tsx | 6 ++++-- src/components/Landing.tsx | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/components/Landing.tsx diff --git a/src/app/page.tsx b/src/app/page.tsx index 6cec9f60..1b7604eb 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,6 @@ -import Home from "@/components/home/home"; +import LandingPage from "@/components/Landing"; +// import Home from "@/components/home/home"; + export default function page() { - return ; + return ; } diff --git a/src/components/Landing.tsx b/src/components/Landing.tsx new file mode 100644 index 00000000..142a54d1 --- /dev/null +++ b/src/components/Landing.tsx @@ -0,0 +1,43 @@ +import Image from "next/image"; +import Link from "next/link"; +import { Button } from "@/components/ui/button"; + +export default function LandingPage() { + return ( +
+ {/* Hero Section */} +
+
+ AIBTC + + {/* Content overlay */} +
+
+

+ RSVP Thursdays +

+ + + +
+
+
+
+
+ ); +} From 7a812b0a54c643b05112943ae10934449acf64fd Mon Sep 17 00:00:00 2001 From: biwasbhandari Date: Fri, 25 Apr 2025 14:20:32 +0545 Subject: [PATCH 2/4] fix: update middleware and logos --- src/components/Landing.tsx | 58 ++++++++++++++++++++------------ src/utils/supabase/middleware.ts | 57 +++++++++++++++---------------- 2 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/components/Landing.tsx b/src/components/Landing.tsx index 142a54d1..34be84c9 100644 --- a/src/components/Landing.tsx +++ b/src/components/Landing.tsx @@ -6,35 +6,49 @@ export default function LandingPage() { return (
{/* Hero Section */} -
-
+
+ {/* Background Pattern */} +
AIBTC +
- {/* Content overlay */} -
-
-

- RSVP Thursdays -

- - - + {/* Content overlay */} +
+
+ {/* Logo */} +
+ AIBTC Logo
+ + {/* Button */} + + +
diff --git a/src/utils/supabase/middleware.ts b/src/utils/supabase/middleware.ts index 902d8b43..1ce8a098 100644 --- a/src/utils/supabase/middleware.ts +++ b/src/utils/supabase/middleware.ts @@ -1,5 +1,5 @@ -import { createServerClient } from "@supabase/ssr"; -import { type NextRequest, NextResponse } from "next/server"; +import { createServerClient } from "@supabase/ssr" +import { type NextRequest, NextResponse } from "next/server" export const updateSession = async (request: NextRequest) => { try { @@ -8,46 +8,40 @@ export const updateSession = async (request: NextRequest) => { request: { headers: request.headers, }, - }); + }) - const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; - const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; + const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL + const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY if (!supabaseUrl || !supabaseAnonKey) { - throw new Error( - "middleware: missing supabase url or supabase anon key in env vars" - ); + throw new Error("middleware: missing supabase url or supabase anon key in env vars") } const supabase = createServerClient(supabaseUrl, supabaseAnonKey, { cookies: { getAll() { - return request.cookies.getAll(); + return request.cookies.getAll() }, setAll(cookiesToSet) { - cookiesToSet.forEach(({ name, value }) => - request.cookies.set(name, value) - ); + cookiesToSet.forEach(({ name, value }) => request.cookies.set(name, value)) response = NextResponse.next({ request, - }); - cookiesToSet.forEach(({ name, value, options }) => - response.cookies.set(name, value, options) - ); + }) + cookiesToSet.forEach(({ name, value, options }) => response.cookies.set(name, value, options)) }, }, - }); + }) // Get the user const { data: { user }, error: userError, - } = await supabase.auth.getUser(); + } = await supabase.auth.getUser() // If trying to access admin route if (request.nextUrl.pathname.startsWith("/admin")) { if (userError || !user) { // If no user, redirect to login - return NextResponse.redirect(new URL("/daos", request.url)); + return NextResponse.redirect(new URL("/", request.url)) } // Check user role in profiles table @@ -55,11 +49,11 @@ export const updateSession = async (request: NextRequest) => { .from("profiles") .select("role") .eq("id", user.id) - .single(); + .single() if (profileError || !profileData || profileData.role !== "Admin") { // If not admin, redirect to dashboard - return NextResponse.redirect(new URL("/chat", request.url)); + return NextResponse.redirect(new URL("/chat", request.url)) } } @@ -74,25 +68,30 @@ export const updateSession = async (request: NextRequest) => { // } // Redirect root route to /daos - if (request.nextUrl.pathname === "/") { - return NextResponse.redirect(new URL("/daos", request.url)); - } + // if (request.nextUrl.pathname === "/") { + // return NextResponse.redirect(new URL("/daos", request.url)); + // } if (request.nextUrl.pathname.startsWith("/profile") && (userError || !user)) { return NextResponse.redirect(new URL("/", request.url)) } if (request.nextUrl.pathname === "/" && !userError) { - return NextResponse.redirect(new URL("/daos", request.url)); + return NextResponse.redirect(new URL("/daos", request.url)) } - return response; + return response } catch (error) { - console.error(error); + console.error(error) return NextResponse.next({ request: { headers: request.headers, }, - }); + }) } -}; \ No newline at end of file +} + +// See "Matching Paths" below to learn more +export const config = { + matcher: ["/", "/admin", "/profile"], +} From b2b0eaca1e95680a03f8f2d6e580a7f8fc30164d Mon Sep 17 00:00:00 2001 From: biwasbhandari Date: Fri, 25 Apr 2025 14:23:09 +0545 Subject: [PATCH 3/4] fix: protect other routes --- src/utils/supabase/middleware.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils/supabase/middleware.ts b/src/utils/supabase/middleware.ts index 1ce8a098..6312f4a7 100644 --- a/src/utils/supabase/middleware.ts +++ b/src/utils/supabase/middleware.ts @@ -3,6 +3,11 @@ import { type NextRequest, NextResponse } from "next/server" export const updateSession = async (request: NextRequest) => { try { + // If the path is not the root path, redirect to root + if (request.nextUrl.pathname !== "/") { + return NextResponse.redirect(new URL("/", request.url)) + } + // Create an unmodified response let response = NextResponse.next({ request: { @@ -37,6 +42,8 @@ export const updateSession = async (request: NextRequest) => { error: userError, } = await supabase.auth.getUser() + // ORIGINAL ROUTE PROTECTION LOGIC (COMMENTED OUT) + /* // If trying to access admin route if (request.nextUrl.pathname.startsWith("/admin")) { if (userError || !user) { @@ -79,6 +86,7 @@ export const updateSession = async (request: NextRequest) => { if (request.nextUrl.pathname === "/" && !userError) { return NextResponse.redirect(new URL("/daos", request.url)) } + */ return response } catch (error) { @@ -89,9 +97,4 @@ export const updateSession = async (request: NextRequest) => { }, }) } -} - -// See "Matching Paths" below to learn more -export const config = { - matcher: ["/", "/admin", "/profile"], -} +} \ No newline at end of file From e262f900047a8723f485d31a086398e3d90ee246 Mon Sep 17 00:00:00 2001 From: biwasbhandari Date: Fri, 25 Apr 2025 14:26:38 +0545 Subject: [PATCH 4/4] fix: build errors --- src/utils/supabase/middleware.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/supabase/middleware.ts b/src/utils/supabase/middleware.ts index 6312f4a7..736b1a0b 100644 --- a/src/utils/supabase/middleware.ts +++ b/src/utils/supabase/middleware.ts @@ -37,10 +37,13 @@ export const updateSession = async (request: NextRequest) => { }) // Get the user - const { - data: { user }, - error: userError, - } = await supabase.auth.getUser() + // const { + // data: { user }, + // error: userError, + // } = await supabase.auth.getUser() + + // Still call getUser() to refresh the session, but don't store the result + await supabase.auth.getUser() // ORIGINAL ROUTE PROTECTION LOGIC (COMMENTED OUT) /* @@ -97,4 +100,4 @@ export const updateSession = async (request: NextRequest) => { }, }) } -} \ No newline at end of file +}