@@ -21,6 +21,8 @@ import { Editor } from "novel";
21
21
import { useEffect , useState } from "react" ;
22
22
import { type JSONContent } from "@tiptap/core" ;
23
23
import crypto from "crypto" ;
24
+ import { toast } from "@/components/ui/use-toast" ;
25
+ import { redirect } from "next/navigation" ;
24
26
// import {placeholder} from './defaultData';
25
27
26
28
function NovelEditor ( { id } : { id : string } ) {
@@ -36,7 +38,17 @@ function NovelEditor({ id }: { id: string }) {
36
38
try {
37
39
const response = await fetch ( `/api/note?id=${ id } ` ) ;
38
40
39
- if ( response . status === 404 ) {
41
+ if ( response . status === 401 ) {
42
+ toast ( {
43
+ title : "You don't have permissions not view/edit this note!" ,
44
+ description : "Redirecting to dashboard in 8 seconds" ,
45
+ variant : "destructive" ,
46
+ } ) ;
47
+ setTimeout ( ( ) => {
48
+ window . location . href = '/dash' ; // Redirect after 10 seconds
49
+ } , 8_000 ) ;
50
+ return null ;
51
+ } else if ( response . status === 404 ) {
40
52
return null ;
41
53
} else if ( ! response . ok ) {
42
54
throw new Error ( "Network response was not ok" ) ;
@@ -91,7 +103,10 @@ function NovelEditor({ id }: { id: string }) {
91
103
return (
92
104
< >
93
105
{ syncWithCloudWarning && (
94
- < Warning handleKeepLocalStorage = { handleKeepLocalStorage } handleKeepCloudStorage = { handleKeepCloudStorage } />
106
+ < Warning
107
+ handleKeepLocalStorage = { handleKeepLocalStorage }
108
+ handleKeepCloudStorage = { handleKeepCloudStorage }
109
+ />
95
110
) }
96
111
< div className = "relative w-full max-w-screen-lg pb-8" >
97
112
< div className = "absolute right-5 top-5 mb-5 rounded-lg bg-stone-100 px-2 py-1 text-sm text-stone-400" >
0 commit comments