From 17a6a8868ba5ffada778808e5e475cbf8cd90113 Mon Sep 17 00:00:00 2001 From: max-voronov <70445727+max-voronov@users.noreply.github.com> Date: Thu, 1 Oct 2020 17:11:45 +0300 Subject: [PATCH] Refactor Honesty (#39726) * remove unused prop from Honesty component * convert Honesty into a functional component --- client/src/components/settings/Honesty.js | 54 ++++++++++------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/client/src/components/settings/Honesty.js b/client/src/components/settings/Honesty.js index fdb126bafb..338c62b51b 100644 --- a/client/src/components/settings/Honesty.js +++ b/client/src/components/settings/Honesty.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React from 'react'; import PropTypes from 'prop-types'; import { Button, Panel } from '@freecodecamp/react-bootstrap'; @@ -10,20 +10,11 @@ import './honesty.css'; const propTypes = { isHonest: PropTypes.bool, - policy: PropTypes.arrayOf(PropTypes.string), updateIsHonest: PropTypes.func.isRequired }; -class Honesty extends Component { - handleAgreeClick = () => this.props.updateIsHonest({ isHonest: true }); - - renderAgreeButton = () => ( - - ); - - renderIsHonestAgreed = () => ( +const Honesty = ({ isHonest, updateIsHonest }) => { + const button = isHonest ? ( + ) : ( + ); - - render() { - const { isHonest } = this.props; - - return ( -
- Academic Honesty Policy - - - - -
- {isHonest ? this.renderIsHonestAgreed() : this.renderAgreeButton()} -
-
- ); - } -} + return ( +
+ Academic Honesty Policy + + + + +
+ {button} +
+
+ ); +}; Honesty.displayName = 'Honesty'; Honesty.propTypes = propTypes;