diff --git a/client/modules/IDE/components/CollectionList/CollectionList.jsx b/client/modules/IDE/components/CollectionList/CollectionList.jsx index cf25be5018..4c37e28bb2 100644 --- a/client/modules/IDE/components/CollectionList/CollectionList.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionList.jsx @@ -2,41 +2,31 @@ import PropTypes from 'prop-types'; import React, { useEffect, useState, useMemo } from 'react'; import { Helmet } from 'react-helmet'; import { useTranslation } from 'react-i18next'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; +import { useSelector, useDispatch } from 'react-redux'; import classNames from 'classnames'; import { find } from 'lodash'; import * as ProjectActions from '../../actions/project'; -import * as ProjectsActions from '../../actions/projects'; import * as CollectionsActions from '../../actions/collections'; -import * as ToastActions from '../../actions/toast'; import * as SortingActions from '../../actions/sorting'; import getSortedCollections from '../../selectors/collections'; import Loader from '../../../App/components/loader'; import Overlay from '../../../App/components/Overlay'; import AddToCollectionSketchList from '../AddToCollectionSketchList'; import { SketchSearchbar } from '../Searchbar'; - import CollectionListRow from './CollectionListRow'; - import ArrowUpIcon from '../../../../images/sort-arrow-up.svg'; import ArrowDownIcon from '../../../../images/sort-arrow-down.svg'; +import * as ProjectsActions from '../../actions/projects'; +import * as ToastActions from '../../actions/toast'; -const CollectionList = ({ - user, - projectId, - getCollections, - getProject, - collections, - username: propsUsername, - loading, - toggleDirectionForField, - resetSorting, - sorting, - project, - mobile -}) => { +const CollectionList = ({ projectId, username: propsUsername, mobile }) => { + const dispatch = useDispatch(); const { t } = useTranslation(); + const user = useSelector((state) => state.user); + const collections = useSelector((state) => getSortedCollections(state)); + const sorting = useSelector((state) => state.sorting); + const loading = useSelector((state) => state.loading); + const project = useSelector((state) => state.project); const [hasLoadedData, setHasLoadedData] = useState(false); const [ addingSketchesToCollectionId, @@ -45,11 +35,13 @@ const CollectionList = ({ useEffect(() => { if (projectId) { - getProject(projectId); + dispatch(ProjectActions.getProject(projectId)); } - getCollections(propsUsername || user.username); - resetSorting(); - }, []); + dispatch(CollectionsActions.getCollections(propsUsername || user.username)); + dispatch(SortingActions.resetSorting()); + dispatch(ProjectsActions.getProjects(propsUsername || user.username)); + dispatch(ToastActions.showToast('Collections loaded successfully!')); + }, [dispatch, projectId, propsUsername, user.username]); useEffect(() => { if (!loading) { @@ -124,7 +116,9 @@ const CollectionList = ({