@@ -79,6 +79,7 @@ export default function RecommendedAlbums({ genre }: RecommendedAlbumsProps) {
album_cover={song.album_object.cover_url}
album_id={song.album_object.id}
album_name={song.album_object.name}
+ album_songs_count={song.album_object.songs.length}
artist_id={song.artist_object.id}
artist_name={song.artist}
first_release_date={song.album_object.first_release_date}
diff --git a/apps/web/components/Home/ScrollButtons.tsx b/apps/web/components/Home/ScrollButtons.tsx
index 4860b8f3..a64d5967 100644
--- a/apps/web/components/Home/ScrollButtons.tsx
+++ b/apps/web/components/Home/ScrollButtons.tsx
@@ -1,13 +1,16 @@
-"use client"
+"use client";
import getSession from '@/lib/Authentication/JWT/getSession';
import { getProfilePicture } from '@music/sdk';
import { ScrollArea, ScrollBar } from '@music/ui/components/scroll-area';
-import { ChevronLeft, ChevronRight } from 'lucide-react';
+import { ChevronLeft, ChevronRight, Ellipsis, Pin, Eye, EyeOff } from 'lucide-react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import Image from 'next/image';
+import { Popover, PopoverContent, PopoverTrigger } from '@music/ui/components/popover';
+import { useLayoutConfig } from '../Providers/LayoutConfigContext';
type ScrollButtonsProps = {
+ id?: string;
children: React.ReactNode;
heading: string;
showUser?: boolean;
@@ -15,13 +18,14 @@ type ScrollButtonsProps = {
imageUrl?: string;
};
-export default function ScrollButtons({ children, heading, showUser, topText, imageUrl }: ScrollButtonsProps) {
+export default function ScrollButtons({ id, children, heading, showUser, topText, imageUrl }: ScrollButtonsProps) {
const scrollRef = useRef
(null);
const [isAtStart, setIsAtStart] = useState(true);
const [isAtEnd, setIsAtEnd] = useState(false);
const [canScroll, setCanScroll] = useState(false);
const [profilePicture, setProfilePicture] = useState(null);
const [username, setUsername] = useState(null);
+ const { components, setComponents } = useLayoutConfig(); // Use the context
const checkScrollPosition = useCallback(() => {
if (scrollRef.current) {
@@ -34,7 +38,7 @@ export default function ScrollButtons({ children, heading, showUser, topText, im
useEffect(() => {
const fetchUserData = async () => {
- const session = await getSession();
+ const session = getSession();
const profilePictureBlob = await getProfilePicture(Number(session?.sub));
const profilePictureUrl = URL.createObjectURL(profilePictureBlob);
setProfilePicture(profilePictureUrl);
@@ -75,11 +79,30 @@ export default function ScrollButtons({ children, heading, showUser, topText, im
}
}, []);
+ const handlePinToggle = () => {
+ const updatedComponents = components.map((component) =>
+ component.id === id ? { ...component, pinned: !component.pinned } : component
+ );
+ const pinnedComponents = updatedComponents.filter((component) => component.pinned);
+ const unpinnedComponents = updatedComponents.filter((component) => !component.pinned);
+ const newComponents = [...pinnedComponents, ...unpinnedComponents];
+ setComponents(newComponents);
+ };
+
+ const handleVisibilityToggle = () => {
+ const updatedComponents = components.map((component) =>
+ component.id === id ? { ...component, visible: !component.visible } : component
+ );
+ setComponents(updatedComponents);
+ };
+
+ const currentComponent = components.find((component) => component.id === id);
+
return (
<>
- { (showUser || imageUrl) &&
+ {(showUser || imageUrl) &&
- {false ? (
-
- ) : (
-
+ {id && (
+
+
+
+
+
+
+
+
+
+
+
)}