File tree Expand file tree Collapse file tree 4 files changed +36
-28
lines changed Expand file tree Collapse file tree 4 files changed +36
-28
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ import { storeToRefs } from 'pinia';
28
28
import { use {{titleUcFirst }}DeleteStore } from ' src/stores/{{lc}}/delete' ;
29
29
import { onBeforeUnmount } from ' vue' ;
30
30
import { {{titleUcFirst }} } from ' src/types/{{lc}}' ;
31
- import { displaySuccessNotification } from ' src/utils /notifications' ;
31
+ import { useNotifications } from ' src/composables /notifications' ;
32
32
import { useI18n } from ' vue-i18n' ;
33
33
import { useBreadcrumb } from ' src/composables/breadcrumb' ;
34
34
import { useWatchErrors } from ' src/composables/errors' ;
@@ -38,6 +38,7 @@ const { t } = useI18n();
38
38
const route = useRoute ();
39
39
const router = useRouter ();
40
40
const breadcrumb = useBreadcrumb ();
41
+ const { displaySuccessNotification } = useNotifications ();
41
42
42
43
const {{lc}}UpdateStore = use {{titleUcFirst }}UpdateStore ();
43
44
const {
@@ -78,7 +79,7 @@ async function submitForm(item: {{titleUcFirst}}) {
78
79
return ;
79
80
}
80
81
81
- displaySuccessNotification (` ${item [' @id' ]} ${t (' updated' )}. ` , t ( ' close ' ) );
82
+ displaySuccessNotification (` ${item [' @id' ]} ${t (' updated' )}. ` );
82
83
}
83
84
84
85
useWatchErrors ([error , deleteError ]);
Original file line number Diff line number Diff line change 1
1
import { Ref , watch } from 'vue' ;
2
- import { displayErrorNotification } from 'src/utils/notifications' ;
3
- import { useI18n } from 'vue-i18n' ;
2
+ import { useNotifications } from './notifications' ;
4
3
5
4
export function useWatchErrors (
6
5
errors : ( Ref < string | undefined > | undefined ) [ ]
7
6
) {
8
- const { t } = useI18n ( ) ;
7
+ const { displayErrorNotification } = useNotifications ( ) ;
9
8
10
9
watch ( errors , ( newErrors ) => {
11
10
newErrors . forEach ( ( newError ) => {
12
11
if ( ! newError ?. value ) {
13
12
return ;
14
13
}
15
14
16
- displayErrorNotification ( newError . value , t ( 'close' ) ) ;
15
+ displayErrorNotification ( newError . value ) ;
17
16
} ) ;
18
17
} ) ;
19
18
}
Original file line number Diff line number Diff line change
1
+ import { useQuasar } from 'quasar' ;
2
+ import { useI18n } from 'vue-i18n' ;
3
+
4
+ export function useNotifications ( ) {
5
+ const $q = useQuasar ( ) ;
6
+ const { t } = useI18n ( ) ;
7
+
8
+ const displayErrorNotification = ( message : string ) => {
9
+ $q . notify ( {
10
+ message,
11
+ color : 'red' ,
12
+ icon : 'error' ,
13
+ closeBtn : t ( 'close' ) ,
14
+ } ) ;
15
+ } ;
16
+
17
+ const displaySuccessNotification = ( message : string ) => {
18
+ $q . notify ( {
19
+ message,
20
+ color : 'green' ,
21
+ icon : 'tag_faces' ,
22
+ closeBtn : t ( 'close' ) ,
23
+ } ) ;
24
+ } ;
25
+
26
+ return {
27
+ displayErrorNotification,
28
+ displaySuccessNotification,
29
+ } ;
30
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments