diff --git a/web/pages/date-docs/[username].tsx b/web/pages/date-docs/[username].tsx index 35270bef..112f2cde 100644 --- a/web/pages/date-docs/[username].tsx +++ b/web/pages/date-docs/[username].tsx @@ -1,5 +1,5 @@ import { getDateDoc } from 'web/lib/firebase/posts' -import { LinkIcon } from '@heroicons/react/outline' +import { ArrowLeftIcon, LinkIcon } from '@heroicons/react/outline' import { Page } from 'web/components/page' import dayjs from 'dayjs' @@ -18,19 +18,21 @@ import { track } from '@amplitude/analytics-browser' import toast from 'react-hot-toast' import { copyToClipboard } from 'web/lib/util/copy' import { useUser } from 'web/hooks/use-user' -import { RichEditPost } from '../post/[...slugs]' +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' export async function getStaticProps(props: { params: { username: string } }) { const { username } = props.params - const { user, post } = (await getDateDoc(username)) ?? { - user: null, + const { user: creator, post } = (await getDateDoc(username)) ?? { + creator: null, post: null, } return { props: { - user, + creator, post, }, revalidate: 5, // regenerate after five seconds @@ -41,19 +43,38 @@ export async function getStaticPaths() { return { paths: [], fallback: 'blocking' } } -export default function DateDocPage(props: { - user: User | null +export default function DateDocPageHelper(props: { + creator: User | null post: DateDoc | null }) { - const { user, post } = props + const { creator, post } = props - if (!user || !post) return + 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}!
+ + +
) } diff --git a/web/pages/post/[...slugs]/index.tsx b/web/pages/post/[...slugs]/index.tsx index 7e52c9b7..b71b7cca 100644 --- a/web/pages/post/[...slugs]/index.tsx +++ b/web/pages/post/[...slugs]/index.tsx @@ -34,9 +34,9 @@ export async function getStaticProps(props: { params: { slugs: string[] } }) { return { props: { - post: post, - creator: creator, - comments: comments, + post, + creator, + comments, }, revalidate: 60, // regenerate after a minute @@ -117,12 +117,7 @@ export default function PostPage(props: {
- +
@@ -133,9 +128,8 @@ export function PostCommentsActivity(props: { post: Post comments: PostComment[] tips: CommentTipMap - user: User | null | undefined }) { - const { post, comments, user, tips } = props + const { post, comments, tips } = props const commentsByUserId = groupBy(comments, (c) => c.userId) const commentsByParentId = groupBy(comments, (c) => c.replyToCommentId ?? '_') const topLevelComments = sortBy( @@ -149,7 +143,6 @@ export function PostCommentsActivity(props: { {topLevelComments.map((parent) => (