diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 7b0b635..465c9cb 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,10 +1,10 @@ -import React from 'react'; -import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; -import Home from './screens/Home'; -import CreateStation from './screens/CreateStation'; -import JoinStation from './screens/JoinStation'; -import StationPage from './screens/StationPage'; -import './App.css'; +import React from "react"; +import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import Home from "./screens/Home"; +import CreateStation from "./screens/CreateStation"; +import JoinStation from "./screens/JoinStation"; +import StationPage from "./screens/StationPage"; +import "./App.css"; function App() { return ( @@ -14,7 +14,7 @@ function App() { } /> } /> } /> - } /> + } /> diff --git a/frontend/src/constants/ApiConstants.js b/frontend/src/constants/ApiConstants.js index c7fd4b7..caaf274 100644 --- a/frontend/src/constants/ApiConstants.js +++ b/frontend/src/constants/ApiConstants.js @@ -2,3 +2,7 @@ export const RADIOSTATION_URL = "http://localhost:8080/api"; export const CREATE_RADIOSTATION_ENDPOINT = "/radio-stations"; export const LIST_RADIOSTATIONS_ENDPOINT = "/radio-stations"; +export const ADD_CLIENT_ENDPOINT = "/clients/connect"; + +export const SPOTIFY_PREMIUM_TOKEN = + "BQCEnWrYVdmta4Eekdkewazun99IuocRAyPEbwPSrHuGYgZYg7JGlXG2BLmRL6fwjzPJkrmHiqlTLSn1yqR36awA9Rv4n9dwvTBv1DjAitsuzaEVg7PtYdbUHXqP2HJJ4dDDvTtvUfWIBDY_Afa7WgY1cyRbl-p4VobNHXUR9N3Ye1qBTgH3RZ5ziIbIoNWe_JrxYvcedkvr23zXUVabOyahTgt_YdmnCWt2Iu8XT8sjhSyc8tOCqbs_KqE-Qe1WSPUCrGS8"; diff --git a/frontend/src/screens/CreateStation.jsx b/frontend/src/screens/CreateStation.jsx index bd53ac0..4578b30 100644 --- a/frontend/src/screens/CreateStation.jsx +++ b/frontend/src/screens/CreateStation.jsx @@ -6,9 +6,10 @@ import { createStation } from "../utils/StationsCreate"; function CreateStation() { const [name, setName] = useState(""); const [description, setDescription] = useState(""); + const [joinCode, setJoinCode] = useState(""); const handleCreateStation = () => { - createStation(name, description); + setJoinCode(createStation(name, description)); }; return ( @@ -28,6 +29,8 @@ function CreateStation() { > Create Radio Station + +

your joinCode: {joinCode}

); diff --git a/frontend/src/screens/Home.jsx b/frontend/src/screens/Home.jsx index 414e9d9..c6637d5 100644 --- a/frontend/src/screens/Home.jsx +++ b/frontend/src/screens/Home.jsx @@ -1,33 +1,35 @@ -import React from 'react'; -import { useNavigate } from 'react-router-dom'; +import React from "react"; +import { useNavigate } from "react-router-dom"; function Home() { const navigate = useNavigate(); const handleCreateStation = () => { - navigate('/create-station'); + navigate("/create-station"); }; const handleJoinStation = () => { - navigate('/join-station'); + navigate("/join-station"); }; return (

Radio Station Hub

-

Create or join a radio station to share music with friends

- +

+ Create or join a radio station to share music with friends +

+
- - -
); })} diff --git a/frontend/src/screens/StationPage.jsx b/frontend/src/screens/StationPage.jsx index 77d5058..35ea7e9 100644 --- a/frontend/src/screens/StationPage.jsx +++ b/frontend/src/screens/StationPage.jsx @@ -1,30 +1,41 @@ -import React, { useState } from 'react'; -import AddSongModal from './AddSongModal'; -import LoginButton from '../components/LoginButton'; +import { useParams } from "react-router-dom"; +import React, { useState, useEffect } from "react"; +import AddSongModal from "./AddSongModal"; +import LoginButton from "../components/LoginButton"; +import { addClientToStation } from "../utils/AddClientToStation"; function StationPage() { + const { stationID } = useParams(); + const [clientToken, setClientToken] = useState(""); const [isModalOpen, setIsModalOpen] = useState(false); - const [currentSong, setCurrentSong] = useState({ - title: "No song playing", - artist: "Add songs to get started", - isPlaying: false - }); + const [accessDenied, setAccessDenied] = useState(true); + + const [userName, setUserName] = useState(""); + const [joinCode, setJoinCode] = useState(""); + + const auth = async () => { + try { + const token = await addClientToStation(userName, joinCode); + setClientToken(token); + setAccessDenied(false); + } catch (error) { + console.error("Auth failed:", error); + setAccessDenied(true); + } + }; + + if (accessDenied) { + return ( +
+