import { h } from 'preact';
import PropTypes from 'prop-types';
const orgOptions = (organizations, organizationId, emptyLabel) => {
const orgs = organizations.map((organization) => {
if (organizationId === organization.id) {
return (
);
}
return (
);
});
const nullOrgOption =
organizationId === null ? (
) : (
);
return [nullOrgOption, ...orgs];
};
export const OrganizationPicker = ({
name,
id,
className,
organizations,
organizationId,
onToggle,
emptyLabel,
}) => (
);
OrganizationPicker.defaultProps = {
emptyLabel: 'None',
};
OrganizationPicker.propTypes = {
name: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
className: PropTypes.string.isRequired,
emptyLabel: PropTypes.string,
onToggle: PropTypes.func.isRequired,
organizationId: PropTypes.number.isRequired,
organizations: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.isRequired,
name: PropTypes.string.isRequired,
}),
).isRequired,
};