aboutsummaryrefslogtreecommitdiff
path: root/src/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/item.js8
-rw-r--r--src/classes/notifications.js31
2 files changed, 35 insertions, 4 deletions
diff --git a/src/classes/item.js b/src/classes/item.js
index 63f65ca..53f4bcd 100644
--- a/src/classes/item.js
+++ b/src/classes/item.js
@@ -54,25 +54,25 @@ export class InvoiceItem extends Item {
export const saveItem = (item, ok, fail) => {
axios.post("/item/new", item)
.then(res => ok())
- .catch((err) => fail())
+ .catch(err => fail(err))
}
export const deleteItem = (id, ok, fail) => {
axios.delete(`/item/${id}`)
.then(res => ok())
- .catch((err) => fail())
+ .catch(err => fail(err))
}
export const getAllItems = (ok, fail) => {
axios.get("/item/all")
.then(res => ok(res.data))
- .catch(err => fail())
+ .catch(err => fail(err))
}
export const editItem = (item, ok, fail) => {
axios.put(`/item/${item.Id}`, item)
.then(res => ok())
- .catch(err => fail());
+ .catch(err => fail(err));
}
export const getDiscountValue = (item) =>
diff --git a/src/classes/notifications.js b/src/classes/notifications.js
new file mode 100644
index 0000000..5ffdec8
--- /dev/null
+++ b/src/classes/notifications.js
@@ -0,0 +1,31 @@
+/* OpenBills-web - Web based libre billing software
+ * Copyright (C) 2022 Vidhu Kant Sharma <vidhukant@vidhukant.xyz>
+
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+// TODO: load defaults from config
+export function notificationConfig(type, duration=3000) {
+ return {
+ type: type,
+ insert: "top",
+ container: "top-right",
+ animationIn: ["animate__animated", "animate__fadeIn"],
+ animationOut: ["animate__animated", "animate__fadeOut"],
+ dismiss: {
+ duration: duration,
+ onScreen: true
+ }
+ };
+}