v-sistec-features 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+
2
+ // store.ts
3
+ import { useToast } from "vue-toastification";
4
+ import ToastComponent from "./components/ToastComponent.vue";
5
+ import { defineStore } from "pinia";
6
+
7
+ /**
8
+ * Define os tipos de toast aceitos.
9
+ * 1 = success
10
+ * 2 = error
11
+ * 3 = info
12
+ */
13
+ type ToastStoreType = 1 | 2 | 3;
14
+
15
+ export const useToastStore = defineStore("toastStore", () => {
16
+ const showToast = (
17
+ title: string,
18
+ body: string,
19
+ type: ToastStoreType
20
+ ) => {
21
+ const toast = useToast();
22
+
23
+ const content = {
24
+ component: ToastComponent,
25
+ props: {
26
+ content: {
27
+ title: title,
28
+ body: body,
29
+ },
30
+ },
31
+ };
32
+ switch (type) {
33
+ case 1:
34
+ toast.success(content, {});
35
+ break;
36
+ case 2:
37
+ toast.error(content, {
38
+ timeout: 7000,
39
+ });
40
+ break;
41
+ case 3:
42
+ toast.info(content, {});
43
+ break;
44
+ default:
45
+ console.info("Tipo de toast não encontrado");
46
+ break;
47
+ }
48
+ };
49
+
50
+ return {
51
+ showToast,
52
+ };
53
+ });