feat: invalidate cache on post save

This commit is contained in:
shadcn 2022-11-06 14:27:40 +04:00
parent de31e9fc30
commit 59e5bf7a28

View file

@ -8,6 +8,7 @@ import Link from "next/link"
import TextareaAutosize from "react-textarea-autosize"
import * as z from "zod"
import { zodResolver } from "@hookform/resolvers/zod"
import { useRouter } from "next/navigation"
import { Icons } from "@/components/icons"
import { postPatchSchema } from "@/lib/validations/post"
@ -24,6 +25,7 @@ export function Editor({ post }: EditorProps) {
resolver: zodResolver(postPatchSchema),
})
const ref = React.useRef<EditorJS>()
const router = useRouter()
const [isSaving, setIsSaving] = React.useState<boolean>(false)
const [isMounted, setIsMounted] = React.useState<boolean>(false)
@ -101,6 +103,8 @@ export function Editor({ post }: EditorProps) {
})
}
router.refresh()
return toast({
message: "Your post has been saved.",
type: "success",