@@ -95,39 +95,6 @@ const KeywordManager = (props) => {
9595 dispatch ( getKeywordIndexes ( ) ) ;
9696 } , [ dispatch , options ] ) ;
9797
98- useEffect ( ( ) => {
99- const actionType = keywords . type ;
100-
101- const isUpdate = actionType . startsWith ( 'UPDATE_' ) ;
102- const isDelete = actionType . startsWith ( 'DELETE_' ) ;
103- const isSuccess = actionType . endsWith ( '_SUCCESS' ) ;
104- const isFail = actionType . endsWith ( '_FAIL' ) ;
105-
106- if ( ! isUpdate && ! isDelete ) return ;
107-
108- if ( isUpdate ) {
109- isSuccess &&
110- toast . success (
111- < Toast title = "Update Success" content = "Updated successfully!" /> ,
112- ) ;
113- isFail &&
114- toast . error (
115- < Toast error title = "Update Failed" content = "Could not update." /> ,
116- ) ;
117- }
118-
119- if ( isDelete ) {
120- isSuccess &&
121- toast . success (
122- < Toast title = "Delete Success" content = "Deleted successfully!" /> ,
123- ) ;
124- isFail &&
125- toast . error (
126- < Toast error title = "Delete Failed" content = "Could not delete." /> ,
127- ) ;
128- }
129- } , [ keywords ] ) ;
130-
13198 const columns = [
13299 {
133100 id : 'keyword' ,
@@ -204,6 +171,13 @@ const KeywordManager = (props) => {
204171 setIsLoading ( true ) ;
205172 try {
206173 await dispatch ( deleteKeywords ( { items : kw , indexName : keywordIndex } ) ) ;
174+ toast . success (
175+ < Toast title = "Delete Success" content = "Deleted successfully!" /> ,
176+ ) ;
177+ } catch ( error ) {
178+ toast . error (
179+ < Toast error title = "Delete Failed" content = "Could not delete." /> ,
180+ ) ;
207181 } finally {
208182 setIsLoading ( false ) ;
209183 }
@@ -220,6 +194,13 @@ const KeywordManager = (props) => {
220194 indexName : keywordIndex ,
221195 } ) ,
222196 ) ;
197+ toast . success (
198+ < Toast title = "Update Success" content = "Updated successfully!" /> ,
199+ ) ;
200+ } catch ( error ) {
201+ toast . error (
202+ < Toast error title = "Update Failed" content = "Could not update." /> ,
203+ ) ;
223204 } finally {
224205 setIsLoading ( false ) ;
225206 }
0 commit comments