import clsx from 'clsx' import dayjs from 'dayjs' import { useState } from 'react' import Textarea from 'react-expanding-textarea' import { Contract } from 'common/contract' import { parseTags } from 'common/util/parse' import { useAdmin } from 'web/hooks/use-admin' import { updateContract } from 'web/lib/firebase/contracts' import { Row } from '../layout/row' import { Linkify } from '../linkify' export function ContractDescription(props: { contract: Contract isCreator: boolean className?: string }) { const { contract, isCreator, className } = props const descriptionTimestamp = () => `${dayjs().format('MMM D, h:mma')}: ` const isAdmin = useAdmin() // Append the new description (after a newline) async function saveDescription(newText: string) { const newDescription = `${contract.description}\n\n${newText}`.trim() const tags = parseTags( `${newDescription} ${contract.tags.map((tag) => `#${tag}`).join(' ')}` ) const lowercaseTags = tags.map((tag) => tag.toLowerCase()) await updateContract(contract.id, { description: newDescription, tags, lowercaseTags, }) } if (!isCreator && !contract.description.trim()) return null return (