|
@ -2,7 +2,7 @@ import React, { |
|
|
useCallback, useEffect, useMemo, useState, |
|
|
useCallback, useEffect, useMemo, useState, |
|
|
} from 'react'; |
|
|
} from 'react'; |
|
|
import { |
|
|
import { |
|
|
Button, Form, Icon, Image, Input, Message, Modal, |
|
|
Button, Form, Input, Message, Modal, |
|
|
} from 'semantic-ui-react'; |
|
|
} from 'semantic-ui-react'; |
|
|
import PropTypes from 'prop-types'; |
|
|
import PropTypes from 'prop-types'; |
|
|
import { useTranslation } from 'react-i18next'; |
|
|
import { useTranslation } from 'react-i18next'; |
|
@ -12,6 +12,8 @@ import checkUrlValid from '../../../../utils/urlUtils'; |
|
|
import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../../constants/orbit/UserDatabaseKeys'; |
|
|
import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../../constants/orbit/UserDatabaseKeys'; |
|
|
import { breeze, drizzle } from '../../../../redux/store'; |
|
|
import { breeze, drizzle } from '../../../../redux/store'; |
|
|
import UsernameSelector from '../../../../components/UsernameSelector'; |
|
|
import UsernameSelector from '../../../../components/UsernameSelector'; |
|
|
|
|
|
import ProfileImage from '../../../../components/ProfileImage'; |
|
|
|
|
|
import './style.css'; |
|
|
|
|
|
|
|
|
const { orbit: { stores } } = breeze; |
|
|
const { orbit: { stores } } = breeze; |
|
|
const { contracts: { [FORUM_CONTRACT]: { methods: { updateUsername } } } } = drizzle; |
|
|
const { contracts: { [FORUM_CONTRACT]: { methods: { updateUsername } } } } = drizzle; |
|
@ -88,11 +90,6 @@ const EditInformationModal = (props) => { |
|
|
} |
|
|
} |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
const profilePicture = useMemo(() => (profilePictureInput.length > 0 && profilePictureUrlValid |
|
|
|
|
|
? (<Image size="medium" src={profilePictureInput} wrapped />) |
|
|
|
|
|
: (<Icon name="user circle" size="massive" inverted color="black" />) |
|
|
|
|
|
), [profilePictureInput, profilePictureUrlValid]); |
|
|
|
|
|
|
|
|
|
|
|
const handleSubmit = useCallback(() => { |
|
|
const handleSubmit = useCallback(() => { |
|
|
const keyValuesToStore = []; |
|
|
const keyValuesToStore = []; |
|
|
|
|
|
|
|
@ -141,7 +138,13 @@ const EditInformationModal = (props) => { |
|
|
> |
|
|
> |
|
|
<Modal.Header>{t('edit.information.modal.title')}</Modal.Header> |
|
|
<Modal.Header>{t('edit.information.modal.title')}</Modal.Header> |
|
|
<Modal.Content image> |
|
|
<Modal.Content image> |
|
|
{profilePicture} |
|
|
<div id="edit-info-profile-image"> |
|
|
|
|
|
<ProfileImage |
|
|
|
|
|
profileUsername={usernameInput} |
|
|
|
|
|
avatarUrl={profilePictureUrlValid ? profilePictureInput : null} |
|
|
|
|
|
size="120" |
|
|
|
|
|
/> |
|
|
|
|
|
</div> |
|
|
<Modal.Description> |
|
|
<Modal.Description> |
|
|
<Form> |
|
|
<Form> |
|
|
<UsernameSelector |
|
|
<UsernameSelector |
|
@ -179,8 +182,9 @@ const EditInformationModal = (props) => { |
|
|
</Form> |
|
|
</Form> |
|
|
{error === true && ( |
|
|
{error === true && ( |
|
|
errorMessages |
|
|
errorMessages |
|
|
.map((errorMessage) => ( |
|
|
.map((errorMessage, index) => ( |
|
|
<Message |
|
|
<Message |
|
|
|
|
|
key={`edit-info-error-message-${{ index }}`} |
|
|
error |
|
|
error |
|
|
header={t('edit.information.modal.form.error.message.header')} |
|
|
header={t('edit.information.modal.form.error.message.header')} |
|
|
content={errorMessage} |
|
|
content={errorMessage} |
|
@ -189,6 +193,7 @@ const EditInformationModal = (props) => { |
|
|
)} |
|
|
)} |
|
|
{usernameError === true && ( |
|
|
{usernameError === true && ( |
|
|
<Message |
|
|
<Message |
|
|
|
|
|
key="edit-info-username-error-message" |
|
|
error |
|
|
error |
|
|
header={t('edit.information.modal.form.error.message.header')} |
|
|
header={t('edit.information.modal.form.error.message.header')} |
|
|
content={usernameErrorMessage} |
|
|
content={usernameErrorMessage} |
|
@ -212,11 +217,11 @@ const EditInformationModal = (props) => { |
|
|
/> |
|
|
/> |
|
|
</Modal.Actions> |
|
|
</Modal.Actions> |
|
|
</Modal> |
|
|
</Modal> |
|
|
), [ |
|
|
), [error, errorMessages, handleInputChange, |
|
|
error, errorMessages, handleInputChange, handleSubmit, handleUsernameErrorChange, initialUsername, locationInput, |
|
|
handleSubmit, handleUsernameErrorChange, |
|
|
onCancel, open, profilePicture, profilePictureInput, t, usernameChecked, usernameError, usernameErrorMessage, |
|
|
initialUsername, locationInput, onCancel, |
|
|
usernameInput, |
|
|
open, profilePictureInput, profilePictureUrlValid, t, |
|
|
]); |
|
|
usernameChecked, usernameError, usernameErrorMessage, usernameInput]); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
EditInformationModal.defaultProps = { |
|
|
EditInformationModal.defaultProps = { |
|
|