Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce start and enddate within SummaryView for events listings #63

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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;
Loading