1
0
Fork 0
mirror of synced 2024-10-03 10:36:59 +13:00

changes notification handling from catch-all to specific messages per action

This commit is contained in:
Keviin Åberg Kultalahti 2021-01-25 12:55:29 +01:00
parent 2034fb8646
commit 8713105b62
3 changed files with 18 additions and 8 deletions

View file

@ -1,5 +1,3 @@
import { notificationStore } from "../store/notification"
/** /**
* API cache for cached request responses. * API cache for cached request responses.
*/ */
@ -9,7 +7,6 @@ let cache = {}
* Handler for API errors. * Handler for API errors.
*/ */
const handleError = error => { const handleError = error => {
notificationStore.danger('An error has occured.')
return { error } return { error }
} }

View file

@ -1,10 +1,15 @@
import { notificationStore } from "../store/notification"
import API from "./api" import API from "./api"
/** /**
* Executes an automation. Must have "App Action" trigger. * Executes an automation. Must have "App Action" trigger.
*/ */
export const triggerAutomation = async (automationId, fields) => { export const triggerAutomation = async (automationId, fields) => {
return await API.post({ const res = await API.post({
url: `/api/automations/${automationId}/trigger`, url: `/api/automations/${automationId}/trigger`,
body: { fields }, body: { fields },
}) })
res.error
? notificationStore.danger("En error has occured")
: notificationStore.success("Automation triggered.")
return res
} }

View file

@ -20,7 +20,9 @@ export const saveRow = async row => {
url: `/api/${row.tableId}/rows`, url: `/api/${row.tableId}/rows`,
body: row, body: row,
}) })
notificationStore.success("Row saved") res.error
? notificationStore.danger("En error has occured")
: notificationStore.success("Row saved")
return res return res
} }
@ -32,7 +34,9 @@ export const updateRow = async row => {
url: `/api/${row.tableId}/rows/${row._id}`, url: `/api/${row.tableId}/rows/${row._id}`,
body: row, body: row,
}) })
notificationStore.success("Row updated") res.error
? notificationStore.danger("En error has occured")
: notificationStore.success("Row updated")
return res return res
} }
@ -43,7 +47,9 @@ export const deleteRow = async ({ tableId, rowId, revId }) => {
const res = await API.del({ const res = await API.del({
url: `/api/${tableId}/rows/${rowId}/${revId}`, url: `/api/${tableId}/rows/${rowId}/${revId}`,
}) })
notificationStore.success("Row deleted") res.error
? notificationStore.danger("En error has occured")
: notificationStore.success("Row deleted")
return res return res
} }
@ -58,7 +64,9 @@ export const deleteRows = async ({ tableId, rows }) => {
type: "delete", type: "delete",
}, },
}) })
notificationStore.success(`${rows.length} rows deleted.`) res.error
? notificationStore.danger("En error has occured")
: notificationStore.success(`${rows.length} rows deleted.`)
return res return res
} }