import React from 'react'; import PropTypes from 'prop-types'; import { useDispatch } from 'react-redux'; import { getConfig, history } from '@edx/frontend-platform'; import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import { ActionRow, Alert, Button } from '@edx/paragon'; import { useModel } from '../../../../generic/model-store'; import { saveIntegritySignature } from '../../../data'; import messages from './messages'; function HonorCode({ intl, courseId }) { const dispatch = useDispatch(); const coursewareMetaData = useModel('coursewareMeta', courseId); const authUser = getAuthenticatedUser(); const siteName = getConfig().SITE_NAME; const honorCodeUrl = `${getConfig().TERMS_OF_SERVICE_URL}#honor-code`; const handleCancel = () => history.push(`/course/${courseId}/home`); const handleAgree = () => dispatch( // If the request is made by a staff user masquerading as a specific learner, // don't actually create a signature for them on the backend. // Only the modal dialog will be dismissed. // Otherwise, even for staff users, we want to record the signature. saveIntegritySignature( courseId, coursewareMetaData.isMasquerading && coursewareMetaData.username !== authUser.username, ), ); return (

{siteName}{' '} {intl.formatMessage(messages['learn.honorCode.name'])}

{intl.formatMessage(messages['learn.honorCode.name'])}, }} />

); } HonorCode.propTypes = { intl: intlShape.isRequired, courseId: PropTypes.string.isRequired, }; export default injectIntl(HonorCode);