Skip to content

Commit 7b629fd

Browse files
committed
pass username prop
1 parent 9ff3624 commit 7b629fd

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

client/modules/User/components/Collection.jsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@ import ArrowDownIcon from '../../../images/sort-arrow-down.svg';
1313
import CollectionMetadata from './CollectionMetadata';
1414
import CollectionItemRow from './CollectionItemRow';
1515

16-
const Collection = ({ collectionId }) => {
16+
const Collection = ({ collectionId, username }) => {
1717
const { t } = useTranslation();
1818
const dispatch = useDispatch();
1919

20-
const { user, collection, sorting, loading, username } = useSelector(
21-
(state) => ({
22-
user: state.user,
23-
collection: getCollection(state, collectionId),
24-
sorting: state.sorting,
25-
loading: state.loading,
26-
username: state.user.username
27-
})
28-
);
20+
const { user, collection, sorting, loading } = useSelector((state) => ({
21+
user: state.user,
22+
collection: getCollection(state, collectionId),
23+
sorting: state.sorting,
24+
loading: state.loading
25+
}));
2926

3027
useEffect(() => {
3128
dispatch(CollectionsActions.getCollections(username));
@@ -34,7 +31,7 @@ const Collection = ({ collectionId }) => {
3431

3532
const isOwner = () =>
3633
user != null &&
37-
user.username &&
34+
typeof user.username !== 'undefined' &&
3835
collection?.owner?.username === user.username;
3936

4037
const hasCollection = () => !!collection;
@@ -160,7 +157,8 @@ const Collection = ({ collectionId }) => {
160157
};
161158

162159
Collection.propTypes = {
163-
collectionId: PropTypes.string.isRequired
160+
collectionId: PropTypes.string.isRequired,
161+
username: PropTypes.string.isRequired
164162
};
165163

166164
export default Collection;

0 commit comments

Comments
 (0)