import { getDateDoc } from 'web/lib/firebase/posts' import { ArrowLeftIcon, LinkIcon } from '@heroicons/react/outline' import { Page } from 'web/components/page' import dayjs from 'dayjs' import toast from 'react-hot-toast' import clsx from 'clsx' import { DateDoc } from 'common/post' import { Content } from 'web/components/editor' import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' import { SiteLink } from 'web/components/site-link' import { User } from 'web/lib/firebase/users' import { DOMAIN } from 'common/envs/constants' import Custom404 from '../404' import { ShareIcon } from '@heroicons/react/solid' import { Button } from 'web/components/button' import { track } from '@amplitude/analytics-browser' import { copyToClipboard } from 'web/lib/util/copy' import { useUser } from 'web/hooks/use-user' import { PostCommentsActivity, RichEditPost } from '../post/[...slugs]' import { usePost } from 'web/hooks/use-post' import { useTipTxns } from 'web/hooks/use-tip-txns' import { useCommentsOnPost } from 'web/hooks/use-comments' import { NoSEO } from 'web/components/NoSEO' export async function getStaticProps(props: { params: { username: string } }) { const { username } = props.params const { user: creator, post } = (await getDateDoc(username)) ?? { creator: null, post: null, } return { props: { creator, post, }, revalidate: 5, // regenerate after five seconds } } export async function getStaticPaths() { return { paths: [], fallback: 'blocking' } } export default function DateDocPageHelper(props: { creator: User | null post: DateDoc | null }) { const { creator, post } = props if (!creator || !post) return return } function DateDocPage(props: { creator: User; post: DateDoc }) { const { creator, post } = props const tips = useTipTxns({ postId: post.id }) const comments = useCommentsOnPost(post.id) ?? [] return (
Add your endorsement of {creator.name}!
) } export function DateDocPost(props: { dateDoc: DateDoc creator: User link?: boolean }) { const { dateDoc, creator, link } = props const { content, birthday, contractSlug } = dateDoc const { name, username } = creator const user = useUser() const post = usePost(dateDoc.id) ?? dateDoc const age = dayjs().diff(birthday, 'year') const shareUrl = `https://${DOMAIN}/date-docs/${username}` const marketUrl = `https://${DOMAIN}/${username}/${contractSlug}` return (
{name}, {age}
{user && user.id === creator.id ? ( ) : ( )}
) }