Squashed commit of the following: commit 3d633703fc60e42d26ccf3b5697370c49ffa1a82 Merge: 09119e2ef082312eAuthor: Artem Krisanov <a.krisanov@adguard.com> Date: Thu Apr 13 10:58:31 2023 +0300 Merge branch 'master' of ssh://bit.adguard.com:7999/dns/adguard-home into AG-20835 commit 09119e2ec6f3116986d3ddeb48ee2eb18c1cd9d7 Merge: 085bbb5c67d8b7dfAuthor: Artem Krisanov <a.krisanov@adguard.com> Date: Wed Apr 12 14:55:22 2023 +0300 Merge branch 'master' of ssh://bit.adguard.com:7999/dns/adguard-home into AG-20835 commit 085bbb5cabb14d5388e45ab2022840d44ae42874 Author: Artem Krisanov <a.krisanov@adguard.com> Date: Wed Apr 12 14:12:28 2023 +0300 Deleted unused methods and variable.
51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
import { createAction } from 'redux-actions';
|
|
import apiClient from '../api/Api';
|
|
import { addErrorToast, addSuccessToast } from './toasts';
|
|
|
|
export const getBlockedServicesRequest = createAction('GET_BLOCKED_SERVICES_REQUEST');
|
|
export const getBlockedServicesFailure = createAction('GET_BLOCKED_SERVICES_FAILURE');
|
|
export const getBlockedServicesSuccess = createAction('GET_BLOCKED_SERVICES_SUCCESS');
|
|
|
|
export const getBlockedServices = () => async (dispatch) => {
|
|
dispatch(getBlockedServicesRequest());
|
|
try {
|
|
const data = await apiClient.getBlockedServices();
|
|
dispatch(getBlockedServicesSuccess(data));
|
|
} catch (error) {
|
|
dispatch(addErrorToast({ error }));
|
|
dispatch(getBlockedServicesFailure());
|
|
}
|
|
};
|
|
|
|
export const getAllBlockedServicesRequest = createAction('GET_ALL_BLOCKED_SERVICES_REQUEST');
|
|
export const getAllBlockedServicesFailure = createAction('GET_ALL_BLOCKED_SERVICES_FAILURE');
|
|
export const getAllBlockedServicesSuccess = createAction('GET_ALL_BLOCKED_SERVICES_SUCCESS');
|
|
|
|
export const getAllBlockedServices = () => async (dispatch) => {
|
|
dispatch(getAllBlockedServicesRequest());
|
|
try {
|
|
const data = await apiClient.getAllBlockedServices();
|
|
dispatch(getAllBlockedServicesSuccess(data));
|
|
} catch (error) {
|
|
dispatch(addErrorToast({ error }));
|
|
dispatch(getAllBlockedServicesFailure());
|
|
}
|
|
};
|
|
|
|
export const setBlockedServicesRequest = createAction('SET_BLOCKED_SERVICES_REQUEST');
|
|
export const setBlockedServicesFailure = createAction('SET_BLOCKED_SERVICES_FAILURE');
|
|
export const setBlockedServicesSuccess = createAction('SET_BLOCKED_SERVICES_SUCCESS');
|
|
|
|
export const setBlockedServices = (values) => async (dispatch) => {
|
|
dispatch(setBlockedServicesRequest());
|
|
try {
|
|
await apiClient.setBlockedServices(values);
|
|
dispatch(setBlockedServicesSuccess());
|
|
dispatch(getBlockedServices());
|
|
dispatch(addSuccessToast('blocked_services_saved'));
|
|
} catch (error) {
|
|
dispatch(addErrorToast({ error }));
|
|
dispatch(setBlockedServicesFailure());
|
|
}
|
|
};
|