feat: Modified discussions FE so that ONLY users with verified emails (#789)
* feat: Modified discussions FE so that ONLY users with verified emails can create content * feat: added comment and response functionality * test: fixed test cases * refactor: refactor code and added HOC * test: added test cases * test: added test cases for failed and denied * feat: added states for button * refactor: added callback function * test: added test case to close the dialogue * refactor: refactor function
This commit is contained in:
@@ -5,23 +5,29 @@ import { useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
|
||||
import withEmailConfirmation from '../common/withEmailConfirmation';
|
||||
import { useIsOnTablet } from '../data/hooks';
|
||||
import { selectAreThreadsFiltered, selectPostThreadCount } from '../data/selectors';
|
||||
import {
|
||||
selectAreThreadsFiltered,
|
||||
selectIsEmailVerified,
|
||||
selectPostThreadCount,
|
||||
} from '../data/selectors';
|
||||
import messages from '../messages';
|
||||
import { showPostEditor } from '../posts/data';
|
||||
import postMessages from '../posts/post-actions-bar/messages';
|
||||
import EmptyPage from './EmptyPage';
|
||||
|
||||
const EmptyPosts = ({ subTitleMessage }) => {
|
||||
const EmptyPosts = ({ subTitleMessage, openEmailConfirmation }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useDispatch();
|
||||
const isOnTabletorDesktop = useIsOnTablet();
|
||||
const isFiltered = useSelector(selectAreThreadsFiltered);
|
||||
const totalThreads = useSelector(selectPostThreadCount);
|
||||
const isEmailVerified = useSelector(selectIsEmailVerified);
|
||||
|
||||
const addPost = useCallback(() => (
|
||||
dispatch(showPostEditor())
|
||||
), []);
|
||||
const addPost = useCallback(() => {
|
||||
if (isEmailVerified) { dispatch(showPostEditor()); } else { openEmailConfirmation(); }
|
||||
}, [isEmailVerified, openEmailConfirmation]);
|
||||
|
||||
let title = messages.noPostSelected;
|
||||
let subTitle = null;
|
||||
@@ -58,6 +64,7 @@ EmptyPosts.propTypes = {
|
||||
defaultMessage: propTypes.string,
|
||||
description: propTypes.string,
|
||||
}).isRequired,
|
||||
openEmailConfirmation: propTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default React.memo(EmptyPosts);
|
||||
export default React.memo(withEmailConfirmation(EmptyPosts));
|
||||
|
||||
Reference in New Issue
Block a user