Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d5a576b
Auth-o branch
RamsesCode Jul 30, 2025
64058a8
log in button and autho implemented but some errors on AuthO's side
RamsesCode Jul 30, 2025
bb8d4c1
Auth-o finished and fully working
RamsesCode Jul 31, 2025
3b78764
random push to fix merge
RamsesCode Jul 31, 2025
65a6a60
added webpack rule for images
Rend1027 Aug 1, 2025
46a99d9
added content to the landing page
Rend1027 Aug 1, 2025
a4226c4
Merge pull request #18 from Local-Beats/flo
Rend1027 Aug 1, 2025
69a10d7
changes but still not working for the momenent only error is browser …
RamsesCode Aug 1, 2025
f430123
Merge branch 'currently-playing' of github.com:Local-Beats/LocalBeats…
Rend1027 Aug 1, 2025
a3dc80f
created axios instance
Rend1027 Aug 1, 2025
bb29c7b
updated useEffect hook
Rend1027 Aug 1, 2025
ae34aef
updated app.jsx no longer need callback
Rend1027 Aug 1, 2025
107c968
fixed- can now recieve custom claim
Rend1027 Aug 2, 2025
733480e
feat- created Dashboard startin point
Rend1027 Aug 2, 2025
d49b626
Merge pull request #19 from Local-Beats/flo
Rend1027 Aug 3, 2025
a872c38
refactored- removed SI from source code
Rend1027 Aug 3, 2025
50940c8
refactored- send id token to backend
Rend1027 Aug 3, 2025
6cb9155
fixed- extract claim
Rend1027 Aug 3, 2025
7e9678a
fixed- Authorixation header
Rend1027 Aug 3, 2025
810bb3b
refactored- updated http request to fetch data from DB
Rend1027 Aug 4, 2025
018fbea
Merge pull request #20 from Local-Beats/flo
Rend1027 Aug 4, 2025
33decaa
resized logo
Rend1027 Aug 4, 2025
955674c
Merge pull request #21 from Local-Beats/flo
Rend1027 Aug 4, 2025
fead913
Updated package-lock.json file
MrRobot458 Aug 4, 2025
5d71a33
Merge branch 'main' of https://github.com/Local-Beats/LocalBeats-Fron…
MrRobot458 Aug 4, 2025
d8edf85
feat-Created listener Card
Rend1027 Aug 5, 2025
4f73aa9
feat-Created Active Listener component
Rend1027 Aug 5, 2025
ad74461
feat-created dummy content for listener card
Rend1027 Aug 5, 2025
3aa95c5
added some css to card
Rend1027 Aug 5, 2025
967044e
getting the track is not fully working and ready to be merged
RamsesCode Aug 5, 2025
f040592
commenting out line 26 which shows errors because its unused
RamsesCode Aug 5, 2025
9c601a6
commented console logs
Rend1027 Aug 5, 2025
4937d74
Merge branch 'track' of github.com:Local-Beats/LocalBeats-Frontend in…
Rend1027 Aug 5, 2025
769da9d
refactored- reconfigured our front-end so it only uses one axios inst…
Rend1027 Aug 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env.example

This file was deleted.

Binary file added dist/images/3a426ca7e83eb4d81d6e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="favicon.ico" />
<title>Capstone 1</title>
<script defer src="main.js"></script>
</head>
<body>
<div id="root"></div>
</body>
</html>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- ⚠️ Only for development -->
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;">

<link rel="icon" href="favicon.ico" />
<title>Capstone 1</title>
<script defer src="main.js"></script>
</head>

<body>
<div id="root"></div>
</body>

