Skip to content

Commit

Permalink
Merge branch '38-register-user' of github.com:sfbrigade/sf-lifeline i…
Browse files Browse the repository at this point in the history
…nto 38-register-user
  • Loading branch information
javtran committed Mar 16, 2024
2 parents e7ca473 + e721f5f commit 94e5e80
Show file tree
Hide file tree
Showing 10 changed files with 1,725 additions and 2,898 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@mantine/core": "^7.5.3",
"@mantine/hooks": "^7.5.3",
"@tanstack/react-query": "^5.18.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.1"
Expand Down
12 changes: 5 additions & 7 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { Routes, Route } from 'react-router-dom';
import Index from './pages';
import Login from './pages/login';
import NavBar from './components/NavBar';
Expand All @@ -8,12 +8,10 @@ function App() {
return (
<>
<NavBar />
<Router>
<Routes>
<Route path="/" element={<Index />} />
<Route path="/login" element={<Login />} />
</Routes>
</Router>
<Routes>
<Route path="/" element={<Index />} />
<Route path="/login" element={<Login />} />
</Routes>
</>
);
}
Expand Down
14 changes: 11 additions & 3 deletions client/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import App from './App.jsx';
import './index.css';
import '@mantine/core/styles.css';
import { theme } from './theme';

import { MantineProvider } from '@mantine/core';

const queryClient = new QueryClient({});

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<MantineProvider theme={theme}>
<App />
</MantineProvider>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<MantineProvider theme={theme}>
<App />
</MantineProvider>
</BrowserRouter>
</QueryClientProvider>
</React.StrictMode>,
);
17 changes: 17 additions & 0 deletions client/src/pages/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import React from 'react';
import { useQuery } from '@tanstack/react-query';

function Index() {
const { isFetching, error } = useQuery({
queryKey: ['users'],
queryFn: () =>
fetch('/api/v1/users').then((res) => {
return res.json();
}),
});

if (isFetching) {
return <main>Index is loading</main>;
}

if (error) {
return <main>Index fetch failed</main>;
}

return <main>Index is working</main>;
}

Expand Down
Loading

0 comments on commit 94e5e80

Please sign in to comment.