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() {