[#40] Implement router

This commit is contained in:
Matthew Northcott 2023-02-03 14:36:04 +13:00
parent 9a7b9474d4
commit fe59b0c854
4 changed files with 28 additions and 35 deletions

View file

@ -1,23 +0,0 @@
import MainPage from './pages/MainPage';
import { createTheme, ThemeProvider } from '@mui/material/styles';
function App() {
const darkTheme = createTheme({
palette: {
mode: 'dark',
},
typography: {
fontFamily: 'Poppins, sans-serif',
},
});
return (
<div className="App">
<ThemeProvider theme={darkTheme}>
<MainPage />
</ThemeProvider>
</div>
);
}
export default App;

View file

@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View file

@ -1,26 +1,45 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import App from './App'; import { createTheme, ThemeProvider } from '@mui/material/styles';
import reportWebVitals from './reportWebVitals'; import reportWebVitals from './reportWebVitals';
import { import {
createBrowserRouter, createBrowserRouter,
RouterProvider, RouterProvider,
} from 'react-router-dom'; } from 'react-router-dom';
import MainPage from './pages/MainPage';
// Styles // Styles
import './assets/styles/main.scss'; import './assets/styles/main.scss';
import 'bootstrap/dist/css/bootstrap.min.css'; import 'bootstrap/dist/css/bootstrap.min.css';
import RegisterPage from './pages/RegisterPage';
const router = createBrowserRouter([ const router = createBrowserRouter([
{ {
path: "/", path: "/",
element: <App /> element: <MainPage />,
}, },
]) {
path: "/register",
element: <RegisterPage />,
},
]);
const darkTheme = createTheme({
palette: {
mode: 'dark',
},
typography: {
fontFamily: 'Poppins, sans-serif',
},
});
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<RouterProvider router={router} /> <div className="App">
<ThemeProvider theme={darkTheme}>
<RouterProvider router={router} />
</ThemeProvider>
</div>
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById('root')
); );

View file

@ -0,0 +1,5 @@
const RegisterPage = () => {
return <></>;
};
export default RegisterPage;