2023-02-16 22:23:59 +00:00
|
|
|
import { useMutation } from '@apollo/client'
|
2023-07-23 15:08:43 +00:00
|
|
|
import { gql } from 'graphql-tag'
|
2023-07-24 18:35:05 +00:00
|
|
|
import Dropdown from 'react-bootstrap/Dropdown'
|
2023-02-16 22:23:59 +00:00
|
|
|
|
|
|
|
export default function BookmarkDropdownItem ({ item: { id, meBookmark } }) {
|
|
|
|
const [bookmarkItem] = useMutation(
|
|
|
|
gql`
|
|
|
|
mutation bookmarkItem($id: ID!) {
|
|
|
|
bookmarkItem(id: $id) {
|
|
|
|
meBookmark
|
|
|
|
}
|
|
|
|
}`, {
|
|
|
|
update (cache, { data: { bookmarkItem } }) {
|
|
|
|
cache.modify({
|
|
|
|
id: `Item:${id}`,
|
|
|
|
fields: {
|
|
|
|
meBookmark: () => bookmarkItem.meBookmark
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
return (
|
|
|
|
<Dropdown.Item
|
|
|
|
onClick={() => bookmarkItem({ variables: { id } })}
|
|
|
|
>
|
|
|
|
{meBookmark ? 'remove bookmark' : 'bookmark'}
|
|
|
|
</Dropdown.Item>
|
|
|
|
)
|
|
|
|
}
|