Skip to content

Commit

Permalink
test: fix tests and format
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-Torrent committed Oct 13, 2021
1 parent 32606c3 commit 08c5606
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
20 changes: 9 additions & 11 deletions src/components/common/PinButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
};
Expand All @@ -44,9 +44,7 @@ const PinButton = ({ item }) => {
};

return (
<Tooltip
title={isPinned ? t('Unpin') : t('Pin')}
>
<Tooltip title={isPinned ? t('Unpin') : t('Pin')}>
<IconButton
aria-label="favorite"
className={FAVORITE_ITEM_BUTTON_CLASS}
Expand All @@ -63,12 +61,12 @@ const PinButton = ({ item }) => {
};

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,
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/item/settings/ItemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const ItemSettings = ({ item }) => {

editItem.mutate({
id: item.get('id'),
// use item login tag id
name: item.get('name'),
settings,
});
Expand All @@ -49,7 +48,6 @@ const ItemSettings = ({ item }) => {

editItem.mutate({
id: item.get('id'),
// use item login tag id
name: item.get('name'),
settings,
});
Expand Down

0 comments on commit 08c5606

Please sign in to comment.