2024-02-28 23:10:31 +03:00
|
|
|
import type { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
|
|
|
|
import type { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type';
|
2023-06-07 03:38:39 +03:00
|
|
|
import React, { FC } from 'react';
|
|
|
|
import { useGetGenres } from 'hooks/useFetchItems';
|
2024-09-23 02:53:44 +03:00
|
|
|
import NoItemsMessage from 'components/common/NoItemsMessage';
|
2023-06-07 03:38:39 +03:00
|
|
|
import Loading from 'components/loading/LoadingComponent';
|
|
|
|
import GenresSectionContainer from './GenresSectionContainer';
|
2024-02-28 23:10:31 +03:00
|
|
|
import type { ParentId } from 'types/library';
|
2023-06-07 03:38:39 +03:00
|
|
|
|
|
|
|
interface GenresItemsContainerProps {
|
2023-10-04 23:14:14 +03:00
|
|
|
parentId: ParentId;
|
2023-10-26 02:05:08 +03:00
|
|
|
collectionType: CollectionType | undefined;
|
|
|
|
itemType: BaseItemKind[];
|
2023-06-07 03:38:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const GenresItemsContainer: FC<GenresItemsContainerProps> = ({
|
|
|
|
parentId,
|
|
|
|
collectionType,
|
|
|
|
itemType
|
|
|
|
}) => {
|
2023-10-23 23:14:21 +03:30
|
|
|
const { isLoading, data: genresResult } = useGetGenres(itemType, parentId);
|
2023-06-07 03:38:39 +03:00
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
return <Loading />;
|
|
|
|
}
|
|
|
|
|
2023-10-23 23:14:21 +03:30
|
|
|
if (!genresResult?.Items?.length) {
|
2024-09-23 02:53:44 +03:00
|
|
|
return <NoItemsMessage message='MessageNoGenresAvailable' />;
|
2023-10-23 23:14:21 +03:30
|
|
|
}
|
|
|
|
|
2024-09-23 02:53:44 +03:00
|
|
|
return genresResult.Items.map((genre) => (
|
|
|
|
<GenresSectionContainer
|
|
|
|
key={genre.Id}
|
|
|
|
collectionType={collectionType}
|
|
|
|
parentId={parentId}
|
|
|
|
itemType={itemType}
|
|
|
|
genre={genre}
|
|
|
|
/>
|
|
|
|
));
|
2023-06-07 03:38:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default GenresItemsContainer;
|