import React from 'react' import { useQuery } from '@apollo/client' import AccordianItem from './accordian-item' import Item, { ItemSkeleton } from './item' import { BOUNTY_ITEMS_BY_USER_NAME } from '../fragments/items' import Link from 'next/link' import styles from './items.module.css' export default function PastBounties ({ children, item }) { const emptyItems = new Array(5).fill(null) const { data, loading } = useQuery(BOUNTY_ITEMS_BY_USER_NAME, { variables: { name: item.user.name, limit: 5 }, fetchPolicy: 'cache-first' }) let items, cursor if (data) { ({ getBountiesByUserName: { items, cursor } } = data) items = items.filter(i => i.id !== item.id) } return ( {item.user.name}'s bounties} body={ <>
{loading ? emptyItems.map((_, i) => ) : (items?.length ? items.map(bountyItem => { return }) :
EMPTY
)}
{cursor && view all past bounties} } /> ) }