import { useState } from 'react' import { useLoaderData, Link as ReactRouterLink, useNavigation, useSubmit } from 'react-router-dom' import { LoadingSpinner } from 'components/LoadingSpinner' import { ProfileSection } from 'components/ProfileSection' import { Comments } from 'components/comment' import { Addressable, BlogPageLoaderResult } from 'types' import placeholder from '../../assets/img/DEGMods Placeholder Img.png' import { PublishDetails } from 'components/Internal/PublishDetails' import { Interactions } from 'components/Internal/Interactions' import { BlogCard } from 'components/BlogCard' import { copyTextToClipboard } from 'utils' import { toast } from 'react-toastify' import { useAppSelector, useBodyScrollDisable } from 'hooks' import { ReportPopup } from 'components/ReportPopup' import { Editor } from 'components/editor' const BLOG_REPORT_REASONS = [ { label: 'Actually CP', key: 'actuallyCP' }, { label: 'Spam', key: 'spam' }, { label: 'Scam', key: 'scam' }, { label: 'Malware', key: 'malware' }, { label: `Wasn't tagged NSFW`, key: 'wasntTaggedNSFW' }, { label: 'Other', key: 'otherReason' } ] export const BlogPage = () => { const { blog, latest, isAddedToNSFW, isBlocked } = useLoaderData() as BlogPageLoaderResult const userState = useAppSelector((state) => state.user) const isAdmin = userState.user?.npub && userState.user.npub === import.meta.env.VITE_REPORTING_NPUB const navigation = useNavigation() const [commentCount, setCommentCount] = useState(0) const [showReportPopUp, setShowReportPopUp] = useState() useBodyScrollDisable(!!showReportPopUp) const submit = useSubmit() const handleBlock = () => { if (navigation.state === 'idle') { submit( { intent: 'block', value: !isBlocked, target: blog?.aTag || '' }, { method: 'post', encType: 'application/json' } ) } } const handleNSFW = () => { if (navigation.state === 'idle') { submit( { intent: 'nsfw', value: !isAddedToNSFW, target: blog?.aTag || '' }, { method: 'post', encType: 'application/json' } ) } } return (
{blog && ( <>
{!!latest.length && (

Latest blog posts

{latest.map((b) => ( ))}
)}
{navigation.state !== 'idle' && ( )} {!!showReportPopUp && ( setShowReportPopUp(undefined)} /> )} )} {!!blog?.author && }
) }