Skip to content

Commit

Permalink
Introduce start and enddate within SummaryView for Listings including…
Browse files Browse the repository at this point in the history
… events
  • Loading branch information
adrianschulz committed May 13, 2024
1 parent e2661a3 commit 204f28e
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import PropTypes from 'prop-types';
import { ConditionalLink, Component, FormattedDate } from '@plone/volto/components';
import { flattenToAppURL } from '@plone/volto/helpers';

import { isInternalURL } from '@plone/volto/helpers/Url/Url';

const SummaryTemplate = ({ items, linkTitle, linkHref, isEditMode }) => {
let link = null;
let href = linkHref?.[0]?.['@id'] || '';

if (isInternalURL(href)) {
link = (
<ConditionalLink to={flattenToAppURL(href)} condition={!isEditMode}>
{linkTitle || href}
</ConditionalLink>
);
} else if (href) {
link = <a href={href}>{linkTitle || href}</a>;
}

return (
<>
<div className="items">
{items.map((item) => (
<div className="listing-item" key={item['@id']}>
<ConditionalLink item={item} condition={!isEditMode}>
<Component componentName="PreviewImage" item={item} alt="" />
<div className="listing-body">
<h3>{item.title || item.id}</h3>
{
item.start && item.end && (
<p><FormattedDate date={item.start} /> - <FormattedDate date={item.end} /></p>
)
}
<p>{item.description}</p>
</div>
</ConditionalLink>
</div>
))}
</div>

{link && <div className="footer">{link}</div>}
</>
);
};

SummaryTemplate.propTypes = {
items: PropTypes.arrayOf(PropTypes.any).isRequired,
linkMore: PropTypes.any,
isEditMode: PropTypes.bool,
};

export default SummaryTemplate;

0 comments on commit 204f28e

Please sign in to comment.