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({ {TableUtils.renderInputGroup({
title: `Date ${isEditing ? "(YYYY-MM-DD)" : ""}`, title: `Date ${isEditing ? "(YYYY-MM-DD)" : ""}`,
value: isEditing value: isEditing ? date : TextUtils.formatDate(intl, date),
? date
: intl.formatDate(date, { format: "long" }),
isEditing, isEditing,
onChange: setDate, onChange: setDate,
})} })}

View File

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

View File

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

View File

@@ -39,9 +39,11 @@ export const SceneDetailPanel: React.FC<ISceneDetailProps> = (props) => {
{props.scene.title ?? TextUtils.fileNameFromPath(props.scene.path)} {props.scene.title ?? TextUtils.fileNameFromPath(props.scene.path)}
</h3> </h3>
<div className="col-6 scene-details"> <div className="col-6 scene-details">
<h4> {props.scene.date ? (
<FormattedDate value={props.scene.date ?? ""} format="long" /> <h4>
</h4> <FormattedDate value={props.scene.date} format="long" />
</h4>
) : undefined}
{props.scene.rating ? <h6>Rating: {props.scene.rating}</h6> : ""} {props.scene.rating ? <h6>Rating: {props.scene.rating}</h6> : ""}
{props.scene.file.height && ( {props.scene.file.height && (
<h6>Resolution: {TextUtils.resolution(props.scene.file.height)}</h6> <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 // Typescript currently does not implement the intl Unit interface
type Unit = type Unit =
| "byte" | "byte"
@@ -128,6 +130,14 @@ const sanitiseURL = (url?: string, siteURL?: URL) => {
return `https://${url}`; return `https://${url}`;
}; };
const formatDate = (intl: IntlShape, date?: string) => {
if (!date) {
return "";
}
return intl.formatDate(date, { format: "long" });
};
const TextUtils = { const TextUtils = {
truncate, truncate,
fileSize, fileSize,
@@ -139,6 +149,7 @@ const TextUtils = {
sanitiseURL, sanitiseURL,
twitterURL, twitterURL,
instagramURL, instagramURL,
formatDate,
}; };
export default TextUtils; export default TextUtils;