forked from CaliCastle/cali.so
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d5612a
commit 0046e86
Showing
28 changed files
with
1,160 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { SignUp } from '@clerk/nextjs' | ||
|
||
import { Container } from '~/components/ui/Container' | ||
|
||
export default function Page() { | ||
return ( | ||
<Container className="mt-24 flex items-center justify-center"> | ||
<SignUp /> | ||
</Container> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
import { useQuery } from 'react-query' | ||
|
||
import { addComment, blogPostState } from '~/app/(main)/blog/blog-post.state' | ||
import { type PostIDLessCommentDto } from '~/db/dto/comment.dto' | ||
import { type Post } from '~/sanity/schemas/post' | ||
|
||
export function BlogPostStateLoader({ post }: { post: Post }) { | ||
const { data: comments } = useQuery( | ||
['comments', post._id], | ||
async () => { | ||
const res = await fetch(`/api/comments/${post._id}`) | ||
const data = await res.json() | ||
return data as PostIDLessCommentDto[] | ||
}, | ||
{ initialData: [] } | ||
) | ||
|
||
React.useEffect(() => { | ||
blogPostState.postId = post._id | ||
}, [post._id]) | ||
React.useEffect(() => { | ||
// only append new comments | ||
comments?.forEach((comment) => { | ||
if (blogPostState.comments.find((c) => c.id === comment.id)) return | ||
addComment(comment) | ||
}) | ||
}, [comments]) | ||
|
||
return null | ||
} |
Oops, something went wrong.