Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion back/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
color: white;
}
</style>
<script type="module" crossorigin src="/assets/index-BZmU6KnB.js"></script>
<script type="module" crossorigin src="/assets/index-CfKkQ7O1.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-nNv3qBfI.css">
</head>
<body>
Expand Down
42 changes: 24 additions & 18 deletions front/src/components/GenreDetails/GenreDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
import SongCard from "@/components/SongCard/SongCard";
import { Flex, SimpleGrid, Skeleton } from "@chakra-ui/react";
import { Box, Center, For, SimpleGrid, Skeleton } from "@chakra-ui/react";
import { useParams } from "react-router-dom";
import ScrollUpArrow from "@/components/Utils/ScrollUpArrow";
import InfiniteScrollList from "@/components/Pagination/InfiniteScrollList";
import NotFound from "@/components/Error/NotFound";
import { Zoom } from "react-awesome-reveal";
import { SONGCARD_SIZES } from "@/components/constants/SongCardC";
import GenreDetHeader from "./GenreDetHeader";
import { SongResponse } from "@/types/songTypes";
import useGenreSongs from "../Utils/hooks/useGenreSongs";
import InfiniteScroll from "react-infinite-scroll-component";
import LoadingBeat from "../Utils/LoadingBeat";

const GenreDetails = () => {
const { genre } = useParams();
const { data, loading, genreKey, loadMore, activeSong, isPlaying, validGenre } = useGenreSongs(genre);
const dataLength = data?.getAllGenreSongs ? data.getAllGenreSongs.length : 20;

if (!validGenre || (!loading && !data)) return <NotFound
message={`The genre: "${genre}" was not found in the DB!`} />;

return (
<Flex w="full" h="full" align="center" justify="center" direction="column" pt={8} pb={20} gap={5}
textAlign="center">
<Zoom triggerOnce direction="down" delay={100}>
<Box w="full" h="full" direction="column" pt={8} gap={5} textAlign="center">
<Zoom triggerOnce direction="down" delay={100} style={{ paddingBottom: 40 }}>
<GenreDetHeader genre={genreKey} />
</Zoom>

<SimpleGrid columns={{ base: 2, sm: 3, md: 4, lg: 5 }} pt={5} gap={{ base: 3, sm: 3, md: 3, lg: 4 }} w="full">
{!data && Array.from({ length: 20 }).map((_, idx) => (
<Skeleton key={idx} w="full" maxW={SONGCARD_SIZES} loading={loading} aspectRatio={3/4} borderRadius="md" />
))}

{data && (
<InfiniteScrollList<SongResponse> renderItem={(song: SongResponse) => <SongCard key={song.id} {...song}
isSongPlaying={isPlaying && song.id === activeSong?.id} /> } items={data.getAllGenreSongs}
error="There was a problem trying to get the songs of this genre" onLoadMore={loadMore} />
)}
</SimpleGrid>

<InfiniteScroll dataLength={dataLength} next={loadMore} hasMore={true}
loader={<Center m={2}><LoadingBeat /></Center>} style={{ display: "block" }}>
<SimpleGrid columns={{ base: 2, sm: 3, md: 4, lg: 5 }} pt={5} gap={{ base: 3, sm: 3, md: 3,
lg: 4 }} w="full">
{!data && (Array.from({ length: 20 }).map((_, idx) => (
<Skeleton key={idx} w="full" maxW={SONGCARD_SIZES} loading={loading} aspectRatio={3/4}
borderRadius="md" />
)))}

{data && (
<For each={data.getAllGenreSongs}>
{(song: SongResponse) => <SongCard key={song.id} {...song}
isSongPlaying={isPlaying && song.id === activeSong?.id} />}
</For>
)}
</SimpleGrid>
</InfiniteScroll>
<ScrollUpArrow />
</Flex>
</Box>
);
};

Expand Down
Loading