import { useQuery } from '@apollo/client' import Link from 'next/link' import { RELATED_ITEMS } from '../fragments/items' import AccordianItem from './accordian-item' import Item, { ItemSkeleton } from './item' import styles from './items.module.css' export default function Related ({ title, itemId }) { const emptyItems = new Array(5).fill(null) const { data, loading } = useQuery(RELATED_ITEMS, { fetchPolicy: 'cache-first', variables: { title, id: itemId, limit: 5 } }) let items, cursor if (data) { ({ related: { items, cursor } } = data) } return ( related} body={ <>
{loading ? emptyItems.map((_, i) => ) : (items?.length ? items.map(item => ) :
EMPTY
)}
{cursor && itemId && view all related} } /> ) }