From f9d603bed6b3ab0dc0acb3e5c2fa6269dfd276e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rane=20Hyvo=CC=88nen?=
Date: Fri, 22 Mar 2024 12:54:19 +0100
Subject: [PATCH] feat: add time to listing and imagecard blocks
---
.../profiles/default/catalog.xml | 13 +++---------
.../blocks/Listing/HomepageSliderTemplate.jsx | 3 ++-
.../blocks/Listing/ListingTemplate.jsx | 5 +++--
.../src/helpers/getDateRangeDescription.js | 21 +++++++++----------
4 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/backend/src/haagshistorischmuseum/src/haagshistorischmuseum/profiles/default/catalog.xml b/backend/src/haagshistorischmuseum/src/haagshistorischmuseum/profiles/default/catalog.xml
index 9558132..b6799a3 100644
--- a/backend/src/haagshistorischmuseum/src/haagshistorischmuseum/profiles/default/catalog.xml
+++ b/backend/src/haagshistorischmuseum/src/haagshistorischmuseum/profiles/default/catalog.xml
@@ -1,13 +1,6 @@
diff --git a/frontend/src/components/blocks/Listing/HomepageSliderTemplate.jsx b/frontend/src/components/blocks/Listing/HomepageSliderTemplate.jsx
index 2668905..3445693 100644
--- a/frontend/src/components/blocks/Listing/HomepageSliderTemplate.jsx
+++ b/frontend/src/components/blocks/Listing/HomepageSliderTemplate.jsx
@@ -29,6 +29,7 @@ const messages = defineMessages({
const Card = ({ item, index, hideText }) => {
const { title, start, end, whole_day } = item || {};
+ const wholeDay = typeof whole_day === 'boolean' ? whole_day : false;
const isEvent = item?.['@type'] === 'Event';
const endDate = new Date(end || Date.now());
const startDate = new Date(start || Date.now());
@@ -87,7 +88,7 @@ const Card = ({ item, index, hideText }) => {
intl.locale,
startDate,
endDate,
- whole_day,
+ wholeDay,
)}
)}
diff --git a/frontend/src/components/blocks/Listing/ListingTemplate.jsx b/frontend/src/components/blocks/Listing/ListingTemplate.jsx
index 1c44dc3..184279d 100644
--- a/frontend/src/components/blocks/Listing/ListingTemplate.jsx
+++ b/frontend/src/components/blocks/Listing/ListingTemplate.jsx
@@ -8,6 +8,7 @@ import { Grid } from 'semantic-ui-react';
const Card = ({ item, showDescription = true, hideDates = false }) => {
const intl = useIntl();
+ const wholeDay = typeof item.whole_day === 'boolean' ? item.whole_day : false;
const start = item.start ? new Date(item.start) : undefined;
const end = item.end ? new Date(item.end) : undefined;
const image = item?.image_field
@@ -34,14 +35,14 @@ const Card = ({ item, showDescription = true, hideDates = false }) => {
{item['@type'] === 'Event' && start && end && (
- {getDateRangeDescription(intl.locale, start, end)}
+ {getDateRangeDescription(intl.locale, start, end, wholeDay)}
)}
{item['@type'] === 'News Item' && (
- {getDateRangeDescription(intl.locale, start, end)}
+ {getDateRangeDescription(intl.locale, start, end, wholeDay)}
)}
diff --git a/frontend/src/helpers/getDateRangeDescription.js b/frontend/src/helpers/getDateRangeDescription.js
index c3c3942..9b466b1 100644
--- a/frontend/src/helpers/getDateRangeDescription.js
+++ b/frontend/src/helpers/getDateRangeDescription.js
@@ -1,17 +1,16 @@
export function getDateRangeDescription(lang, start, end, wholeDay = true) {
- // const startTime = new Intl.DateTimeFormat(lang, {
- // hour: 'numeric',
- // minute: 'numeric',
- // }).format(start);
+ const startTime = new Intl.DateTimeFormat(lang, {
+ hour: 'numeric',
+ minute: 'numeric',
+ }).format(start);
- // const endTime = new Intl.DateTimeFormat(lang, {
- // hour: 'numeric',
- // minute: 'numeric',
- // }).format(end);
+ const endTime = new Intl.DateTimeFormat(lang, {
+ hour: 'numeric',
+ minute: 'numeric',
+ }).format(end);
- // const time =
- // wholeDay || startTime === endTime ? '' : `, ${startTime} - ${endTime}`;
- const time = '';
+ const time =
+ wholeDay || startTime === endTime ? '' : `, ${startTime} - ${endTime}`;
if (
!end ||