Browse Source

Merge branch 'implement-ui' into add-event-saga-fix-user-state

develop
Apostolos Fanakis 4 years ago
parent
commit
f418e263fe
  1. 16
      packages/concordia-app/src/components/PostCreate/index.jsx
  2. 16
      packages/concordia-app/src/views/Topic/TopicCreate/index.jsx

16
packages/concordia-app/src/components/PostCreate/index.jsx

@ -30,8 +30,6 @@ const PostCreate = (props) => {
const [postSubject, setPostSubject] = useState(initialPostSubject); const [postSubject, setPostSubject] = useState(initialPostSubject);
const [postContent, setPostContent] = useState(''); const [postContent, setPostContent] = useState('');
const [userProfilePictureUrl, setUserProfilePictureUrl] = useState(); const [userProfilePictureUrl, setUserProfilePictureUrl] = useState();
const [postSubjectInputEmptySubmit, setPostSubjectInputEmptySubmit] = useState(false);
const [postContentInputEmptySubmit, setPostContentInputEmptySubmit] = useState(false);
const [createPostCacheSendStackId, setCreatePostCacheSendStackId] = useState(''); const [createPostCacheSendStackId, setCreatePostCacheSendStackId] = useState('');
const [posting, setPosting] = useState(false); const [posting, setPosting] = useState(false);
const [storingPost, setStoringPost] = useState(false); const [storingPost, setStoringPost] = useState(false);
@ -103,8 +101,7 @@ const PostCreate = (props) => {
setPostSubject(initialPostSubject); setPostSubject(initialPostSubject);
setPostContent(''); setPostContent('');
setPosting(false); setPosting(false);
setPostSubjectInputEmptySubmit(false); setStoringPost(false);
setPostContentInputEmptySubmit(false);
setCreatePostCacheSendStackId(''); setCreatePostCacheSendStackId('');
}) })
.catch((reason) => { .catch((reason) => {
@ -120,13 +117,7 @@ const PostCreate = (props) => {
]); ]);
const savePost = useCallback(() => { const savePost = useCallback(() => {
if (postSubject === '') { if (postSubject === '' || postContent === '') {
setPostSubjectInputEmptySubmit(true);
return;
}
if (postContent === '') {
setPostContentInputEmptySubmit(true);
return; return;
} }
@ -162,7 +153,6 @@ const PostCreate = (props) => {
name="postSubject" name="postSubject"
className="subject-input" className="subject-input"
size="mini" size="mini"
error={postSubjectInputEmptySubmit}
value={postSubject} value={postSubject}
onChange={handleInputChange} onChange={handleInputChange}
/> />
@ -176,10 +166,8 @@ const PostCreate = (props) => {
<TextArea <TextArea
placeholder={t('post.form.content.field.placeholder')} placeholder={t('post.form.content.field.placeholder')}
name="postContent" name="postContent"
className="content-input"
size="mini" size="mini"
rows={4} rows={4}
error={postContentInputEmptySubmit}
value={postContent} value={postContent}
onChange={handleInputChange} onChange={handleInputChange}
/> />

16
packages/concordia-app/src/views/Topic/TopicCreate/index.jsx

@ -25,8 +25,6 @@ const TopicCreate = (props) => {
const transactions = useSelector((state) => state.transactions); const transactions = useSelector((state) => state.transactions);
const [subjectInput, setSubjectInput] = useState(''); const [subjectInput, setSubjectInput] = useState('');
const [contentInput, setContentInput] = useState(''); const [contentInput, setContentInput] = useState('');
const [topicSubjectInputEmptySubmit, setTopicSubjectInputEmptySubmit] = useState(false);
const [topicMessageInputEmptySubmit, setTopicMessageInputEmptySubmit] = useState(false);
const [createTopicCacheSendStackId, setCreateTopicCacheSendStackId] = useState(''); const [createTopicCacheSendStackId, setCreateTopicCacheSendStackId] = useState('');
const [posting, setPosting] = useState(false); const [posting, setPosting] = useState(false);
@ -90,13 +88,7 @@ const TopicCreate = (props) => {
}, [createTopicCacheSendStackId, history, contentInput, posting, subjectInput, transactionStack, transactions]); }, [createTopicCacheSendStackId, history, contentInput, posting, subjectInput, transactionStack, transactions]);
const validateAndPost = useCallback(() => { const validateAndPost = useCallback(() => {
if (subjectInput === '') { if (subjectInput === '' || contentInput === '') {
setTopicSubjectInputEmptySubmit(true);
return;
}
if (contentInput === '') {
setTopicMessageInputEmptySubmit(true);
return; return;
} }
@ -116,7 +108,6 @@ const TopicCreate = (props) => {
placeholder={t('topic.create.form.subject.field.placeholder')} placeholder={t('topic.create.form.subject.field.placeholder')}
name="subjectInput" name="subjectInput"
className="form-input" className="form-input"
error={topicSubjectInputEmptySubmit}
value={subjectInput} value={subjectInput}
onChange={handleSubjectInputChange} onChange={handleSubjectInputChange}
/> />
@ -128,9 +119,6 @@ const TopicCreate = (props) => {
<TextArea <TextArea
id="form-topic-create-field-message" id="form-topic-create-field-message"
name="contentInput" name="contentInput"
className={topicMessageInputEmptySubmit
? 'form-textarea-required'
: ''}
value={contentInput} value={contentInput}
placeholder={t('topic.create.form.content.field.placeholder')} placeholder={t('topic.create.form.content.field.placeholder')}
rows={5} rows={5}
@ -144,7 +132,7 @@ const TopicCreate = (props) => {
key="form-topic-create-button-submit" key="form-topic-create-button-submit"
type="button" type="button"
color="green" color="green"
disabled={posting} disabled={posting || subjectInput === '' || contentInput === ''}
onClick={validateAndPost} onClick={validateAndPost}
> >
<Button.Content visible> <Button.Content visible>

Loading…
Cancel
Save