import { useEffect, useState } from 'react' import { PencilIcon } from '@heroicons/react/outline' import Router from 'next/router' import { AddFundsButton } from '../components/add-funds-button' import { Page } from '../components/page' import { SEO } from '../components/SEO' import { Title } from '../components/title' import { usePrivateUser, useUser } from '../hooks/use-user' import { formatMoney } from '../../common/util/format' import { cleanDisplayName, cleanUsername, } from '../../common/util/clean-username' import { changeUserInfo } from '../lib/firebase/api-call' import { uploadImage } from '../lib/firebase/storage' import { Col } from '../components/layout/col' import { Row } from '../components/layout/row' import { User } from '../../common/user' import { updateUser } from '../lib/firebase/users' import { defaultBannerUrl } from '../components/user-page' import { SiteLink } from '../components/site-link' import Textarea from 'react-expanding-textarea' function EditUserField(props: { user: User field: 'bio' | 'bannerUrl' | 'twitterHandle' | 'discordHandle' label: string }) { const { user, field, label } = props const [value, setValue] = useState(user[field] ?? '') async function updateField() { // Note: We trim whitespace before uploading to Firestore await updateUser(user.id, { [field]: value.trim() }) } return (
{field === 'bio' ? (