-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved resource list to using react-router
- Loading branch information
1 parent
1d1c0b1
commit 25ce092
Showing
7 changed files
with
71 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import SearchBar from './resources/SearchBar'; | ||
import ResourceList from './resources/ResourceList'; | ||
import '../stylesheets/triclops_v1.scss'; // app css entry point | ||
import { RouterProvider, createBrowserRouter } from 'react-router-dom'; | ||
import HomePage from '../pages/Home'; | ||
import ResourcesPage from '../pages/Resources'; | ||
|
||
const App = () => { | ||
const [appVersion, setAppVersion] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
setAppVersion(document.body.getAttribute('data-app-version')); | ||
}, [appVersion]) | ||
|
||
if (!appVersion) { | ||
return 'Loading...'; | ||
const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
children: [ | ||
{ index: true, element: <HomePage /> }, | ||
{ path: '/admin/resources', element: <ResourcesPage /> } | ||
] | ||
} | ||
]) | ||
|
||
return ( | ||
<div> | ||
<h1>Triclops</h1> | ||
<p>{`Version ${appVersion}`}</p> | ||
<ResourceList /> | ||
</div> | ||
); | ||
const App = () => { | ||
return <RouterProvider router={router} />; | ||
}; | ||
|
||
export default App; |
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,20 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
export default function HomePage() { | ||
const [appVersion, setAppVersion] = useState(null); | ||
|
||
useEffect(() => { | ||
setAppVersion(document.body.getAttribute('data-app-version')); | ||
}, [appVersion]) | ||
|
||
if (!appVersion) { | ||
return 'Loading...'; | ||
} | ||
|
||
return ( | ||
<div> | ||
<h1>Triclops</h1> | ||
<p>{`Version ${appVersion}`}</p> | ||
</div> | ||
) | ||
} |
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,9 @@ | ||
import React from 'react'; | ||
|
||
import ResourceList from "../components/resources/ResourceList"; | ||
|
||
export default function ResourcesPage() { | ||
return ( | ||
<ResourceList /> | ||
); | ||
} |
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
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