-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fbfe4f
commit 130a2de
Showing
18 changed files
with
190 additions
and
99 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
|
||
import React, { useEffect } from 'react'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
|
||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; | ||
|
||
import Header from './Header'; | ||
import { SignUpScreen } from '../Auth'; | ||
import { SelectUserScreen, WrappedScreen } from '../Wrapped'; | ||
import { NoMatchScreen } from '../Misc'; | ||
|
||
import { setPrivateAccess as _setPrivateAccess } from '../../redux/actions/userActions'; | ||
import { getUserMetadata } from '../../api'; | ||
import Footer from './Footer'; | ||
|
||
function App() { | ||
const userId = useSelector((state) => state.user.userId); | ||
const isAuthenticated = userId && userId.length > 0; | ||
|
||
const dispatch = useDispatch(); | ||
const setPrivateAccess = (access) => dispatch(_setPrivateAccess(access)); | ||
|
||
useEffect(() => { | ||
async function getPrivateAccess() { | ||
if (userId && userId.length > 0) { | ||
const result = await getUserMetadata(userId); | ||
if (result !== null && result.private_access !== undefined) { | ||
setPrivateAccess(result.private_access); | ||
} | ||
} | ||
} | ||
getPrivateAccess(); | ||
}, [userId]); | ||
|
||
return ( | ||
<div className="h-screen flex flex-col"> | ||
<Router> | ||
<Header /> | ||
<section className="bg-white text-gray-700 flex-grow"> | ||
<Routes> | ||
{!isAuthenticated && ( | ||
<Route path="/signup" element={<SignUpScreen />} /> | ||
)} | ||
<Route path="/" element={<SelectUserScreen />} /> | ||
<Route path="/public/" element={<SelectUserScreen />} /> | ||
<Route path="/private/" element={<SelectUserScreen />} /> | ||
<Route path="/:userId/:year" element={<WrappedScreen />} /> | ||
<Route path="/:userId" element={<WrappedScreen />} /> | ||
<Route path="*" element={<NoMatchScreen />} /> | ||
</Routes> | ||
</section> | ||
<Footer /> | ||
</Router> | ||
</div> | ||
); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
function Footer() { | ||
return ( | ||
<footer className="body-font"> | ||
<div className="bg-gray-100 border-t border-gray-300"> | ||
<div className="container mx-auto py-4 px-5"> | ||
<p className="text-gray-500 text-sm text-center"> | ||
© 2023 GitHub Trends | ||
</p> | ||
</div> | ||
</div> | ||
</footer> | ||
); | ||
} | ||
|
||
export default Footer; |
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,3 +1,4 @@ | ||
import App from './App'; | ||
import AppTrends from './AppTrends'; | ||
import AppWrapped from './AppWrapped'; | ||
|
||
export default App; | ||
export { AppTrends, AppWrapped }; |
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
Oops, something went wrong.