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';
|
2024-08-10 04:09:59 +03:00
|
|
|
import type { PrimaryInfoOpts } from './type';
|
2024-01-31 03:01:58 +03:00
|
|
|
|
2024-08-10 04:09:59 +03:00
|
|
|
interface PrimaryMediaInfoProps extends PrimaryInfoOpts {
|
2024-01-31 03:01:58 +03:00
|
|
|
className?: string;
|
|
|
|
item: ItemDto;
|
2024-08-10 04:09:59 +03:00
|
|
|
showStarRatingInfo?: boolean;
|
|
|
|
showCaptionIndicatorInfo?: boolean;
|
|
|
|
showCriticRatingInfo?: boolean;
|
|
|
|
showEndsAtInfo?: boolean;
|
|
|
|
showMissingIndicatorInfo?: boolean;
|
|
|
|
getMissingIndicator?: () => React.JSX.Element | null
|
2024-01-31 03:01:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({
|
|
|
|
className,
|
|
|
|
item,
|
2024-08-10 04:09:59 +03:00
|
|
|
showYearInfo,
|
|
|
|
showAudioContainerInfo,
|
|
|
|
showEpisodeTitleInfo,
|
|
|
|
showOriginalAirDateInfo,
|
|
|
|
showRuntimeInfo,
|
|
|
|
showProgramIndicatorInfo,
|
|
|
|
includeEpisodeTitleIndexNumber,
|
|
|
|
showOfficialRatingInfo,
|
|
|
|
showStarRatingInfo = false,
|
|
|
|
showCaptionIndicatorInfo = false,
|
|
|
|
showCriticRatingInfo = false,
|
|
|
|
showEndsAtInfo = false,
|
2024-01-31 03:01:58 +03:00
|
|
|
getMissingIndicator
|
|
|
|
}) => {
|
|
|
|
const miscInfo = usePrimaryMediaInfo({
|
|
|
|
item,
|
2024-08-10 04:09:59 +03:00
|
|
|
showYearInfo,
|
|
|
|
showAudioContainerInfo,
|
|
|
|
showEpisodeTitleInfo,
|
|
|
|
showOriginalAirDateInfo,
|
|
|
|
showRuntimeInfo,
|
|
|
|
showProgramIndicatorInfo,
|
|
|
|
includeEpisodeTitleIndexNumber,
|
|
|
|
showOfficialRatingInfo
|
2024-01-31 03:01:58 +03:00
|
|
|
});
|
|
|
|
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))}
|
|
|
|
|
2024-08-10 04:09:59 +03:00
|
|
|
{showStarRatingInfo && CommunityRating && (
|
2024-01-31 03:01:58 +03:00
|
|
|
<StarIcons communityRating={CommunityRating} />
|
|
|
|
)}
|
|
|
|
|
2024-08-10 04:09:59 +03:00
|
|
|
{showCaptionIndicatorInfo && HasSubtitles && <CaptionMediaInfo />}
|
2024-01-31 03:01:58 +03:00
|
|
|
|
2024-08-10 04:09:59 +03:00
|
|
|
{showCriticRatingInfo && CriticRating && (
|
2024-01-31 03:01:58 +03:00
|
|
|
<CriticRatingMediaInfo criticRating={CriticRating} />
|
|
|
|
)}
|
|
|
|
|
2024-08-10 04:09:59 +03:00
|
|
|
{showEndsAtInfo
|
2024-08-21 03:27:03 +03:00
|
|
|
&& MediaType === ItemMediaKind.Video
|
2024-01-31 03:01:58 +03:00
|
|
|
&& RunTimeTicks
|
|
|
|
&& !StartDate && <EndsAt runTimeTicks={RunTimeTicks} />}
|
|
|
|
|
2024-08-10 04:09:59 +03:00
|
|
|
{getMissingIndicator?.()}
|
2024-01-31 03:01:58 +03:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PrimaryMediaInfo;
|