@@ -12,12 +12,15 @@ import type { LinksFunction, LoaderFunction, LoaderFunctionArgs } from '@remix-r
1212import stylesheet from '~/styles/app.css?url'
1313// configs
1414import base from '~/configs/base.config'
15+ // apis
16+ import { getSystems } from '~/apis/status-api'
1517// layouts
1618import AppLayout from '~/layouts/AppLayout'
1719// helpers
1820import { getNotificationMessage } from '~/helpers/notification-helper'
1921// utils
20- import { authenticator } from '~/utils/auth.server'
22+ import { authenticator , getAuthAccessToken } from '~/utils/auth.server'
23+ import { SystemProvider } from '~/contexts/SystemContext'
2124
2225export const links : LinksFunction = ( ) => [ { rel : 'stylesheet' , href : stylesheet } ]
2326
@@ -26,10 +29,14 @@ export const loader: LoaderFunction = async ({ request }: LoaderFunctionArgs) =>
2629 const auth = await authenticator . isAuthenticated ( request , {
2730 failureRedirect : '/login' ,
2831 } )
32+ // Get auth access token
33+ const accessToken = await getAuthAccessToken ( request )
2934 // Create a headers object
3035 const headers = new Headers ( )
3136 // Get notification messages
3237 const notificationMessages = await getNotificationMessage ( request , headers )
38+ // Call api/s and fetch data
39+ const { systems } = await getSystems ( accessToken )
3340 // Return json
3441 return json (
3542 {
@@ -43,6 +50,7 @@ export const loader: LoaderFunction = async ({ request }: LoaderFunctionArgs) =>
4350 logoPath : base . logoPath ,
4451 authUser : auth . user ,
4552 notificationMessages : notificationMessages ,
53+ systems : systems ,
4654 } ,
4755 {
4856 headers : headers ,
@@ -63,19 +71,22 @@ export default function AppLayoutRoute() {
6371 environment,
6472 authUser,
6573 notificationMessages,
74+ systems,
6675 } : any = data
6776 return (
68- < AppLayout
69- appName = { appName }
70- environment = { environment }
71- appVersion = { appVersion }
72- companyName = { companyName }
73- logoPath = { logoPath }
74- supportUrl = { supportUrl }
75- repoUrl = { repoUrl }
76- docUrl = { docUrl }
77- authUser = { authUser }
78- notificationMessages = { notificationMessages }
79- />
77+ < SystemProvider systems = { systems } >
78+ < AppLayout
79+ appName = { appName }
80+ environment = { environment }
81+ appVersion = { appVersion }
82+ companyName = { companyName }
83+ logoPath = { logoPath }
84+ supportUrl = { supportUrl }
85+ repoUrl = { repoUrl }
86+ docUrl = { docUrl }
87+ authUser = { authUser }
88+ notificationMessages = { notificationMessages }
89+ />
90+ </ SystemProvider >
8091 )
8192}
0 commit comments