diff --git a/src/components/common/PinButton.js b/src/components/common/PinButton.js index e5abe0b60..e80ab7e0e 100644 --- a/src/components/common/PinButton.js +++ b/src/components/common/PinButton.js @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; import IconButton from '@material-ui/core/IconButton'; import PushPinIcon from '@material-ui/icons/PushPin'; -import PushPinOutlinedIcon from '@material-ui/icons/PushPinOutlined' +import PushPinOutlinedIcon from '@material-ui/icons/PushPinOutlined'; import { useTranslation } from 'react-i18next'; import Tooltip from '@material-ui/core/Tooltip'; import { MUTATION_KEYS } from '@graasp/query-client'; @@ -13,18 +13,18 @@ const PinButton = ({ item }) => { const { t } = useTranslation(); const editItem = useMutation(MUTATION_KEYS.EDIT_ITEM); - const [isPinned, setPinned] = useState(item.settings.isPinned); + const [isPinned, setPinned] = useState(item?.settings?.isPinned); const handlePin = () => { const { settings } = item; settings.isPinned = true; - editItem.mutate({ + editItem.mutate({ id: item.id, // use item login tag id name: item.name, settings: item.settings, - }); + }); setPinned(true); }; @@ -44,9 +44,7 @@ const PinButton = ({ item }) => { }; return ( - + { }; PinButton.propTypes = { - item: PropTypes.shape({ - id: PropTypes.string.isRequired, + item: PropTypes.shape({ + id: PropTypes.string.isRequired, name: PropTypes.string, settings: PropTypes.shape({ - isPinned: PropTypes.bool.isRequired - }).isRequired + isPinned: PropTypes.bool.isRequired, + }).isRequired, }).isRequired, }; diff --git a/src/components/item/settings/ItemSettings.js b/src/components/item/settings/ItemSettings.js index 6eee5a946..5e96b85da 100644 --- a/src/components/item/settings/ItemSettings.js +++ b/src/components/item/settings/ItemSettings.js @@ -38,7 +38,6 @@ const ItemSettings = ({ item }) => { editItem.mutate({ id: item.get('id'), - // use item login tag id name: item.get('name'), settings, }); @@ -49,7 +48,6 @@ const ItemSettings = ({ item }) => { editItem.mutate({ id: item.get('id'), - // use item login tag id name: item.get('name'), settings, });