Auth Auth

This commit is contained in:
Sir Blob
2025-01-26 02:45:04 -05:00
parent bef4b48b1b
commit a0c3f9b151
5 changed files with 41 additions and 29 deletions

View File

@@ -26,7 +26,6 @@
"axios": "^1.7.9",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^2.30.0",
"dotenv": "^16.4.7",
"formidable": "^3.5.2",
"hoyahax-2025": "file:",
@@ -39,7 +38,6 @@
"openai": "^4.80.1",
"openai-whisper": "^1.0.2",
"react": "^19.0.0",
"react-day-picker": "^9.5.0",
"react-dom": "^19.0.0",
"recharts": "^2.15.0",
"svix": "^1.45.1",

View File

@@ -1,24 +0,0 @@
"use client"
import { useState } from "react"
import { Calendar } from "@/components/ui/calendar"
import { Card, CardContent } from "@/components/ui/card"
export function ScheduleCalender() {
const [date, setDate] = useState(new Date())
return (
<Card>
<CardContent className="px-auto py-5">
<Calendar
mode="single"
selected={date}
onSelect={setDate}
className="rounded-md my-auto mx-auto w-fit"
/>
</CardContent>
</Card>
)
}

View File

@@ -2,7 +2,6 @@
import { PatientTable } from "./PatientTable"
import { ScheduleCalender } from "./Calender"
export default function Dashboard() {
@@ -17,7 +16,6 @@ export default function Dashboard() {
<h1 className="text-3xl font-semibold mb-6">Dashboard</h1>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<PatientTable data={patients} />
<ScheduleCalender />
</div>
</div>
)

View File

@@ -0,0 +1,40 @@
"use client"
import { useState, useEffect } from "react";
import { useUser } from "@clerk/nextjs";
import axios from "axios";
export default function RootLayout({
children,
}) {
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";
}
} else {
window.location.href = "/";
window.location.href = "/";
return null;
}
return (
<>{children}</>
)
}

View File

@@ -22,6 +22,6 @@
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/api/connectDB.js", "src/lib/utils.js", "src/app/(web)/account/page.jsx", "src/app/(panels)/suite/patient/account/page.jsx", "src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx", "src/app/(panels)/suite/patient/dashboard/page.jsx", "src/app/api/transcribe/route.js", "src/components/ui/calendar.jsx", "src/app/(web)/page.jsx", "src/app/(web)/transcribe/page.jsx", "src/app/(web)/login/page.jsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/api/connectDB.js", "src/lib/utils.js", "src/app/(web)/account/page.jsx", "src/app/(panels)/suite/patient/account/page.jsx", "src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx", "src/app/(panels)/suite/patient/dashboard/page.jsx", "src/app/api/transcribe/route.js", "src/components/ui/calendar.jsx", "src/app/(web)/page.jsx", "src/app/(web)/transcribe/page.jsx", "src/app/(web)/login/page.jsx", "src/app/(panels)/suite/layout.jsx"],
"exclude": ["node_modules"]
}