@@ -3,17 +3,50 @@ import { Routes, Route, Navigate } from "react-router-dom";
33import SecureRoute from './components/secureRoute' ;
44import { SigninCallback } from "./components/signinCallback" ;
55import { UserInvitations } from './components/user/userInvitations' ;
6+ import { SettingsService } from './services/settingsService' ;
7+ import { AuthenticationService } from './services/authenticationService' ;
8+ import { InviterService } from './services/inviterService' ;
9+ import { ApplicationContext } from './utilities/applicationContext' ;
610
711function App ( ) {
8-
12+ const context = new AppContext ( ) ;
913 return (
10- < Routes >
11- < Route path = '/' element = { < Navigate to = "/index" /> } >
12- </ Route >
13- < Route path = "signin-callback" element = { < SigninCallback /> } />
14- < Route path = 'index' element = { < SecureRoute > < UserInvitations /> </ SecureRoute > } />
15- </ Routes >
14+ < ApplicationContext . Provider value = { context } >
15+ < Routes >
16+ < Route path = '/' element = { < Navigate to = "/index" /> } >
17+ </ Route >
18+ < Route path = "signin-callback" element = { < SigninCallback /> } />
19+ < Route path = 'index' element = { < SecureRoute > < UserInvitations /> </ SecureRoute > } />
20+ </ Routes >
21+ </ ApplicationContext . Provider >
1622 ) ;
1723}
1824
19- export default App ;
25+ export default App ;
26+
27+ class AppContext {
28+ private settingsService : SettingsService ;
29+ private authenticationService : AuthenticationService ;
30+ private inviterService : InviterService ;
31+
32+ public getAuthenticationService ( ) : AuthenticationService {
33+ if ( ! this . authenticationService ) {
34+ this . authenticationService = new AuthenticationService ( this . getSettingsService ( ) . getAuthenticationSettings ( ) ) ;
35+ }
36+ return this . authenticationService ;
37+ }
38+
39+ public getSettingsService ( ) : SettingsService {
40+ if ( ! this . settingsService ) {
41+ this . settingsService = new SettingsService ( ) ;
42+ }
43+ return this . settingsService ;
44+ }
45+
46+ public getInviterService ( ) : InviterService {
47+ if ( ! this . inviterService ) {
48+ this . inviterService = new InviterService ( this . getSettingsService ( ) . getServerUrl ( ) , this . getAuthenticationService ( ) . userManager ) ;
49+ }
50+ return this . inviterService ;
51+ }
52+ }
0 commit comments