auth stuff
This commit is contained in:
@@ -12,7 +12,10 @@ import { ChevronDown } from "lucide-react"
|
|||||||
|
|
||||||
import { PersonForm } from './PatientForm';
|
import { PersonForm } from './PatientForm';
|
||||||
|
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
const AccountPage = () => {
|
const AccountPage = () => {
|
||||||
|
const router = useRouter();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
const [patients, setPatients] = useState([]);
|
const [patients, setPatients] = useState([]);
|
||||||
@@ -40,7 +43,9 @@ const AccountPage = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!userData) return <div>Loading...</div>;
|
if (!userData) {
|
||||||
|
router.push('/');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto p-4">
|
<div className="container mx-auto p-4">
|
||||||
|
|||||||
@@ -2,9 +2,34 @@
|
|||||||
|
|
||||||
import { PatientTable } from "./PatientTable"
|
import { PatientTable } from "./PatientTable"
|
||||||
|
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import axios from "axios";
|
||||||
|
import { useUser } from '@clerk/nextjs';
|
||||||
|
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
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 !== "doctor") {
|
||||||
|
router.push("/suite/patient/dashboard");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
router.push("/");
|
||||||
|
}
|
||||||
|
|
||||||
const patients = [
|
const patients = [
|
||||||
{ id: 1, name: "John Doe", age: 30, lastVisit: "2024-10-01" },
|
{ id: 1, name: "John Doe", age: 30, lastVisit: "2024-10-01" },
|
||||||
{ id: 2, name: "Jane Smith", age: 25, lastVisit: "2024-09-15" },
|
{ id: 2, name: "Jane Smith", age: 25, lastVisit: "2024-09-15" },
|
||||||
@@ -7,6 +7,7 @@ import { Label } from '@/components/ui/label';
|
|||||||
import { Card, CardHeader, CardContent } from '@/components/ui/card';
|
import { Card, CardHeader, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
const AccountPage = () => {
|
const AccountPage = () => {
|
||||||
|
const router = useRouter();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
|
|
||||||
@@ -18,9 +19,13 @@ const AccountPage = () => {
|
|||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
if (!userData) return <div>Loading...</div>;
|
if (userData) {
|
||||||
|
if (userData.role !== "doctor") {
|
||||||
console.log(userData);
|
router.push("/suite/patient/dashboard");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
router.push("/");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto p-4">
|
<div className="container mx-auto p-4">
|
||||||
|
|||||||
@@ -8,7 +8,33 @@ import { Input } from "@/components/ui/input"
|
|||||||
|
|
||||||
import { Card, CardContent } from "@/components/ui/card"
|
import { Card, CardContent } from "@/components/ui/card"
|
||||||
|
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useUser } from "@clerk/nextjs";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
|
||||||
export default function Chat() {
|
export default function Chat() {
|
||||||
|
const router = useRouter();
|
||||||
|
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 !== "doctor") {
|
||||||
|
router.push("/suite/patient/dashboard");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
router.push("/");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto">
|
<div className="container mx-auto">
|
||||||
<div className="grid gap-4">
|
<div className="grid gap-4">
|
||||||
@@ -3,13 +3,15 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useUser } from '@clerk/nextjs';
|
import { useUser } from '@clerk/nextjs';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import { IntenseChart } from "./IntensityChart"
|
import { IntenseChart } from "./IntensityChart"
|
||||||
import { MedicationTable } from "./MedicationTable"
|
import { MedicationTable } from "./MedicationTable"
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
|
|
||||||
const { user } = useUser();
|
const router = useRouter();
|
||||||
|
const { user } = useUser();
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -18,7 +20,15 @@ export default function Dashboard() {
|
|||||||
setUserData(response.data);
|
setUserData(response.data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
|
if (userData) {
|
||||||
|
if (userData.role !== "doctor") {
|
||||||
|
router.push("/suite/patient/dashboard");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
router.push("/");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto">
|
<div className="container mx-auto">
|
||||||
|
|||||||
@@ -22,6 +22,6 @@
|
|||||||
"@/*": ["./src/*"]
|
"@/*": ["./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", "src/app/(panels)/suite/layout.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", "src/app/(panels)/suite/doctor/dashboard/page.jsx", "src/app/(panels)/suite/patient/chat/page.jsx"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user