2024-02-28 21:02:05 +03:00
|
|
|
import React, { type FC } from 'react';
|
2024-01-31 03:01:58 +03:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
import usePrimaryMediaInfo from './usePrimaryMediaInfo';
|
|
|
|
|
|
|
|
import MediaInfoItem from './MediaInfoItem';
|
|
|
|
import StarIcons from './StarIcons';
|
|
|
|
import CaptionMediaInfo from './CaptionMediaInfo';
|
|
|
|
import CriticRatingMediaInfo from './CriticRatingMediaInfo';
|
|
|
|
import EndsAt from './EndsAt';
|
2024-08-21 03:27:03 +03:00
|
|
|
|
|
|
|
import { ItemMediaKind } from 'types/base/models/item-media-kind';
|
2024-03-03 01:31:35 +03:00
|
|
|
import type { ItemDto } from 'types/base/models/item-dto';
|
2024-01-31 03:01:58 +03:00
|
|
|
import type { MiscInfo } from 'types/mediaInfoItem';
|
|
|
|
|
|
|
|
interface PrimaryMediaInfoProps {
|
|
|
|
className?: string;
|
|
|
|
item: ItemDto;
|
|
|
|
isYearEnabled?: boolean;
|
|
|
|
isContainerEnabled?: boolean;
|
|
|
|
isEpisodeTitleEnabled?: boolean;
|
|
|
|
isCriticRatingEnabled?: boolean;
|
|
|
|
isEndsAtEnabled?: boolean;
|
|
|
|
isOriginalAirDateEnabled?: boolean;
|
|
|
|
isRuntimeEnabled?: boolean;
|
|
|
|
isProgramIndicatorEnabled?: boolean;
|
|
|
|
isEpisodeTitleIndexNumberEnabled?: boolean;
|
|
|
|
isOfficialRatingEnabled?: boolean;
|
|
|
|
isStarRatingEnabled?: boolean;
|
|
|
|
isCaptionIndicatorEnabled?: boolean;
|
|
|
|
isMissingIndicatorEnabled?: boolean;
|
|
|
|
getMissingIndicator: () => React.JSX.Element | null
|
|
|
|
}
|
|
|
|
|
|
|
|
const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({
|
|
|
|
className,
|
|
|
|
item,
|
|
|
|
isYearEnabled = false,
|
|
|
|
isContainerEnabled = false,
|
|
|
|
isEpisodeTitleEnabled = false,
|
|
|
|
isCriticRatingEnabled = false,
|
|
|
|
isEndsAtEnabled = false,
|
|
|
|
isOriginalAirDateEnabled = false,
|
|
|
|
isRuntimeEnabled = false,
|
|
|
|
isProgramIndicatorEnabled = false,
|
|
|
|
isEpisodeTitleIndexNumberEnabled = false,
|
|
|
|
isOfficialRatingEnabled = false,
|
|
|
|
isStarRatingEnabled = false,
|
|
|
|
isCaptionIndicatorEnabled = false,
|
|
|
|
isMissingIndicatorEnabled = false,
|
|
|
|
getMissingIndicator
|
|
|
|
}) => {
|
|
|
|
const miscInfo = usePrimaryMediaInfo({
|
|
|
|
item,
|
|
|
|
isYearEnabled,
|
|
|
|
isContainerEnabled,
|
|
|
|
isEpisodeTitleEnabled,
|
|
|
|
isOriginalAirDateEnabled,
|
|
|
|
isRuntimeEnabled,
|
|
|
|
isProgramIndicatorEnabled,
|
|
|
|
isEpisodeTitleIndexNumberEnabled,
|
|
|
|
isOfficialRatingEnabled
|
|
|
|
});
|
|
|
|
const {
|
|
|
|
StartDate,
|
|
|
|
HasSubtitles,
|
|
|
|
MediaType,
|
|
|
|
RunTimeTicks,
|
|
|
|
CommunityRating,
|
|
|
|
CriticRating
|
|
|
|
} = item;
|
|
|
|
|
|
|
|
const cssClass = classNames(className);
|
|
|
|
|
|
|
|
const renderMediaInfo = (info: MiscInfo | undefined, index: number) => (
|
|
|
|
<MediaInfoItem key={index} miscInfo={info} />
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box className={cssClass}>
|
|
|
|
{miscInfo.map((info, index) => renderMediaInfo(info, index))}
|
|
|
|
|
|
|
|
{isStarRatingEnabled && CommunityRating && (
|
|
|
|
<StarIcons communityRating={CommunityRating} />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{HasSubtitles && isCaptionIndicatorEnabled && <CaptionMediaInfo />}
|
|
|
|
|
|
|
|
{CriticRating && isCriticRatingEnabled && (
|
|
|
|
<CriticRatingMediaInfo criticRating={CriticRating} />
|
|
|
|
)}
|
|
|
|
|
|
|
|
{isEndsAtEnabled
|
2024-08-21 03:27:03 +03:00
|
|
|
&& MediaType === ItemMediaKind.Video
|
2024-01-31 03:01:58 +03:00
|
|
|
&& RunTimeTicks
|
|
|
|
&& !StartDate && <EndsAt runTimeTicks={RunTimeTicks} />}
|
|
|
|
|
|
|
|
{isMissingIndicatorEnabled && (
|
|
|
|
getMissingIndicator()
|
|
|
|
)}
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PrimaryMediaInfo;
|