import { h } from 'preact'; import PropTypes from 'prop-types'; import { Dropdown, Button } from '@crayons'; const Icon = () => ( Post options ); /** * Component comprising a trigger button and dropdown with additional post options. * * @param {Object} props * @param {Object} props.passedData The current post options data * @param {Function} props.onSaveDraft Callback for when the post draft is saved * @param {Function} props.onConfigChange Callback for when the config options have changed */ export const Options = ({ passedData: { published = false, allSeries = [], canonicalUrl = '', series = '', }, onSaveDraft, onConfigChange, }) => { let publishedField = ''; let existingSeries = ''; if (allSeries.length > 0) { const seriesNames = allSeries.map((name, index) => { return ( ); }); existingSeries = (
Existing series: {` `}
); } if (published) { publishedField = (
Danger Zone
); } return (
); }; Options.propTypes = { passedData: PropTypes.shape({ published: PropTypes.bool.isRequired, allSeries: PropTypes.array.isRequired, canonicalUrl: PropTypes.string.isRequired, series: PropTypes.string.isRequired, }).isRequired, onSaveDraft: PropTypes.func.isRequired, onConfigChange: PropTypes.func.isRequired, }; Options.displayName = 'Options';