Thanks to @fredvd, @sneridagh and @csanahuja for helping to clarify some of the concepts and generally nudging me in the right direction
Here's how I'm using @csanahuja's suggested approach.
(This is an oversimplification, but a good summary of how the code works)
My ContactComponent
now conditionally present download linke depending on if my new boolean indexed values ( hasChairVcard
and hasViceChairVcard
) are true or not.
import PropTypes from 'prop-types';
import React from 'react';
import ContactComponent from '../../Committees/ContactComponent';
import { flattenToAppURL } from '@plone/volto/helpers';
const CommitteeListTemplate = ({ items }) => {
{items.map((item, index) => {
console.log(item);
return (
<>
...
<ContactComponent
chair_contact_info={
item.hasChairVcard
? `${item.getURL}/@@download/committee_chair_vcard`
: null
}
vice_chair_contact_info={
item.hasViceChairVcard
? `${item.getURL}/@@download/committee_vice_chair_vcard`
: null
}
/> ;
})}
</>
);
};
CommitteeListTemplate.propTypes = {
items: PropTypes.arrayOf(PropTypes.any).isRequired,
linkMore: PropTypes.any,
isEditMode: PropTypes.bool,
};
export default CommitteeListTemplate;