Skip to content

Commit

Permalink
Created a Database Supabase, Created a responsive Navbar design, Crea…
Browse files Browse the repository at this point in the history
…ted a authentication pages such as login and signup, added google auth
  • Loading branch information
Priyanshu9898 committed Dec 23, 2024
1 parent c4690fc commit 3192e01
Show file tree
Hide file tree
Showing 8 changed files with 408 additions and 3 deletions.
11 changes: 11 additions & 0 deletions app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

const AuthLayout = ({ children }: { children: React.ReactNode }) => {
return (
<div className="flex w-full h-[90vh] flex-1 items-center justify-center mt-[-20px]">
{children}
</div>
);
};

export default AuthLayout;
5 changes: 5 additions & 0 deletions app/(auth)/sign-in/[[...sign-in]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignIn } from "@clerk/nextjs";

export default function Page() {
return <SignIn />;
}
5 changes: 5 additions & 0 deletions app/(auth)/sign-up/[[...sign-up]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignUp } from "@clerk/nextjs";

export default function Page() {
return <SignUp />;
}
23 changes: 20 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Metadata } from "next";
import "./globals.css";
import { Inter } from "next/font/google";
import { ClerkProvider } from "@clerk/nextjs";
import Navbar from "@/components/Navbar";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -15,8 +17,23 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={`${inter.className}`}>{children}</body>
</html>
<ClerkProvider>
<html lang="en">
<body className={`${inter.className}`}>
<main className="container min-h-screen">
<Navbar />
<div className="mt-20">{children}</div>
</main>

{/* {"Footer is here"} */}
<div className="footer section mx-auto bg-gray-600">
<footer className="py-4 text-center font-bold text-blue-50">
<p>© 2025 Wealth Manager </p>
<p>Made with 💗 by Priyanshu Malaviya </p>
</footer>
</div>
</body>
</html>
</ClerkProvider>
);
}
64 changes: 64 additions & 0 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from "react";
import { SignedIn, SignInButton, SignedOut, UserButton } from "@clerk/nextjs";
import { Button } from "./ui/button";
import Link from "next/link";
import { LayoutDashboard, PenBox } from "lucide-react";

const Navbar = () => {
return (
<>
<div className="container mx-auto px-2 md:px-10 z-50 fixed top-0 bg-white/80 backdrop-blur-md border-b">
<nav className="container flex justify-between items-center py-4 ">
{/* Logo here */}
<Link href="/">
<div className="text-2xl xl:text-3xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-sky-500 to-blue-600">
Wealth Manager
</div>
</Link>

{/* Nav items here */}
<div>
<SignedIn>
<div className="w-full flex items-center justify-between gap-x-4">
<Link href="/transaction/create">
<Button type="button">
<PenBox className="" />
<span className="hidden md:flex">Add Transaction</span>
</Button>
</Link>

<Link href="/dashboard">
<Button
type="button"
variant={"outline"}
className="text-gray-600 hover:text-blue-600"
>
<LayoutDashboard className="" />
<span className="hidden md:flex">Dashboard</span>
</Button>
</Link>

<UserButton
appearance={{
elements: {
avatarBox: "h-10 w-10",
},
}}
/>
</div>
</SignedIn>
<SignedOut>
<SignInButton forceRedirectUrl={"/dashboard"}>
<Button type="button" variant={"outline"}>
Login
</Button>
</SignInButton>
</SignedOut>
</div>
</nav>
</div>
</>
);
};

export default Navbar;
28 changes: 28 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";

const isProtected = createRouteMatcher([
"/dashboard(.*)",
"/account(.*)",
"/transaction(.*)",
]);

export default clerkMiddleware(async (auth, req) => {
const { userId } = await auth();

if (!userId && isProtected(req)) {
const { redirectToSignIn } = await auth();

return redirectToSignIn();
}

return null;
});

export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
// Always run for API routes
"/(api|trpc)(.*)",
],
};
Loading

0 comments on commit 3192e01

Please sign in to comment.