From b86f1174bd8e89e8d96eb413e923e71eea4fed93 Mon Sep 17 00:00:00 2001 From: Sir Blob <76974209+GamerBoss101@users.noreply.github.com> Date: Sun, 26 Jan 2025 01:59:16 -0500 Subject: [PATCH] Update Login --- src/app/(web)/login/page.jsx | 60 +++++++++++++++++ src/app/(web)/login/page.tsx | 25 ------- src/components/hero.tsx | 4 +- src/components/navbar.tsx | 20 +++--- src/models/User.js | 122 +++++++++++++++++------------------ tsconfig.json | 2 +- 6 files changed, 136 insertions(+), 97 deletions(-) create mode 100644 src/app/(web)/login/page.jsx delete mode 100644 src/app/(web)/login/page.tsx diff --git a/src/app/(web)/login/page.jsx b/src/app/(web)/login/page.jsx new file mode 100644 index 0000000..529bd55 --- /dev/null +++ b/src/app/(web)/login/page.jsx @@ -0,0 +1,60 @@ +"use client"; + +import { useState, useEffect } from "react"; + +import axios from "axios"; +import { useUser } from "@clerk/nextjs"; + +import { + SignInButton, + SignedOut, +} from '@clerk/nextjs'; + +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" +import { Button } from "@/components/ui/button" + +export default function LoginPage() { + + const { user } = useUser(); + const [userData, setUserData] = useState(null); + + useEffect(() => { + if (user) { + axios.get(`/api/user?userId=${user.id}`).then(response => { + setUserData(response.data); + }); + } + }, [user]); + + if (userData) { + if (userData.role === "caregiver") { + window.location.href = "suite/doctor/dashboard"; + } + if (userData.role === "patient") { + window.location.href = "suite/patient/dashboard"; + } + } + + + return ( +
+ + + Welcome + Choose your login type + + + + + + + + +
+ ) +} + diff --git a/src/app/(web)/login/page.tsx b/src/app/(web)/login/page.tsx deleted file mode 100644 index e9099c9..0000000 --- a/src/app/(web)/login/page.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" -import { Button } from "@/components/ui/button" -import Link from "next/link" - -export default function LoginPage() { - return ( -
- - - Welcome - Choose your login type - - - - - - -
- ) -} - diff --git a/src/components/hero.tsx b/src/components/hero.tsx index e13ec26..0eedd64 100644 --- a/src/components/hero.tsx +++ b/src/components/hero.tsx @@ -16,8 +16,8 @@ export function Hero() {