generated from warmachine028/github-super-starter-kit
-
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
789f024
commit 40f9173
Showing
6 changed files
with
86 additions
and
23 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 |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
"uploadthing": "7.3.0", | ||
"zod": "3.24.0-canary.20241107T043915" | ||
}, | ||
"description": "A full-stack social media web app built on NextJS 15 for the Next Fans", | ||
"devDependencies": { | ||
"@eslint/js": "^9.14.0", | ||
"@prisma/extension-accelerate": "^1.2.1", | ||
|
@@ -79,17 +80,10 @@ | |
}, | ||
"license": "MIT", | ||
"name": "next-book", | ||
"description": "A full-stack social media web app built on NextJS 15 for the Next Fans", | ||
"overrides": { | ||
"@types/react": "npm:[email protected]", | ||
"@types/react-dom": "npm:[email protected]" | ||
}, | ||
"tags": [ | ||
"nextjs", | ||
"nextjs15", | ||
"socialmedia", | ||
"fullstack" | ||
], | ||
"private": true, | ||
"scripts": { | ||
"build": "next build", | ||
|
@@ -103,6 +97,12 @@ | |
"prisma:studio": "prisma studio", | ||
"start": "next start" | ||
}, | ||
"tags": [ | ||
"nextjs", | ||
"nextjs15", | ||
"socialmedia", | ||
"fullstack" | ||
], | ||
"type": "module", | ||
"version": "0.1.0" | ||
} | ||
} |
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
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,43 @@ | ||
import type { CommentsPage } from '@/types' | ||
import { useQueryClient, useMutation, QueryKey, InfiniteData } from '@tanstack/react-query' | ||
import { useToast } from '.' | ||
import { deleteComment } from '@/components/comments/actions' | ||
|
||
const useDeleteCommentMutation = () => { | ||
const { toast } = useToast() | ||
const queryClient = useQueryClient() | ||
|
||
return useMutation({ | ||
mutationFn: deleteComment, | ||
onSuccess: async (deletedComment) => { | ||
const queryKey: QueryKey = ['comments', deletedComment.id] | ||
await queryClient.cancelQueries({ queryKey }) | ||
queryClient.setQueryData<InfiniteData<CommentsPage, string | null>>(queryKey, (data) => { | ||
if (!data) { | ||
return | ||
} | ||
return { | ||
pageParams: data.pageParams, | ||
pages: data.pages.map((page) => ({ | ||
previousCursor: page.previousCursor, | ||
comments: page.comments.filter((c) => c.id !== deletedComment.id) | ||
})) | ||
} | ||
}) | ||
|
||
toast({ | ||
variant: 'success', | ||
description: 'Comment deleted' | ||
}) | ||
}, | ||
onError: (error) => { | ||
console.error(error) | ||
toast({ | ||
variant: 'destructive', | ||
description: 'Failed to delete comment. Please try again.' | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
export default useDeleteCommentMutation |
40f9173
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
next-book – ./
next-boook.vercel.app
next-book-15.vercel.app
nextife.vercel.app
next-book-pritam.vercel.app
next-book-pritam-kundu.vercel.app
nextifly.vercel.app
next-book-git-main-pritam-kundu.vercel.app