import React, { useEffect, useRef, useState } from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { ActionRow, Button, Form, ModalDialog, } from '@edx/paragon'; import { selectModerationSettings } from '../../data/selectors'; import messages from './messages'; function ClosePostReasonModal({ intl, isOpen, onCancel, onConfirm, }) { const scrollTo = useRef(null); const [reasonCode, setReasonCode] = useState(null); const { postCloseReasons } = useSelector(selectModerationSettings); const onChange = event => { if (event.target.value) { setReasonCode(event.target.value); } else { setReasonCode(null); } }; useEffect(() => { /* istanbul ignore if: This API is not available in the test environment. */ if (scrollTo.current && scrollTo.current.scrollIntoView) { // Use a timeout since the component is first given focus, which scrolls // it into view but doesn't centrally align it. This should run after that. setTimeout(() => { scrollTo.current.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 0); } }, [scrollTo, isOpen]); return ( {intl.formatMessage(messages.closePostModalTitle)}

{intl.formatMessage(messages.closePostModalText)}

{postCloseReasons.map(({ code, label }) => ( ))}
{intl.formatMessage(messages.closePostModalButtonCancel)}
); } ClosePostReasonModal.propTypes = { intl: intlShape.isRequired, isOpen: PropTypes.bool.isRequired, onCancel: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired, }; export default injectIntl(ClosePostReasonModal);