import React, { FunctionComponent, useMemo } from "react"; import { BackgroundImage, Badge, BadgeProps, Box, Grid, Group, HoverCard, Image, List, Stack, Text, Title, Tooltip, } from "@mantine/core"; import { faBookmark as farBookmark, faFolder, } from "@fortawesome/free-regular-svg-icons"; import { faBookmark, faClone, faLanguage, faMusic, faStream, faTags, IconDefinition, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Language } from "@/components/bazarr"; import { BuildKey } from "@/utilities"; import { normalizeAudioLanguage, useLanguageProfileBy, useProfileItemsToLanguages, } from "@/utilities/languages"; interface Props { item: Item.Base | null; details?: { icon: IconDefinition; text: string }[]; } const ItemOverview: FunctionComponent = (props) => { const { item, details } = props; const detailBadges = useMemo(() => { const badges: (React.JSX.Element | null)[] = []; if (item) { badges.push( {item.path} , ); badges.push( ...(details?.map((val, idx) => ( {val.text} )) ?? []), ); if (item.tags.length > 0) { badges.push( {item.tags.join("|")} , ); } } return badges; }, [details, item]); const audioBadges = useMemo( () => item?.audio_language.map((v, idx) => ( {normalizeAudioLanguage(v.name)} )) ?? [], [item?.audio_language], ); const profile = useLanguageProfileBy(item?.profileId); const profileItems = useProfileItemsToLanguages(profile); const languageBadges = useMemo(() => { const badges: (React.JSX.Element | null)[] = []; if (profile) { badges.push( {profile.name} , ); badges.push( ...profileItems.map((v, idx) => ( )), ); } return badges; }, [profile, profileItems]); return ( <Text inherit c="white"> <Box component="span" mr={12}> <FontAwesomeIcon title={item?.monitored ? "monitored" : "unmonitored"} icon={item?.monitored ? faBookmark : farBookmark} ></FontAwesomeIcon> </Box> {item?.title} </Text> {item?.alternativeTitles.map((v, idx) => ( {v} ))} {detailBadges} {audioBadges} {languageBadges} {item?.overview} ); }; type ItemBadgeProps = Omit & { icon: IconDefinition; title?: string; }; const ItemBadge: FunctionComponent = ({ icon, title, ...props }) => ( } variant="light" radius="sm" size="sm" style={{ textTransform: "none" }} aria-label={title} {...props} > ); export default ItemOverview;