import { Answer } from 'common/answer' import { Contract } from 'common/contract' import React, { useEffect, useRef } from 'react' import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' import { Avatar } from 'web/components/avatar' import { CopyLinkDateTimeComponent } from 'web/components/feed/copy-link-date-time' import { useRouter } from 'next/router' import { UserLink } from 'web/components/user-link' export function CommentsAnswer(props: { answer: Answer; contract: Contract }) { const { answer, contract } = props const { username, avatarUrl, name, text } = answer const answerElementId = `answer-${answer.id}` const router = useRouter() const highlighted = router.asPath.endsWith(`#${answerElementId}`) const answerRef = useRef(null) useEffect(() => { if (highlighted && answerRef.current != null) { answerRef.current.scrollIntoView(true) } }, [highlighted]) return (
answered
{text}
) }