mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-14 18:55:10 +01:00
Update MediaCard.tsx
This commit is contained in:
parent
4386772404
commit
9888798c28
@ -36,11 +36,11 @@ function MediaCardContent({
|
|||||||
const percentageString = `${Math.round(percentage ?? 0).toFixed(0)}%`;
|
const percentageString = `${Math.round(percentage ?? 0).toFixed(0)}%`;
|
||||||
|
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
const isReleased = media.year && media.year < currentYear;
|
const canLink =
|
||||||
const canLink = linkable && !closable && isReleased;
|
linkable && !closable && media.year && media.year < currentYear;
|
||||||
|
|
||||||
const dotListContent = [t(`media.types.${media.type}`)];
|
const dotListContent = [t(`media.types.${media.type}`)];
|
||||||
if (isReleased) {
|
if (media.year && media.year < currentYear) {
|
||||||
dotListContent.push(media.year.toFixed());
|
dotListContent.push(media.year.toFixed());
|
||||||
} else {
|
} else {
|
||||||
dotListContent.push(t("media.unreleased"));
|
dotListContent.push(t("media.unreleased"));
|
||||||
@ -149,8 +149,11 @@ export function MediaCard(props: MediaCardProps) {
|
|||||||
const content = <MediaCardContent {...props} />;
|
const content = <MediaCardContent {...props} />;
|
||||||
|
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
const isReleased = props.media.year && props.media.year < currentYear;
|
const canLink =
|
||||||
const canLink = props.linkable && !props.closable && isReleased;
|
props.linkable &&
|
||||||
|
!props.closable &&
|
||||||
|
props.media.year &&
|
||||||
|
props.media.year < currentYear;
|
||||||
|
|
||||||
let link = canLink
|
let link = canLink
|
||||||
? `/media/${encodeURIComponent(mediaItemToId(props.media))}`
|
? `/media/${encodeURIComponent(mediaItemToId(props.media))}`
|
||||||
|
Loading…
Reference in New Issue
Block a user