diff --git a/client/.eslintrc.js b/client/.eslintrc.js index 125a726..b71fdfb 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -7,7 +7,7 @@ module.exports = { 'prettier', 'prettier/react', ], - plugins: ['jsx-a11y', 'prettier'], + plugins: ['jsx-a11y', 'prettier', 'react-hooks'], rules: { semi: 0, 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], @@ -26,6 +26,8 @@ module.exports = { 'jsx-a11y/click-events-have-key-events': 'off', 'react/no-unescaped-entities': 'off', 'react/no-array-index-key': 'off', - 'jsx-a11y/no-static-element-interactions': 'off' + 'jsx-a11y/no-static-element-interactions': 'off', + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', }, }; diff --git a/client/public/locales/de/physicianView.json b/client/public/locales/de/physicianView.json index 997ac21..610c195 100644 --- a/client/public/locales/de/physicianView.json +++ b/client/public/locales/de/physicianView.json @@ -1,11 +1,11 @@ { - "welcome": "Welcome, ", - "unverifiedUserMessage": "You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit a Physician Registration form if you have not already done so. Thank you.", + "welcome": "[DE] Welcome, {{userFullName}}", + "unverifiedUserMessage": "[DE] You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit <0>a Physician Registration form if you have not already done so. Thank you.", "buttons": { - "answeredQuestions": "Answered Questions", - "unansweredQuestions": "Unanswered Questions", - "televideo": "Televideo", - "logOut": "Log out" + "answeredQuestions": "[DE] Answered Questions", + "unansweredQuestions": "[DE] Unanswered Questions", + "televideo": "[DE] Televideo", + "logOut": "[DE] Log out" }, - "errorMessage": "Sorry, something went wrong!" + "errorMessage": "[DE] Sorry, something went wrong!" } diff --git a/client/public/locales/en/physicianView.json b/client/public/locales/en/physicianView.json index 997ac21..6dec099 100644 --- a/client/public/locales/en/physicianView.json +++ b/client/public/locales/en/physicianView.json @@ -1,6 +1,6 @@ { - "welcome": "Welcome, ", - "unverifiedUserMessage": "You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit a Physician Registration form if you have not already done so. Thank you.", + "welcome": "Welcome, {{userFullName}}", + "unverifiedUserMessage": "You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit <0>a Physician Registration form if you have not already done so. Thank you.", "buttons": { "answeredQuestions": "Answered Questions", "unansweredQuestions": "Unanswered Questions", diff --git a/client/public/locales/hi-IN/physicianView.json b/client/public/locales/hi-IN/physicianView.json index 997ac21..bc8da24 100644 --- a/client/public/locales/hi-IN/physicianView.json +++ b/client/public/locales/hi-IN/physicianView.json @@ -1,11 +1,11 @@ { - "welcome": "Welcome, ", - "unverifiedUserMessage": "You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit a Physician Registration form if you have not already done so. Thank you.", + "welcome": "[hi-IN] Welcome, {{userFullName}}", + "unverifiedUserMessage": "[hi-IN] You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit <0>a Physician Registration form if you have not already done so. Thank you.", "buttons": { - "answeredQuestions": "Answered Questions", - "unansweredQuestions": "Unanswered Questions", - "televideo": "Televideo", - "logOut": "Log out" + "answeredQuestions": "[hi-IN] Answered Questions", + "unansweredQuestions": "[hi-IN] Unanswered Questions", + "televideo": "[hi-IN] Televideo", + "logOut": "[hi-IN] Log out" }, - "errorMessage": "Sorry, something went wrong!" + "errorMessage": "[hi-IN] Sorry, something went wrong!" } diff --git a/client/public/locales/ko-KR/physicianView.json b/client/public/locales/ko-KR/physicianView.json index 997ac21..fb63c48 100644 --- a/client/public/locales/ko-KR/physicianView.json +++ b/client/public/locales/ko-KR/physicianView.json @@ -1,11 +1,11 @@ { - "welcome": "Welcome, ", - "unverifiedUserMessage": "You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit a Physician Registration form if you have not already done so. Thank you.", + "welcome": "[ko-KR] Welcome, {{userFullName}}", + "unverifiedUserMessage": "[ko-KR] You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit <0>a Physician Registration form if you have not already done so. Thank you.", "buttons": { - "answeredQuestions": "Answered Questions", - "unansweredQuestions": "Unanswered Questions", - "televideo": "Televideo", - "logOut": "Log out" + "answeredQuestions": "[ko-KR] Answered Questions", + "unansweredQuestions": "[ko-KR] Unanswered Questions", + "televideo": "[ko-KR] Televideo", + "logOut": "[ko-KR] Log out" }, - "errorMessage": "Sorry, something went wrong!" + "errorMessage": "[ko-KR] Sorry, something went wrong!" } diff --git a/client/public/locales/zh-cn/physicianView.json b/client/public/locales/zh-cn/physicianView.json index 997ac21..0af237a 100644 --- a/client/public/locales/zh-cn/physicianView.json +++ b/client/public/locales/zh-cn/physicianView.json @@ -1,11 +1,11 @@ { - "welcome": "Welcome, ", - "unverifiedUserMessage": "You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit a Physician Registration form if you have not already done so. Thank you.", + "welcome": "[zh-cn] Welcome, ", + "unverifiedUserMessage": "[zh-cn] You have been granted READ-ONLY access to rate, review, and flag answers until your account has been verified. Please submit a Physician Registration form if you have not already done so. Thank you.", "buttons": { - "answeredQuestions": "Answered Questions", - "unansweredQuestions": "Unanswered Questions", - "televideo": "Televideo", - "logOut": "Log out" + "answeredQuestions": "[zh-cn] Answered Questions", + "unansweredQuestions": "[zh-cn] Unanswered Questions", + "televideo": "[zh-cn] Televideo", + "logOut": "[zh-cn] Log out" }, - "errorMessage": "Sorry, something went wrong!" + "errorMessage": "[zh-cn] Sorry, something went wrong!" } diff --git a/client/src/components/AnswerItem.js b/client/src/components/AnswerItem.js index 1dc4a70..a69f9bb 100644 --- a/client/src/components/AnswerItem.js +++ b/client/src/components/AnswerItem.js @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { Trans, withTranslation } from 'react-i18next'; import { ReactTinyLink } from 'react-tiny-link'; -import { List, Image, Label, Button, Icon } from 'semantic-ui-react'; +import { List, Image, Label } from 'semantic-ui-react'; import clockIcon from '../assets/images/clockIcon.png'; @@ -44,10 +44,7 @@ const AnswerItem = (props) => { clock_icon Posted: {firstAnsweredOn} - - Last Edited:{' '} - {lastAnsweredOn} - + Last Edited: {lastAnsweredOn} { + const [isMessageVisible, setIsMessageVisible] = useState(true); + const [isUnansweredShown, setIsUnansweredShown] = useState(true); - componentDidMount() { - this.props.fetchUnansweredQuestions(); - this.props.fetchQuestions(); - } + /* eslint-disable-next-line no-shadow */ + const { fetchUnansweredQuestions, fetchQuestions } = props; - handleToggleView(showUnanswered) { - this.setState({ showUnanswered }); - } + useEffect(() => { + fetchUnansweredQuestions(); + fetchQuestions(); + }, [fetchUnansweredQuestions, fetchQuestions]); - handleDismissMessage = () => { - this.setState({ isMessageVisible: false }); + const handleToggleView = (showUnanswered) => { + setIsUnansweredShown(showUnanswered); }; - render() { - return !this.props.authuser ? ( - - ) : ( - <> - + const handleDismissMessage = () => { + setIsMessageVisible(false); + }; - - - {this.props.authuser.profilestatus === 'level 0' ? ( - - ) : ( - this.state.isMessageVisible && ( - - {this.props.t('physicianView:welcome')}{' '} - {this.props.authuser.fullname} - - ) - )} - - + return !props.authuser ? ( + + ) : ( + <> + -
- - - - {this.props.account && ( - + + {props.authuser.profilestatus === 'level 0' ? ( + + + {props.t('physicianView:welcome', { + returnObjects: true, + userFullName: props.authuser.fullname, + })} + + + {/* eslint-disable-next-line jsx-a11y/anchor-has-content */} + - )} - - -
- {this.props.account && ( - - - - - )} -
-
- {this.props.error && ( - - - {this.props.t('physicianView:errorMessage')} - -

{this.props.error}

+ +
+ ) : ( + isMessageVisible && ( + + {props.t('physicianView:welcome')} {props.authuser.fullname} - )} -
-
-
- - - {this.state.showUnanswered && - this.props.account && - this.props.unansweredQuestions && - this.props.unansweredQuestions.map((q, idx) => ( - - ))} + ) + )} + + - {!this.state.showUnanswered && - this.props.account && - this.props.questions && - this.props.questions.map((q, idx) => ( - - ))} - - +
+ + -
+ + {props.account && ( + + )} + +
+
+ {props.account && ( + + + + + )}
- - ); - } -} +
+ {props.error && ( + + +

{props.error}

+
+ )} +
+
+
+ + + {isUnansweredShown && + props.account && + props.unansweredQuestions && + props.unansweredQuestions.map((q, idx) => ( + + ))} + + {!isUnansweredShown && + props.account && + props.questions && + props.questions.map((q, idx) => ( + + ))} + + +
+
+ + ); +}; const mapStateToProps = (state) => { return {