Hide ratings on movie table in absence of data

pull/10346/head
Bogdan 5 months ago
parent 7532dfb03c
commit d79db69644

@ -360,23 +360,25 @@ function MovieIndexRow(props: MovieIndexRowProps) {
if (name === 'tmdbRating') { if (name === 'tmdbRating') {
return ( return (
<VirtualTableRowCell key={name} className={styles[name]}> <VirtualTableRowCell key={name} className={styles[name]}>
<TmdbRating ratings={ratings} /> {ratings.tmdb ? <TmdbRating ratings={ratings} /> : null}
</VirtualTableRowCell> </VirtualTableRowCell>
); );
} }
if (name === 'rottenTomatoesRating') { if (name === 'imdbRating') {
return ( return (
<VirtualTableRowCell key={name} className={styles[name]}> <VirtualTableRowCell key={name} className={styles[name]}>
<RottenTomatoRating ratings={ratings} /> {ratings.imdb ? <ImdbRating ratings={ratings} /> : null}
</VirtualTableRowCell> </VirtualTableRowCell>
); );
} }
if (name === 'imdbRating') { if (name === 'rottenTomatoesRating') {
return ( return (
<VirtualTableRowCell key={name} className={styles[name]}> <VirtualTableRowCell key={name} className={styles[name]}>
<ImdbRating ratings={ratings} /> {ratings.rottenTomatoes ? (
<RottenTomatoRating ratings={ratings} />
) : null}
</VirtualTableRowCell> </VirtualTableRowCell>
); );
} }

@ -191,14 +191,14 @@ export const defaultState = {
isVisible: false isVisible: false
}, },
{ {
name: 'rottenTomatoesRating', name: 'imdbRating',
label: () => translate('RottenTomatoesRating'), label: () => translate('ImdbRating'),
isSortable: true, isSortable: true,
isVisible: false isVisible: false
}, },
{ {
name: 'imdbRating', name: 'rottenTomatoesRating',
label: () => translate('ImdbRating'), label: () => translate('RottenTomatoesRating'),
isSortable: true, isSortable: true,
isVisible: false isVisible: false
}, },
@ -266,21 +266,15 @@ export const defaultState = {
undefined; undefined;
}, },
imdbRating: function(item) { tmdbRating: function({ ratings = {} }) {
const { ratings = {} } = item;
return ratings.imdb ? ratings.imdb.value : 0;
},
tmdbRating: function(item) {
const { ratings = {} } = item;
return ratings.tmdb ? ratings.tmdb.value : 0; return ratings.tmdb ? ratings.tmdb.value : 0;
}, },
rottenTomatoesRating: function(item) { imdbRating: function({ ratings = {} }) {
const { ratings = {} } = item; return ratings.imdb ? ratings.imdb.value : 0;
},
rottenTomatoesRating: function({ ratings = {} }) {
return ratings.rottenTomatoes ? ratings.rottenTomatoes.value : -1; return ratings.rottenTomatoes ? ratings.rottenTomatoes.value : -1;
} }
}, },

Loading…
Cancel
Save