Fix date rendering for missing date values (#580)

* Fix date rendering when missing date value
* Move scene studio overlay within scene card
This commit is contained in:
WithoutPants
2020-05-27 09:34:46 +10:00
committed by GitHub
parent 4ec6d62e01
commit 1110e9c311
5 changed files with 20 additions and 8 deletions

View File

@@ -242,9 +242,7 @@ export const Movie: React.FC = () => {
})}
{TableUtils.renderInputGroup({
title: `Date ${isEditing ? "(YYYY-MM-DD)" : ""}`,
value: isEditing
? date
: intl.formatDate(date, { format: "long" }),
value: isEditing ? date : TextUtils.formatDate(intl, date),
isEditing,
onChange: setDate,
})}

View File

@@ -490,7 +490,7 @@ export const PerformerDetailsPanel: React.FC<IPerformerDetails> = ({
title: "Birthdate",
value: isEditing
? birthdate
: intl.formatDate(birthdate, { format: "long" }),
: TextUtils.formatDate(intl, birthdate),
isEditing: !!isEditing,
onChange: setBirthdate,
})}

View File

@@ -252,9 +252,10 @@ export const SceneCard: React.FC<ISceneCardProps> = (
event.stopPropagation();
}}
/>
{maybeRenderSceneStudioOverlay()}
<Link to={`/scenes/${props.scene.id}`} className="scene-card-link">
{maybeRenderRatingBanner()}
{maybeRenderSceneStudioOverlay()}
{maybeRenderSceneSpecsOverlay()}
<video
loop

View File

@@ -39,9 +39,11 @@ export const SceneDetailPanel: React.FC<ISceneDetailProps> = (props) => {
{props.scene.title ?? TextUtils.fileNameFromPath(props.scene.path)}
</h3>
<div className="col-6 scene-details">
{props.scene.date ? (
<h4>
<FormattedDate value={props.scene.date ?? ""} format="long" />
<FormattedDate value={props.scene.date} format="long" />
</h4>
) : undefined}
{props.scene.rating ? <h6>Rating: {props.scene.rating}</h6> : ""}
{props.scene.file.height && (
<h6>Resolution: {TextUtils.resolution(props.scene.file.height)}</h6>

View File

@@ -1,3 +1,5 @@
import { IntlShape } from "react-intl";
// Typescript currently does not implement the intl Unit interface
type Unit =
| "byte"
@@ -128,6 +130,14 @@ const sanitiseURL = (url?: string, siteURL?: URL) => {
return `https://${url}`;
};
const formatDate = (intl: IntlShape, date?: string) => {
if (!date) {
return "";
}
return intl.formatDate(date, { format: "long" });
};
const TextUtils = {
truncate,
fileSize,
@@ -139,6 +149,7 @@ const TextUtils = {
sanitiseURL,
twitterURL,
instagramURL,
formatDate,
};
export default TextUtils;