diff --git a/smart-frontend/app/src/store/adh/rules/rulesActionsSlice.ts b/smart-frontend/app/src/store/adh/rules/rulesActionsSlice.ts index 5bdca029d4..8cca2c256f 100644 --- a/smart-frontend/app/src/store/adh/rules/rulesActionsSlice.ts +++ b/smart-frontend/app/src/store/adh/rules/rulesActionsSlice.ts @@ -77,7 +77,9 @@ const stopRule = createAsyncThunk('adh/rulesActions/stopRule', async (ruleId: nu } }); -const withFullUpdate = (name: string, dialogAction: ReturnType) => { +type DialogActionType = ReturnType; + +const withFullUpdate = (name: string, dialogAction: DialogActionType) => { return createAsyncThunk(name, async (payload: unknown, thunkAPI) => { await thunkAPI.dispatch(dialogAction(payload)).unwrap(); thunkAPI.dispatch(getRulesMetaInfo()); @@ -85,32 +87,20 @@ const withFullUpdate = (name: string, dialogAction: ReturnType) => { +const withMetaInfoUpdate = (name: string, dialogAction: DialogActionType) => { return createAsyncThunk(name, async (payload: unknown, thunkAPI) => { await thunkAPI.dispatch(dialogAction(payload)).unwrap(); thunkAPI.dispatch(getRulesMetaInfo()); }); }; -const createRuleWithUpdate = withFullUpdate( - 'adh/rulesActions/createRuleWithUpdate', - createRule as ReturnType, -); - -const deleteRuleWithUpdate = withFullUpdate( - 'adh/rulesActions/deleteRuleWithUpdate', - deleteRule as ReturnType, -); - -const startRuleWithUpdate = withMetaInfoUpdate( - 'adh/rulesActions/startRuleWithUpdate', - startRule as ReturnType, -); - -const stopRuleWithUpdate = withMetaInfoUpdate( - 'adh/rulesActions/stopRuleWithUpdate', - stopRule as ReturnType, -); +const createRuleWithUpdate = withFullUpdate('adh/rulesActions/createRuleWithUpdate', createRule as DialogActionType); + +const deleteRuleWithUpdate = withFullUpdate('adh/rulesActions/deleteRuleWithUpdate', deleteRule as DialogActionType); + +const startRuleWithUpdate = withMetaInfoUpdate('adh/rulesActions/startRuleWithUpdate', startRule as DialogActionType); + +const stopRuleWithUpdate = withMetaInfoUpdate('adh/rulesActions/stopRuleWithUpdate', stopRule as DialogActionType); interface AdhRulesActions extends ModalState { startDialog: {