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/screens/JoinStation.jsx b/frontend/src/screens/JoinStation.jsx index 2f3e758..ed2fff4 100644 --- a/frontend/src/screens/JoinStation.jsx +++ b/frontend/src/screens/JoinStation.jsx @@ -8,13 +8,15 @@ function JoinStation() { const handleJoinStation = (stationID) => { console.log("Joining station with ID:" + stationID); - navigate("/station"); + navigate(`/station/${stationID}`); }; useEffect(() => { - console.log("Test"); - - getStations(getStations()); + async function fetchStations() { + const result = await getStations(); // assuming getStations is async + setStations(result); + } + fetchStations(); }, []); return ( @@ -26,8 +28,12 @@ function JoinStation() {
{stations.map((station, index) => { return ( -
- station +
+

Station Name: {station.name}

+

Station Description: {station.description}

+
); })} diff --git a/frontend/src/screens/StationPage.jsx b/frontend/src/screens/StationPage.jsx index 77d5058..c4830eb 100644 --- a/frontend/src/screens/StationPage.jsx +++ b/frontend/src/screens/StationPage.jsx @@ -1,30 +1,13 @@ -import React, { useState } from 'react'; -import AddSongModal from './AddSongModal'; -import LoginButton from '../components/LoginButton'; +import React, { useState, useParams } from "react"; +import AddSongModal from "./AddSongModal"; +import LoginButton from "../components/LoginButton"; function StationPage() { + const { id } = useParams(); const [isModalOpen, setIsModalOpen] = useState(false); - const [currentSong, setCurrentSong] = useState({ - title: "No song playing", - artist: "Add songs to get started", - isPlaying: false - }); - // Empty song list - no songs initially const recommendedSongs = []; - const handlePlayPause = () => { - setCurrentSong(prev => ({ ...prev, isPlaying: !prev.isPlaying })); - }; - - const handleNext = () => { - console.log('Next song'); - }; - - const handlePrevious = () => { - console.log('Previous song'); - }; - const openModal = () => { setIsModalOpen(true); }; @@ -48,39 +31,6 @@ function StationPage() { -
-
-

{currentSong.title}

-

{currentSong.artist}

-
- -
- - - - - -
-
-

Song Queue

@@ -88,14 +38,14 @@ function StationPage() { Add Song
- +
{recommendedSongs.length === 0 ? (

No songs in queue yet. Add some songs to get started!

) : ( - recommendedSongs.map(song => ( + recommendedSongs.map((song) => (

{song.title}

diff --git a/frontend/src/utils/GetStations.js b/frontend/src/utils/GetStations.js index 21d954e..886f5c0 100644 --- a/frontend/src/utils/GetStations.js +++ b/frontend/src/utils/GetStations.js @@ -4,17 +4,22 @@ import { } from "../constants/ApiConstants"; export async function getStations() { - fetch(RADIOSTATION_URL + LIST_RADIOSTATIONS_ENDPOINT, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }) - .then((response) => response.json()) - .then((data) => { - console.log("Station:", data); - }) - .catch((error) => { - console.error("Error creating station:", error); - }); + try { + const response = await fetch( + RADIOSTATION_URL + LIST_RADIOSTATIONS_ENDPOINT, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + } + ); + + const data = await response.json(); + console.log("Station:", data.data); + return data.data; + } catch (error) { + console.error("Error fetching stations:", error); + return []; + } } diff --git a/frontend/src/utils/StationsCreate.js b/frontend/src/utils/StationsCreate.js index 34ac305..7d5d31f 100644 --- a/frontend/src/utils/StationsCreate.js +++ b/frontend/src/utils/StationsCreate.js @@ -7,8 +7,8 @@ import { export async function createStation(name, description) { const body = { - name: "My Awesome Station", - description: "The best music station ever", + name: name, + description: description, }; fetch(RADIOSTATION_URL + CREATE_RADIOSTATION_ENDPOINT, {