From a1ebe6dcd66ec3b6ed7e8f8b16d8f6fcab0354ee Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Fri, 10 Feb 2023 19:13:27 +0200 Subject: [PATCH] refactor(client): turn image validation component into subComponent (#49155) * refactor(client): clean extra FormGroup component in personal info * Revert "refactor(client): clean extra FormGroup component in personal info" This reverts commit cc29df30339e623a5c673f42aab467116702d1a4. * refactor show image component into JSX * Remove redundant text Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com> --------- Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com> --- client/src/components/settings/about.tsx | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/client/src/components/settings/about.tsx b/client/src/components/settings/about.tsx index 4b3f1aa8d16..ab8f1b96dfa 100644 --- a/client/src/components/settings/about.tsx +++ b/client/src/components/settings/about.tsx @@ -48,6 +48,18 @@ type AboutState = { isPictureUrlValid: boolean; }; +const ShowImageValidationWarning = ({ + alertContent +}: { + alertContent: string; +}) => { + return ( + + {alertContent} + + ); +}; + class AboutSettings extends Component { validationImage: HTMLImageElement; static displayName: string; @@ -79,7 +91,6 @@ class AboutSettings extends Component { picture === formValues.picture && about === formValues.about ) { - // eslint-disable-next-line react/no-did-update-set-state return this.setState({ originalValues: { name, @@ -170,21 +181,6 @@ class AboutSettings extends Component { })); }; - showImageValidationWarning = () => { - const { t } = this.props; - if (this.state.isPictureUrlValid === false) { - return ( - - - {t('validation.url-not-image')} - - - ); - } else { - return true; - } - }; - handleAboutChange = (e: React.FormEvent) => { const value = (e.target as HTMLInputElement).value.slice(0); return this.setState(state => ({ @@ -210,9 +206,9 @@ class AboutSettings extends Component { toggleKeyboardShortcuts } = this.props; return ( -
+ <> -
+ {t('settings.headings.personal-info')}
@@ -246,7 +242,11 @@ class AboutSettings extends Component { type='url' value={picture} /> - {this.showImageValidationWarning()} + {!this.state.isPictureUrlValid && ( + + )} @@ -279,7 +279,7 @@ class AboutSettings extends Component { toggleKeyboardShortcuts={toggleKeyboardShortcuts} /> -
+ ); } }