mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
New: Project Aphrodite
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { kinds } from 'Helpers/Props';
|
||||
import Label from 'Components/Label';
|
||||
import MoviePoster from 'Movie/MoviePoster';
|
||||
import styles from './MovieSearchResult.css';
|
||||
|
||||
function findMatchingAlternateTitle(alternateTitles, cleanQuery) {
|
||||
return alternateTitles.find((alternateTitle) => {
|
||||
return alternateTitle.cleanTitle.contains(cleanQuery);
|
||||
});
|
||||
}
|
||||
|
||||
function getMatchingTag(tags, cleanQuery) {
|
||||
return tags.find((tag) => {
|
||||
return tag.cleanLabel.contains(cleanQuery);
|
||||
});
|
||||
}
|
||||
|
||||
function MovieSearchResult(props) {
|
||||
const {
|
||||
cleanQuery,
|
||||
title,
|
||||
cleanTitle,
|
||||
images,
|
||||
alternateTitles,
|
||||
tags
|
||||
} = props;
|
||||
|
||||
const titleContains = cleanTitle.contains(cleanQuery);
|
||||
let alternateTitle = null;
|
||||
let tag = null;
|
||||
|
||||
if (!titleContains) {
|
||||
alternateTitle = findMatchingAlternateTitle(alternateTitles, cleanQuery);
|
||||
}
|
||||
|
||||
if (!titleContains && !alternateTitle) {
|
||||
tag = getMatchingTag(tags, cleanQuery);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.result}>
|
||||
<MoviePoster
|
||||
className={styles.poster}
|
||||
images={images}
|
||||
size={250}
|
||||
lazy={false}
|
||||
overflow={true}
|
||||
/>
|
||||
|
||||
<div className={styles.titles}>
|
||||
<div className={styles.title}>
|
||||
{title}
|
||||
</div>
|
||||
|
||||
{
|
||||
!!alternateTitle &&
|
||||
<div className={styles.alternateTitle}>
|
||||
{alternateTitle.title}
|
||||
</div>
|
||||
}
|
||||
|
||||
{
|
||||
!!tag &&
|
||||
<div className={styles.tagContainer}>
|
||||
<Label
|
||||
key={tag.id}
|
||||
kind={kinds.INFO}
|
||||
>
|
||||
{tag.label}
|
||||
</Label>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
MovieSearchResult.propTypes = {
|
||||
cleanQuery: PropTypes.string.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
cleanTitle: PropTypes.string.isRequired,
|
||||
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
alternateTitles: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
tags: PropTypes.arrayOf(PropTypes.object).isRequired
|
||||
};
|
||||
|
||||
export default MovieSearchResult;
|
||||
Reference in New Issue
Block a user