Fixed Join Screen and added Station Page navigation

This commit is contained in:
Noah Knapp 2025-08-02 04:23:49 +02:00
parent 4ea9fea362
commit db8ab4e166
5 changed files with 46 additions and 85 deletions

View file

@ -1,10 +1,10 @@
import React from 'react'; import React from "react";
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import Home from './screens/Home'; import Home from "./screens/Home";
import CreateStation from './screens/CreateStation'; import CreateStation from "./screens/CreateStation";
import JoinStation from './screens/JoinStation'; import JoinStation from "./screens/JoinStation";
import StationPage from './screens/StationPage'; import StationPage from "./screens/StationPage";
import './App.css'; import "./App.css";
function App() { function App() {
return ( return (
@ -14,7 +14,7 @@ function App() {
<Route path="/" element={<Home />} /> <Route path="/" element={<Home />} />
<Route path="/create-station" element={<CreateStation />} /> <Route path="/create-station" element={<CreateStation />} />
<Route path="/join-station" element={<JoinStation />} /> <Route path="/join-station" element={<JoinStation />} />
<Route path="/station" element={<StationPage />} /> <Route path="/station/:id" element={<StationPage />} />
</Routes> </Routes>
</Router> </Router>
</div> </div>

View file

@ -8,13 +8,15 @@ function JoinStation() {
const handleJoinStation = (stationID) => { const handleJoinStation = (stationID) => {
console.log("Joining station with ID:" + stationID); console.log("Joining station with ID:" + stationID);
navigate("/station"); navigate(`/station/${stationID}`);
}; };
useEffect(() => { useEffect(() => {
console.log("Test"); async function fetchStations() {
const result = await getStations(); // assuming getStations is async
getStations(getStations()); setStations(result);
}
fetchStations();
}, []); }, []);
return ( return (
@ -26,8 +28,12 @@ function JoinStation() {
<main className="join-station-content"> <main className="join-station-content">
{stations.map((station, index) => { {stations.map((station, index) => {
return ( return (
<div className="verify-method-section"> <div key={index}>
<text>station</text> <p>Station Name: {station.name}</p>
<p>Station Description: {station.description}</p>
<button onClick={() => handleJoinStation(station.id)}>
join this station
</button>
</div> </div>
); );
})} })}

View file

@ -1,30 +1,13 @@
import React, { useState } from 'react'; import React, { useState, useParams } from "react";
import AddSongModal from './AddSongModal'; import AddSongModal from "./AddSongModal";
import LoginButton from '../components/LoginButton'; import LoginButton from "../components/LoginButton";
function StationPage() { function StationPage() {
const { id } = useParams();
const [isModalOpen, setIsModalOpen] = useState(false); 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 recommendedSongs = [];
const handlePlayPause = () => {
setCurrentSong(prev => ({ ...prev, isPlaying: !prev.isPlaying }));
};
const handleNext = () => {
console.log('Next song');
};
const handlePrevious = () => {
console.log('Previous song');
};
const openModal = () => { const openModal = () => {
setIsModalOpen(true); setIsModalOpen(true);
}; };
@ -48,39 +31,6 @@ function StationPage() {
<LoginButton /> <LoginButton />
</header> </header>
<div className="media-controls-section">
<div className="current-song">
<h3>{currentSong.title}</h3>
<p>{currentSong.artist}</p>
</div>
<div className="media-controls">
<button className="control-btn" onClick={handlePrevious}>
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/>
</svg>
</button>
<button className="control-btn play-pause" onClick={handlePlayPause}>
{currentSong.isPlaying ? (
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"/>
</svg>
) : (
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M8 5v14l11-7z"/>
</svg>
)}
</button>
<button className="control-btn" onClick={handleNext}>
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"/>
</svg>
</button>
</div>
</div>
<div className="songs-section"> <div className="songs-section">
<div className="section-header"> <div className="section-header">
<h2>Song Queue</h2> <h2>Song Queue</h2>
@ -88,14 +38,14 @@ function StationPage() {
Add Song Add Song
</button> </button>
</div> </div>
<div className="songs-list"> <div className="songs-list">
{recommendedSongs.length === 0 ? ( {recommendedSongs.length === 0 ? (
<div className="empty-songs-state"> <div className="empty-songs-state">
<p>No songs in queue yet. Add some songs to get started!</p> <p>No songs in queue yet. Add some songs to get started!</p>
</div> </div>
) : ( ) : (
recommendedSongs.map(song => ( recommendedSongs.map((song) => (
<div key={song.id} className="song-item"> <div key={song.id} className="song-item">
<div className="song-info"> <div className="song-info">
<h4>{song.title}</h4> <h4>{song.title}</h4>

View file

@ -4,17 +4,22 @@ import {
} from "../constants/ApiConstants"; } from "../constants/ApiConstants";
export async function getStations() { export async function getStations() {
fetch(RADIOSTATION_URL + LIST_RADIOSTATIONS_ENDPOINT, { try {
method: "GET", const response = await fetch(
headers: { RADIOSTATION_URL + LIST_RADIOSTATIONS_ENDPOINT,
"Content-Type": "application/json", {
}, method: "GET",
}) headers: {
.then((response) => response.json()) "Content-Type": "application/json",
.then((data) => { },
console.log("Station:", data); }
}) );
.catch((error) => {
console.error("Error creating station:", error); const data = await response.json();
}); console.log("Station:", data.data);
return data.data;
} catch (error) {
console.error("Error fetching stations:", error);
return [];
}
} }

View file

@ -7,8 +7,8 @@ import {
export async function createStation(name, description) { export async function createStation(name, description) {
const body = { const body = {
name: "My Awesome Station", name: name,
description: "The best music station ever", description: description,
}; };
fetch(RADIOSTATION_URL + CREATE_RADIOSTATION_ENDPOINT, { fetch(RADIOSTATION_URL + CREATE_RADIOSTATION_ENDPOINT, {