diff --git a/frontend/src/app/(page)/explore/components/SongList.tsx b/frontend/src/app/(page)/explore/components/SongList.tsx index 025d63f..11ac8d3 100644 --- a/frontend/src/app/(page)/explore/components/SongList.tsx +++ b/frontend/src/app/(page)/explore/components/SongList.tsx @@ -23,7 +23,7 @@ export default function SongList({ const loadSongs = async () => { try { const fetchedSongs = await fetchSongsList(); - console.log("Fetched Songs:", fetchedSongs); // Debug log + //console.log("Fetched Songs:", fetchedSongs); // Debug log setAllSongs(fetchedSongs); } catch (error) { console.error("Error fetching songs:", error); @@ -51,6 +51,9 @@ export default function SongList({ const handlePlayPause = useCallback(() => { setIsPlaying(!isPlaying); }, [isPlaying]); + const handlePlayerClose = () => { + setSelectedSong(null); + }; const handleNext = useCallback(() => { if (!selectedSong) return; @@ -112,7 +115,6 @@ export default function SongList({ }} genres={selectedSong.album.genres || ""} artistImage={selectedSong.artist.picture_medium} - isFavorite={selectedSong.isFavorite} isPlaying={isPlaying} onPlayPause={handlePlayPause} onNext={handleNext} @@ -120,6 +122,7 @@ export default function SongList({ onFavoriteToggle={() => selectedSong && toggleFavoriteHandler(selectedSong.id) } + onClose={handlePlayerClose} /> )} diff --git a/frontend/src/components/ui/GenroButtons.tsx b/frontend/src/components/ui/GenroButtons.tsx index 09ec661..1741135 100644 --- a/frontend/src/components/ui/GenroButtons.tsx +++ b/frontend/src/components/ui/GenroButtons.tsx @@ -10,10 +10,12 @@ const genres = [ "Electrónica", "Pop", "Rock", - "Rap", + "Rap/Hip Hop", "K-pop", "Clássica", "Dance", + "Alternativo", + "Electro", ]; export default function GenreButtons({ diff --git a/frontend/src/components/ui/Player.tsx b/frontend/src/components/ui/Player.tsx index 30fd3a5..a849dba 100644 --- a/frontend/src/components/ui/Player.tsx +++ b/frontend/src/components/ui/Player.tsx @@ -9,7 +9,7 @@ import { Square, FastForward, SkipForward, - Heart, + X, } from "lucide-react"; interface PlayerProps { @@ -28,7 +28,7 @@ interface PlayerProps { onNext?: () => void; onPrevious?: () => void; onFavoriteToggle: (songId: string) => void; - isFavorite: boolean; + onClose: () => void; } const Player: React.FC = ({ @@ -39,11 +39,13 @@ const Player: React.FC = ({ onPlayPause, onNext, onPrevious, - onFavoriteToggle, + + onClose, }) => { const [progress, setProgress] = useState(0); const [currentTime, setCurrentTime] = useState("00:00"); const [error, setError] = useState(null); + const [isPlayerVisible, setIsPlayerVisible] = useState(true); const playerRef = useRef(null); const audioRef = useRef(null); @@ -174,6 +176,11 @@ const Player: React.FC = ({ } }; + const handlePlayerClose = () => { + setIsPlayerVisible(false); + onClose(); + }; + const formatTime = (time: number): string => { const minutes = Math.floor(time / 60); const seconds = Math.floor(time % 60); @@ -182,7 +189,7 @@ const Player: React.FC = ({ .padStart(2, "0")}`; }; - if (!currentSong) return null; + if (!currentSong || !isPlayerVisible) return null; return (
= ({

{currentSong.artist}

{genres}

- onFavoriteToggle(currentSong.id)} - /> +
+ +
@@ -252,7 +256,7 @@ const Player: React.FC = ({ className="text-primary cursor-pointer" size={47} style={{ strokeWidth: 2, fill: "currentColor" }} - onClick={handleStop} // Cambia a handleStop + onClick={handleStop} /> - genre.toLowerCase().includes(selectedGenre.toLowerCase()) - ); - - return matchesSearch && matchesGenre; - }); -}; - - -/*import { Song } from "@/types/ui/Song"; - -export const useFilterSongs = ( - songs: Song[], - searchTerm: string, - selectedGenre: string -): Song[] => { - if (!Array.isArray(songs)) { - return []; - } - - return songs.filter((song) => { - const matchesSearch = [song.title, song.artist.name, song.album.genres] - .map((field) => (typeof field === "string" ? field : "").toLowerCase()) - .some((value) => value.includes(searchTerm.toLowerCase())); - - const genres = song.album.genres || ""; - const matchesGenre = - selectedGenre === "Todos" || genres.toLowerCase().includes(selectedGenre.toLowerCase()); + selectedGenre === "Todos" || genres.some((genre) => { + if (selectedGenre.toLowerCase().includes('/')) { + // Use includes for compound genres + return genre.toLowerCase().includes(selectedGenre.toLowerCase()); + } else { + // Use exact match for single-word genres + return genre.toLowerCase() === selectedGenre.toLowerCase(); + } + }); return matchesSearch && matchesGenre; }); }; -*/ \ No newline at end of file