import { CopyInput } from './form' import { gql, useMutation } from '@apollo/client' import { INVITE_FIELDS } from '@/fragments/invites' import styles from '@/styles/invites.module.css' import { useToast } from '@/components/toast' export default function Invite ({ invite, active }) { const [revokeInvite] = useMutation( gql` ${INVITE_FIELDS} mutation revokeInvite($id: ID!) { revokeInvite(id: $id) { ...InviteFields } }` ) const toaster = useToast() return (
{invite.description && {invite.description}}
{invite.gift} sat gift \ {invite.invitees.length} joined{invite.limit ? ` of ${invite.limit}` : ''} {active ? ( <> \ { try { await revokeInvite({ variables: { id: invite.id } }) } catch (err) { toaster.danger(err.message) } }} >revoke ) : invite.revoked && ( <> \ revoked )}
) }