mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
feat(api): fetch listens from spotify
This commit is contained in:
parent
f253a66f86
commit
f2065d3f1f
54 changed files with 1180 additions and 256 deletions
|
|
@ -1,27 +0,0 @@
|
|||
import React from "react";
|
||||
import { useAuth0 } from "../react-auth0-spa";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
const NavBar = () => {
|
||||
const { isAuthenticated, loginWithRedirect, logout } = useAuth0();
|
||||
|
||||
return (
|
||||
<div>
|
||||
{!isAuthenticated && (
|
||||
<button onClick={() => loginWithRedirect({})}>Log in</button>
|
||||
)}
|
||||
|
||||
{isAuthenticated && <button onClick={() => logout()}>Log out</button>}
|
||||
|
||||
{isAuthenticated && (
|
||||
<span>
|
||||
<Link to="/">Home</Link>
|
||||
<Link to="/profile">Profile</Link>
|
||||
<Link to="/external-api">External API</Link>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NavBar;
|
||||
9
frontend/src/components/NavBar.jsx
Normal file
9
frontend/src/components/NavBar.jsx
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import React from "react";
|
||||
|
||||
export function NavBar() {
|
||||
return (
|
||||
<div>
|
||||
<a href="/api/v1/auth/spotify">Login with Spotify</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
import React, { useEffect } from "react";
|
||||
import { Route } from "react-router-dom";
|
||||
import { useAuth0 } from "../react-auth0-spa";
|
||||
|
||||
const PrivateRoute = ({ component: Component, path, ...rest }) => {
|
||||
const { loading, isAuthenticated, loginWithRedirect } = useAuth0();
|
||||
|
||||
useEffect(() => {
|
||||
if (loading || isAuthenticated) {
|
||||
return;
|
||||
}
|
||||
const fn = async () => {
|
||||
await loginWithRedirect({
|
||||
appState: { targetUrl: path }
|
||||
});
|
||||
};
|
||||
fn();
|
||||
}, [loading, isAuthenticated, loginWithRedirect, path]);
|
||||
|
||||
const render = props =>
|
||||
isAuthenticated === true ? <Component {...props} /> : null;
|
||||
|
||||
return <Route path={path} render={render} {...rest} />;
|
||||
};
|
||||
|
||||
export default PrivateRoute;
|
||||
Loading…
Add table
Add a link
Reference in a new issue