import { useEffect, useState } from 'react' import { useLazyQuery } from '@apollo/client' import { SaveIcon } from '@heroicons/react/outline' import { GET_CSV } from '@graphql/queries' import { Tooltip } from '@components/tailwind/Tooltip' export const GetCsvButton = ({ address }) => { const [getCsv, { data }] = useLazyQuery(GET_CSV, { fetchPolicy: 'no-cache', }) const [click, setClick] = useState(1) const [ipfsGatewayUrl, setUrl] = useState('') useEffect(() => { if (data) { setUrl(data.getCsv.ipfsGatewayUrl) window.open(data.getCsv.ipfsGatewayUrl) } }, [data, ipfsGatewayUrl, click]) const onClick = () => { setClick(click + 1) getCsv({ variables: { address } }) } return ( ) }