</html>
54 changes: 32 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
"license": "ISC",
"description": "",
"dependencies": {
"@auth0/auth0-react": "^2.3.0",
"@auth0/auth0-react": "^2.4.0",
"@babel/core": "^7.27.4",
"@babel/preset-react": "^7.27.1",
"axios": "^1.10.0",
"babel-loader": "^10.0.0",
"dotenv": "^17.1.0",
"jwt-decode": "^4.0.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router-dom": "^7.6.3",
Expand Down
139 changes: 111 additions & 28 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,102 @@
import React, { useState, useEffect } from "react";
import { createRoot } from "react-dom/client";
import axios from "axios";
// import axios from "axios";
import "./AppStyles.css";
import NavBar from "./components/NavBar";
import Dashboard from "./components/Dashboard";
import NowPlaying from "./components/NowPlaying";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Login from "./components/Login";
import Signup from "./components/Signup";
import Home from "./components/Home";
// import Home from "./components/Home";
import NotFound from "./components/NotFound";
import { API_URL } from "./shared";
// import CallBack from "./components/CallBack";
// import { jwtDecode } from "jwt-decode";
// import { API_URL } from "./shared";
import axios from './utils/axiosInstance';
import { Auth0Provider, useAuth0 } from "@auth0/auth0-react";

// AUTH0 CONFIGURATION
const AUTH0_DOMAIN = process.env.REACT_APP_AUTH0_DOMAIN;
const AUTH0_CLIENT_ID = process.env.REACT_APP_AUTH0_CLIENT_ID;

const App = () => {
const [user, setUser] = useState(null);
console.log("this is user--->", user)
//const [token, setToken] = useState("");

const checkAuth = async () => {
try {
const response = await axios.get(`${API_URL}/auth/me`, {
withCredentials: true,
});
setUser(response.data.user);
} catch {
console.log("Not authenticated");
setUser(null);
}
};
const {
isAuthenticated,
user: auth0User,
getIdTokenClaims,
} = useAuth0(); // swapped getAccessTokenSilently for getIdTokenClaims

// Check authentication status on app load
useEffect(() => {
const checkAuth = async () => {
try {
const response = await axios.get("/auth/me", {
withCredentials: true,
});
setUser(response.data.user);
} catch {
console.log("Not authenticated");
setUser(null);
}
};
checkAuth();
}, []);

const handleLogout = async () => {
try {
// Logout from our backend
await axios.post(
`${API_URL}/auth/logout`,
{},
{
useEffect(() => {
const syncSpotifyAndFetchUser = async () => {
if (!isAuthenticated || !auth0User) {
console.warn("User not authenticated or auth0User not ready.");
return;
}

try {
const claims = await getIdTokenClaims();
const spotifyAccessToken = claims["https://localbeats.app/spotify_access_token"];

if (!spotifyAccessToken) {
console.warn("No Spotify access token found in ID token claims.");
return;
}

// Sync with backend — this will update DB & create session token
await axios.post("/auth/spotify/sync", {}, {
headers: {
Authorization: `Bearer ${spotifyAccessToken}`,
},
withCredentials: true,
}
);
);


// Fetch user info from DB (using session token)
const res = await axios.get("/auth/me", { withCredentials: true });
console.log("this is data-->", res.data)
setUser(res.data.user);
} catch (err) {
console.error("Post-login sync failed:", err);
}
};

// Update frontend state
// setUser({
// name: auth0User.name,
// email: auth0User.email,
// picture: auth0User.picture,
// });

console.log("Auth0 state ->", { isAuthenticated, auth0User });
syncSpotifyAndFetchUser();
}, [isAuthenticated, auth0User, getIdTokenClaims]);



const handleLogout = async () => {
try {
await axios.post('/auth/logout', {}, { withCredentials: true });
setUser(null);
} catch (error) {
console.error("Logout error:", error);
Expand All @@ -51,21 +108,47 @@ const App = () => {
<NavBar user={user} onLogout={handleLogout} />
<div className="app">
<Routes>
<Route path="/login" element={<Login setUser={setUser} />} />
<Route path="/" element={<Login setUser={setUser} />} />
<Route path="/signup" element={<Signup setUser={setUser} />} />
<Route exact path="/" element={<Home />} />
<Route path="/dashboard" element={
<>
<Dashboard user={user} />
<NowPlaying />
</>
} />

<Route path="*" element={<NotFound />} />
</Routes>
</div>
</div>
);
};

// ✅ Root with Spotify audience + scopes
const Root = () => {
return (
<Router>
<App />
</Router>
// <Auth0Provider
// domain={AUTH0_DOMAIN}
// clientId={AUTH0_CLIENT_ID}
// authorizationParams={{
// redirect_uri: window.location.origin + "/callback",
// audience: "https://api.spotify.com",
// scope: "user-read-email user-read-private user-read-playback-state user-read-currently-playing offline_access",
// }}
// cacheLocation="localstorage"
// >
<Auth0Provider
domain={AUTH0_DOMAIN}
clientId={AUTH0_CLIENT_ID}
authorizationParams={{
redirect_uri: window.location.origin + "/dashboard"
}}
cacheLocation="localstorage"
>
<Router>
<App />
</Router>
</Auth0Provider>
);
};

Expand Down
Binary file added src/assets/LocalBeats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/components/ActiveListener.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import ListenerCard from "./LIstenerCard";

const Activelistener = ({ user }) => {
// console.log("this is user from actiive listener---> ", user)
return (
<main>
<h1>
Active Listeners
</h1>
{/* <div className="active-listener-cards">
<ul>
{user.map((element) => (
<li key={user.id}>
<ListenerCard element={element} />
</li>
))}
</ul>
</div> */}

</main>
)
}

export default Activelistener;
4 changes: 3 additions & 1 deletion src/components/AuthStyles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.auth-container {
display: flex;
flex-direction: column;
gap: 5rem;
justify-content: center;
align-items: center;
min-height: 60vh;
Expand Down Expand Up @@ -143,4 +145,4 @@

.auth-link a:hover {
text-decoration: underline;
}
}
Loading