import { useRouter } from 'next/router' import { HTMLAttributes, useEffect, useState } from 'react' import { FaChevronLeft, FaX } from 'react-icons/fa6' import Thread from './Thread' import { Entity, MegalodonInterface } from 'megalodon' import Reply from './Reply' import Profile from './Profile' import { Account } from '@/db' type Props = { client: MegalodonInterface account: Account openMedia: (media: Entity.Attachment) => void } & HTMLAttributes export default function Detail(props: Props) { const [target, setTarget] = useState<'status' | 'reply' | 'profile' | null>(null) const router = useRouter() useEffect(() => { if (router.query.status_id) { setTarget('status') } else if (router.query.reply_target_id) { setTarget('reply') } else if (router.query.user_id) { setTarget('profile') } else { setTarget(null) } }, [router.query]) const back = () => { router.back() } const close = () => { router.push({ query: { id: router.query.id, timeline: router.query.timeline } }) } return ( <> {target && (
{target === 'status' && ( )} {target === 'reply' && ( )} {target === 'profile' && ( )}
)} ) }