-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
874 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import AdminDash from '../components/Dashboards/AdminDash/AdminDash'; | ||
import DocList from '../components/Dashboards/AdminDash/Tabs/DocList'; | ||
import AddNew from '../components/Dashboards/AdminDash/Tabs/AddNew'; | ||
import GenerateStats from '../components/Dashboards/AdminDash/Tabs/GenerateStats'; | ||
import VerifySignUp from '../components/Dashboards/AdminDash/Tabs/VerifySignUp'; | ||
import Feedbacks from '../components/Dashboards/AdminDash/Tabs/Feedbacks'; | ||
|
||
|
||
const adminRouter = [ | ||
{ | ||
path: '/dashboard/admin', | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<AdminDash /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/admin/doctors'-list`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<DocList /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/admin/doctors'-list/add-new`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<AddNew /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/admin/generate-stats`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<GenerateStats /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/admin/verify-signup`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<VerifySignUp /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/admin/generate-stats/feedbacks`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<Feedbacks /> | ||
</AuthContext.Provider> | ||
}, | ||
] | ||
|
||
export default adminRouter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import DoctorDash from '../components/Dashboards/DoctorDash/DoctorDash'; | ||
import Appointments from '../components/Dashboards/DoctorDash/Tabs/Appointments'; | ||
import UploadPrescription from '../components/Dashboards/DoctorDash/Tabs/UploadPrescription'; | ||
|
||
const doctorRouter = [ | ||
{ | ||
path: '/dashboard/doctor', | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<DoctorDash /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/doctor/appointments`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<Appointments /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/doctor/upload-prescription`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<UploadPrescription /> | ||
</AuthContext.Provider> | ||
} | ||
] | ||
|
||
export default doctorRouter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { createBrowserRouter, Navigate, RouterProvider } from 'react-router-dom' | ||
import jwt from "jsonwebtoken"; | ||
import HomePage from '../components/HomePage/HomePage'; | ||
import SignIn from '../components/SignIn/SignIn'; | ||
import SignUp from '../components/SignUp/SignUp'; | ||
import AdminDash from '../components/Dashboards/AdminDash/AdminDash'; | ||
import DocList from '../components/Dashboards/AdminDash/Tabs/DocList'; | ||
import AddNew from '../components/Dashboards/AdminDash/Tabs/AddNew'; | ||
import GenerateStats from '../components/Dashboards/AdminDash/Tabs/GenerateStats'; | ||
import VerifySignUp from '../components/Dashboards/AdminDash/Tabs/VerifySignUp'; | ||
import Feedbacks from '../components/Dashboards/AdminDash/Tabs/Feedbacks'; | ||
import adminRouter from './adminRouter'; | ||
import doctorRouter from './doctorRouter'; | ||
import staffRouter from './staffRouter'; | ||
|
||
export const AuthContext = React.createContext(); | ||
|
||
export default function MyRouter() { | ||
const [userType, setUserType] = useState( | ||
jwt.decode(localStorage.getItem("accessToken"))?.userType | ||
); | ||
useEffect(() => { | ||
const token = localStorage.getItem("accessToken"); | ||
const payload = token && jwt.decode(token); | ||
const userTyp = payload && payload.userType; | ||
setUserType(userTyp && userTyp); | ||
}, []); | ||
|
||
|
||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
element: <HomePage /> | ||
}, | ||
{ | ||
path: '/signin', | ||
element: userType ? ( | ||
<Navigate to={`/dashboard/${userType}`} /> | ||
) : ( | ||
<AuthContext.Provider value={{ setUserType }}> | ||
<SignIn /> | ||
</AuthContext.Provider> | ||
), | ||
}, | ||
{ | ||
path: '/signup', | ||
element: userType ? <Navigate to={`/dashboard/${userType}`} /> : <SignUp /> | ||
}, | ||
userType === "admin" && { ...adminRouter }, | ||
userType === "doctor" && { ...doctorRouter }, | ||
userType === "staff" && { ...staffRouter }, | ||
{ | ||
path: '*', | ||
element: <AuthContext.Provider value={{ userType }}> | ||
<Page404 /> | ||
</AuthContext.Provider>, | ||
// loader: async ({ params }) => await getonetutorial(params.tutorialID) | ||
}, | ||
]) | ||
return ( | ||
<RouterProvider router={router} /> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import PatientDash from '../components/Dashboards/PatientDash/PatientDash'; | ||
import BookAppointment from '../components/Dashboards/PatientDash/Tabs/BookAppointment'; | ||
import CardPaymentPatient from '../components/Dashboards/PatientDash/Tabs/CardPayment'; | ||
import Feedback from '../components/Dashboards/PatientDash/Tabs/Feedback'; | ||
import MakePaymentPatinet from '../components/Dashboards/PatientDash/Tabs/MakePayment'; | ||
import MyAppointments from '../components/Dashboards/PatientDash/Tabs/MyAppointments'; | ||
import Prescriptions from '../components/Dashboards/PatientDash/Tabs/Prescriptions'; | ||
import UpiPaymentPatient from '../components/Dashboards/PatientDash/Tabs/UpiPayment'; | ||
import ViewLocation from '../components/Dashboards/PatientDash/Tabs/ViewLocation'; | ||
|
||
const patientRouter = [ | ||
{ | ||
path: '/dashboard/patient', | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<PatientDash /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/view-location", | ||
element: <ViewLocation /> | ||
}, | ||
{ | ||
path: "/dashboard/patient/my-appointments", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<MyAppointments /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/book-appointment", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<BookAppointment /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/make-payment", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<MakePaymentPatinet /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/make-payment/card-payment", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<CardPaymentPatient /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/make-payment/upi-payment", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<UpiPaymentPatient /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/prescriptions", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<Prescriptions /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: "/dashboard/patient/feedback", | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<Feedback /> | ||
</AuthContext.Provider> | ||
}, | ||
] | ||
|
||
export default patientRouter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import StaffDash from '../components/Dashboards/StaffDash/StaffDash'; | ||
import BookAppointmentStaff from '../components/Dashboards/StaffDash/Tabs/BookAppointment'; | ||
import CancelAppointment from '../components/Dashboards/StaffDash/Tabs/CancelAppointment'; | ||
import CardPaymentStaff from '../components/Dashboards/StaffDash/Tabs/CardPayment'; | ||
import CashPayment from '../components/Dashboards/StaffDash/Tabs/CashPayment'; | ||
import MakePaymentStaff from '../components/Dashboards/StaffDash/Tabs/MakePayment'; | ||
import UpiPaymentStaff from '../components/Dashboards/StaffDash/Tabs/UpiPayment'; | ||
|
||
const staffRouter = [ | ||
{ | ||
path: '/dashboard/staff', | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<StaffDash /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/staff/book-appointment`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<BookAppointmentStaff /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/staff/cancel-appointment`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<CancelAppointment /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/staff/make-payment`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<MakePaymentStaff /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/staff/make-payment/card-payment`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<CardPaymentStaff /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/staff/make-payment/upi-payment`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<UpiPaymentStaff /> | ||
</AuthContext.Provider> | ||
}, | ||
{ | ||
path: `/dashboard/staff/make-payment/cash-payment`, | ||
element: <AuthContext.Provider value={{ setUserType }}> | ||
<CashPayment /> | ||
</AuthContext.Provider> | ||
} | ||
] | ||
|
||
export default staffRouter |
Oops, something went wrong.