Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { createSlice } from "@reduxjs/toolkit";
import capitalizeFirstLetter from "../../../utils/common/capitalize";
import { RootState } from "../..";
type InitialStateType = {
allIntegrations: any;
currentConnector: any;
keyOptions: any;
vpcConnectors: any;
agentProxy: any;
testData: any;
};
const initialState: InitialStateType = {
allIntegrations: [],
currentConnector: {},
keyOptions: [],
vpcConnectors: [],
agentProxy: {},
testData: {},
};
const integrationsSlice = createSlice({
name: "integrations",
initialState,
reducers: {
setIntegrations: (state, { payload }) => {
state.allIntegrations = payload;
},
setVpcConnectors: (state, { payload }) => {
state.vpcConnectors = payload;
},
setAgentProxy: (state, { payload }) => {
state.agentProxy = payload;
},
setCurrentConnector: (state, { payload }) => {
const connector = state.allIntegrations.find(
(el) => el.enum.toLowerCase() === payload,
);
Iif (connector) {
state.currentConnector = {
...connector,
displayTitle: connector.title
.split(" ")
.map((e) => capitalizeFirstLetter(e.toLowerCase()))
.join(" "),
};
}
},
setConnector(state, { payload }) {
state.currentConnector = payload;
},
setKeysOptions: (state, { payload }) => {
state.keyOptions = payload;
payload?.forEach((el) => {
state.currentConnector[el.key_type] = "";
});
},
setAgentKeyOptions: (state, { payload }) => {
state.agentProxy.keyOptions = payload;
payload.forEach((el) => {
state.agentProxy[el.key_type] = "";
});
},
setKey(state, { payload }) {
state.currentConnector[payload.key] = payload.value;
},
setAgentProxyKey(state, { payload }) {
state.agentProxy[payload.key] = payload.value;
},
setTestConnectorData(state, { payload }) {
state.testData = payload;
},
resetIntegrationState(state) {
state.testData = {};
state.currentConnector = {};
state.agentProxy = {};
state.keyOptions = {};
state.vpcConnectors = {};
},
},
});
export const {
setIntegrations,
setVpcConnectors,
setAgentProxy,
setCurrentConnector,
setConnector,
setKeysOptions,
setAgentKeyOptions,
setKey,
setAgentProxyKey,
setTestConnectorData,
resetIntegrationState,
} = integrationsSlice.actions;
export default integrationsSlice.reducer;
export const integrationsSelector = (state: RootState) =>
state.integrations.allIntegrations;
export const connectorSelector = (state: RootState) =>
state.integrations.currentConnector;
export const keyOptionsSelector = (state: RootState) =>
state.integrations.keyOptions;
export const agentProxySelector = (state: RootState) =>
state.integrations.agentProxy;
export const testDataSelector = (state: RootState) =>
state.integrations.testData;
|