Skip to content

Commit

Permalink
feat: add time to listing and imagecard blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
RaneHyv committed Mar 22, 2024
1 parent 9d1918e commit f9d603b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<object name="portal_catalog">
<!-- Index
<index meta_type="FieldIndex"
name="industry"
>
<indexed_attr value="industry" />
</index>
-->
<!-- Metadata
<column value="industry" />
-->
<column value="whole_day" />
<column value="open_end" />
<column value="recurrence" />
</object>
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -87,7 +88,7 @@ const Card = ({ item, index, hideText }) => {
intl.locale,
startDate,
endDate,
whole_day,
wholeDay,
)}
</p>
)}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/blocks/Listing/ListingTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,14 +35,14 @@ const Card = ({ item, showDescription = true, hideDates = false }) => {
{item['@type'] === 'Event' && start && end && (
<div className="listing-dates">
<div className={`listing-dates-wrapper`}>
{getDateRangeDescription(intl.locale, start, end)}
{getDateRangeDescription(intl.locale, start, end, wholeDay)}
</div>
</div>
)}
{item['@type'] === 'News Item' && (
<div className="listing-dates">
<div className={`listing-dates-wrapper`}>
{getDateRangeDescription(intl.locale, start, end)}
{getDateRangeDescription(intl.locale, start, end, wholeDay)}
</div>
</div>
)}
Expand Down
21 changes: 10 additions & 11 deletions frontend/src/helpers/getDateRangeDescription.js
Original file line number Diff line number Diff line change
@@ -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 ||
Expand Down

0 comments on commit f9d603b

Please sign in to comment.