(id)
| 103 | } |
| 104 | |
| 105 | async function deleteNotebook(id) { |
| 106 | if (window.confirm("Do you really want to delete this notebook?")) { |
| 107 | await fetch(`/api/v1/notebooks/note/${router.query.id}`, { |
| 108 | method: "DELETE", |
| 109 | headers: { |
| 110 | Authorization: `Bearer ${token}`, |
| 111 | }, |
| 112 | }) |
| 113 | .then((res) => res.json()) |
| 114 | .then((res) => { |
| 115 | if (res.success) { |
| 116 | router.push("/documents"); |
| 117 | } else { |
| 118 | toast({ |
| 119 | variant: "destructive", |
| 120 | title: "Error -> Unable to delete", |
| 121 | description: res.message, |
| 122 | }); |
| 123 | } |
| 124 | }); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | useEffect(() => { |
| 129 | fetchNotebook(); |
no test coverage detected