import { Button, Dialog, DialogBody, DialogHeader, Textarea, Typography } from '@material-tailwind/react' import { Entity, MegalodonInterface } from 'megalodon' import { useEffect, useState } from 'react' import { FormattedMessage } from 'react-intl' type Props = { media: Entity.Attachment | undefined close: () => void client: MegalodonInterface } export default function EditMedia(props: Props) { const [description, setDescription] = useState('') useEffect(() => { if (props.media) { const f = async () => { const res = await props.client.getMedia(props.media.id) if (res.data.description) { setDescription(res.data.description) } } f() } }, [props.media, props.client]) const submit = async () => { if (!props.media || !props.client) return await props.client.updateMedia(props.media.id, { description: description }) } const onClose = () => { setDescription('') props.close() } return ( {props.media && ( <>