()
| 76 | } |
| 77 | |
| 78 | async function updateNoteBook() { |
| 79 | setSaving(true); |
| 80 | const res = await fetch(`/api/v1/notebooks/note/${router.query.id}/update`, { |
| 81 | method: "PUT", |
| 82 | headers: { |
| 83 | "Content-Type": "application/json", |
| 84 | Authorization: `Bearer ${token}`, |
| 85 | }, |
| 86 | body: JSON.stringify({ |
| 87 | title: debounceTitle, |
| 88 | content: JSON.stringify(debouncedValue), |
| 89 | }), |
| 90 | }); |
| 91 | const data = await res.json(); |
| 92 | setSaving(false); |
| 93 | let date = new Date(); |
| 94 | // @ts-ignore |
| 95 | setLastSaved(new Date(date).getTime()); |
| 96 | if(data.status) { |
| 97 | toast({ |
| 98 | variant: "destructive", |
| 99 | title: "Error -> Unable to update", |
| 100 | description: data.message, |
| 101 | }); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | async function deleteNotebook(id) { |
| 106 | if (window.confirm("Do you really want to delete this notebook?")) { |
no test coverage detected