aboutsummaryrefslogtreecommitdiffstats
path: root/apps/Notes/helpers/noteActions.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2021-09-04 10:56:37 +0200
committerGravatar piotrruss <mail@pruss.it> 2021-09-04 10:56:37 +0200
commita28b952eafc83ac6f6fc1a3d99805866bc41fde9 (patch)
tree5e8e99ef5ac2b11e8a8ab027a976caa9b1af480f /apps/Notes/helpers/noteActions.js
parent467233f771d745aeb9f4e69b93d2fb24a1a95d3e (diff)
downloadmy_apps-a28b952eafc83ac6f6fc1a3d99805866bc41fde9.tar.gz
my_apps-a28b952eafc83ac6f6fc1a3d99805866bc41fde9.tar.bz2
my_apps-a28b952eafc83ac6f6fc1a3d99805866bc41fde9.zip
routes refactor
Diffstat (limited to 'apps/Notes/helpers/noteActions.js')
-rw-r--r--apps/Notes/helpers/noteActions.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/apps/Notes/helpers/noteActions.js b/apps/Notes/helpers/noteActions.js
index f67e7a4..f864e58 100644
--- a/apps/Notes/helpers/noteActions.js
+++ b/apps/Notes/helpers/noteActions.js
@@ -4,7 +4,7 @@ import filename from '../helpers/fileName'
export const getNote = async (note, setFetchedNote, t, setPopup, callback) => {
try {
- const {content} = await fetchJson(`/api/note/${note.noteId}`)
+ const {content} = await fetchJson(`/api/notes/${note.noteId}`)
setFetchedNote({ ...note, content})
callback()
} catch (err) {
@@ -50,10 +50,10 @@ export const updateNote = async (e, note, mutateNotes, setAction, t, setPopup) =
try {
mutateNotes(
- await fetchJson('/api/notes', {
+ await fetchJson(`/api/notes/${_id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({_id, title, noteId, content}),
+ body: JSON.stringify({title, noteId, content}),
})
)
setPopup({
@@ -76,10 +76,8 @@ export const removeNote = (e, _id, mutateNotes, t, setPopup, setAction) => {
const remove = async () => {
try {
await mutateNotes(
- await fetchJson('/api/notes', {
+ await fetchJson(`/api/notes/${_id}`, {
method: 'DELETE',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({_id}),
})
)
setPopup({
@@ -98,8 +96,8 @@ export const removeNote = (e, _id, mutateNotes, t, setPopup, setAction) => {
setPopup({
content: t('notes_remove_confirm'),
- yes: { label: t('remove'), action: remove },
- no: { label: t('cancel'), action: async () => {} },
+ yes: {label: t('remove'), action: remove},
+ no: {label: t('cancel'), action: async () => {}},
error: true,
})
}
@@ -108,7 +106,7 @@ export const exportNote = async note => {
const {title} = note
const {content} = note.content
? note
- : await fetchJson(`/api/note/${note.noteId}`)
+ : await fetchJson(`/api/notes/${note.noteId}`)
saveFile(content, filename(title), 'text/plain')
}