Skip to content

Commit f8677b4

Browse files
committed
77
1 parent ae2d355 commit f8677b4

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

db.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@
104104
"completed": false,
105105
"body": "asdf",
106106
"id": 25
107+
},
108+
{
109+
"subject": "a",
110+
"completed": false,
111+
"body": "a",
112+
"id": 26
113+
},
114+
{
115+
"subject": "df",
116+
"completed": false,
117+
"body": "df",
118+
"id": 27
107119
}
108120
]
109121
}

src/store/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,40 @@ export default createStore({
66
toastAlertType: '',
77
showToast: false,
88
timeout: null
9+
},
10+
mutations: {
11+
UPDATE_TOAST_MESSAGE (state, payload) {
12+
state.toastMessage = payload;
13+
},
14+
UPDATE_TOAST_ALERT_TYPE (state, payload) {
15+
state.toastAlertType = payload;
16+
},
17+
UPDATE_TOAST_STATUS (state, payload) {
18+
state.showToast = payload;
19+
},
20+
UPDATE_TOAST_TIMEOUT (state, payload) {
21+
state.timeout = payload;
22+
}
23+
},
24+
actions: {
25+
triggerToast({ commit }, message, type = 'success') {
26+
// toastMessage.value = message;
27+
commit('UPDATE_TOAST_MESSAGE', message)
28+
// toastAlertType.value = type;
29+
commit('UPDATE_TOAST_ALERT_TYPE', type)
30+
// showToast.value = true;
31+
commit('UPDATE_TOAST_STATUS', true)
32+
33+
const timeout = setTimeout(() => {
34+
// toastMessage.value = '';
35+
commit('UPDATE_TOAST_MESSAGE', '')
36+
// toastAlertType.value = '';
37+
commit('UPDATE_TOAST_ALERT_TYPE', '')
38+
// showToast.value = false;
39+
commit('UPDATE_TOAST_STATUS', false)
40+
}, 5000)
41+
42+
commit('UPDATE_TOAST_TIMEOUT', timeout);
43+
}
944
}
1045
});

0 commit comments

Comments
 (0)