Browse Source

fix: EditInformationModal fixes

develop
Ezerous 4 years ago
parent
commit
16bc012e29
  1. 2
      packages/concordia-app/src/components/PostList/PostListRow/index.jsx
  2. 31
      packages/concordia-app/src/views/Profile/GeneralTab/EditInformationModal/index.jsx
  3. 4
      packages/concordia-app/src/views/Profile/GeneralTab/EditInformationModal/style.css

2
packages/concordia-app/src/components/PostList/PostListRow/index.jsx

@ -14,12 +14,12 @@ import { FORUM_CONTRACT } from 'concordia-shared/src/constants/contracts/Contrac
import { POSTS_DATABASE, USER_DATABASE } from 'concordia-shared/src/constants/orbit/OrbitDatabases'; import { POSTS_DATABASE, USER_DATABASE } from 'concordia-shared/src/constants/orbit/OrbitDatabases';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions'; import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import { breeze } from '../../../redux/store'; import { breeze } from '../../../redux/store';
import './styles.css';
import determineKVAddress from '../../../utils/orbitUtils'; import determineKVAddress from '../../../utils/orbitUtils';
import { POST_CONTENT } from '../../../constants/orbit/PostsDatabaseKeys'; import { POST_CONTENT } from '../../../constants/orbit/PostsDatabaseKeys';
import ProfileImage from '../../ProfileImage'; import ProfileImage from '../../ProfileImage';
import PostVoting from '../PostVoting'; import PostVoting from '../PostVoting';
import targetBlank from '../../../utils/markdownUtils'; import targetBlank from '../../../utils/markdownUtils';
import './styles.css';
const { orbit } = breeze; const { orbit } = breeze;

31
packages/concordia-app/src/views/Profile/GeneralTab/EditInformationModal/index.jsx

@ -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 = {

4
packages/concordia-app/src/views/Profile/GeneralTab/EditInformationModal/style.css

@ -0,0 +1,4 @@
#edit-info-profile-image {
padding-top: 0.3rem;
padding-right: 2rem;
}
Loading…
Cancel
Save