From 6b8ebd5a8dcd03aa3857ea055cfd81c63b524888 Mon Sep 17 00:00:00 2001 From: jinder1s Date: Thu, 16 Apr 2020 15:09:51 -0400 Subject: [PATCH] Code Refactor --- .../static/support/jsx/errors_list.jsx | 16 +- .../static/support/jsx/logged_in_user.jsx | 10 +- .../support/jsx/single_support_form.jsx | 195 ++++++++++-------- 3 files changed, 118 insertions(+), 103 deletions(-) diff --git a/lms/djangoapps/support/static/support/jsx/errors_list.jsx b/lms/djangoapps/support/static/support/jsx/errors_list.jsx index cc91ed45e6..86da7c13a0 100644 --- a/lms/djangoapps/support/static/support/jsx/errors_list.jsx +++ b/lms/djangoapps/support/static/support/jsx/errors_list.jsx @@ -6,25 +6,23 @@ import PropTypes from 'prop-types'; class ShowErrors extends React.Component { render() { - if (this.props.errorList.length > 0) { - window.scrollTo(0, 0); - } - return this.props.errorList.length > 0 && -
+ return ( + this.props.hasErrors &&
{gettext('Please fix the following errors:')}
    - {this.props.errorList.map((error, i) => -
  • {error}
  • , + { Object.keys(this.props.errorList).map(key => + this.props.errorList[key] &&
  • {this.props.errorList[key]}
  • , )}
-
; +
); } } ShowErrors.propTypes = { - errorList: PropTypes.arrayOf(PropTypes.object).isRequired, + errorList: PropTypes.objectOf(PropTypes.string).isRequired, + hasErrors: PropTypes.bool.isRequired, }; export default ShowErrors; diff --git a/lms/djangoapps/support/static/support/jsx/logged_in_user.jsx b/lms/djangoapps/support/static/support/jsx/logged_in_user.jsx index ab88d3c943..649a07c5cc 100644 --- a/lms/djangoapps/support/static/support/jsx/logged_in_user.jsx +++ b/lms/djangoapps/support/static/support/jsx/logged_in_user.jsx @@ -5,8 +5,7 @@ import PropTypes from 'prop-types'; import { Button, StatusAlert } from '@edx/paragon'; import StringUtils from 'edx-ui-toolkit/js/utils/string-utils'; - -function LoggedInUser({ userInformation, onChangeCallback, submitForm, showWarning, showDiscussionButton, reDirectUser }) { +function LoggedInUser({ userInformation, onChangeCallback, submitForm, showWarning, showDiscussionButton, reDirectUser, errorList }) { let courseElement; let detailElement; let discussionElement = ''; @@ -97,7 +96,7 @@ function LoggedInUser({ userInformation, onChangeCallback, submitForm, showWarni
-
+

{gettext('the more quickly and helpfully we can respond!')}