@@ -6,6 +6,8 @@ import { BrowserRouter as Router, Link, Route, Routes } from 'react-router-dom';
66import './App.css' ;
77import DoctorOrders from './views/DoctorOrders/DoctorOrders' ;
88import Login from './views/Login/Login' ;
9+ import ProtectedRoute from './components/ProtectedRoute' ;
10+ import { AuthProvider } from './contexts/AuthContext' ;
911import axios from 'axios' ;
1012
1113axios . defaults . baseURL = process . env . REACT_APP_PIMS_BACKEND_URL
@@ -17,36 +19,44 @@ const basename = process.env.REACT_APP_VITE_BASE?.replace(/\/$/, '') || '';
1719
1820function App ( ) {
1921 return (
20- < Box >
21- < Router basename = { basename } >
22- < div className = "App" >
23- < Container className = "NavContainer" maxWidth = "xl" >
24- < div className = "containerg" >
25- < div className = "logo" >
26- < LocalPharmacyIcon
27- sx = { { color : 'white' , fontSize : 40 , paddingTop : 2.5 , paddingRight : 2.5 } }
28- />
29- < h1 > Pharmacy</ h1 >
22+ < AuthProvider >
23+ < Box >
24+ < Router basename = { basename } >
25+ < div className = "App" >
26+ < Container className = "NavContainer" maxWidth = "xl" >
27+ < div className = "containerg" >
28+ < div className = "logo" >
29+ < LocalPharmacyIcon
30+ sx = { { color : 'white' , fontSize : 40 , paddingTop : 2.5 , paddingRight : 2.5 } }
31+ />
32+ < h1 > Pharmacy</ h1 >
33+ </ div >
34+ < div className = "links" >
35+ < Link className = "NavButtons" to = "/DoctorOrders" >
36+ < Button variant = "contained" > Doctor Orders</ Button >
37+ </ Link >
38+ < Link className = "NavButtons" to = "/Login" >
39+ < Button variant = "contained" > Login</ Button >
40+ </ Link >
41+ </ div >
3042 </ div >
31- < div className = "links" >
32- < Link className = "NavButtons" to = "/DoctorOrders" >
33- < Button variant = "contained" > Doctor Orders</ Button >
34- </ Link >
35- < Link className = "NavButtons" to = "/Login" >
36- < Button variant = "contained" > Login</ Button >
37- </ Link >
38- </ div >
39- </ div >
40- </ Container >
41- </ div >
42- < Routes >
43- { /* Initial load to login page, will need to change to check for user authentication to load to correct page */ }
44- < Route path = "/" element = { < Login /> } />
45- < Route path = "/Login" element = { < Login /> } > </ Route >
46- < Route path = "/DoctorOrders" element = { < DoctorOrders /> } > </ Route >
47- </ Routes >
48- </ Router >
49- </ Box >
43+ </ Container >
44+ </ div >
45+ < Routes >
46+ < Route path = "/" element = { < Login /> } />
47+ < Route path = "/Login" element = { < Login /> } />
48+ < Route
49+ path = "/DoctorOrders"
50+ element = {
51+ < ProtectedRoute >
52+ < DoctorOrders />
53+ </ ProtectedRoute >
54+ }
55+ />
56+ </ Routes >
57+ </ Router >
58+ </ Box >
59+ </ AuthProvider >
5060 ) ;
5161}
5262
0 commit comments