Files
freeCodeCamp/client/src/components/settings/Honesty.js
2021-05-07 02:39:38 +05:30

55 lines
1.3 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { Button, Panel } from '@freecodecamp/react-bootstrap';
import { useTranslation } from 'react-i18next';
import { FullWidthRow } from '../helpers';
import SectionHeader from './SectionHeader';
import HonestyPolicy from '../../resources/honesty-policy';
import './honesty.css';
const propTypes = {
isHonest: PropTypes.bool,
updateIsHonest: PropTypes.func.isRequired
};
const Honesty = ({ isHonest, updateIsHonest }) => {
const { t } = useTranslation();
const button = isHonest ? (
<Button
block={true}
bsStyle='primary'
className='disabled-agreed'
disabled={true}
>
<p>{t('buttons.accepted-honesty')}</p>
</Button>
) : (
<Button
block={true}
bsStyle='primary'
onClick={() => updateIsHonest({ isHonest: true })}
>
{t('buttons.agree')}
</Button>
);
return (
<section className='honesty-policy'>
<SectionHeader>{t('settings.headings.honesty')}</SectionHeader>
<FullWidthRow>
<Panel className='honesty-panel'>
<HonestyPolicy />
</Panel>
<br />
{button}
</FullWidthRow>
</section>
);
};
Honesty.displayName = 'Honesty';
Honesty.propTypes = propTypes;
export default Honesty;