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 | 540x 540x 540x 540x | import { MCCType } from "@hooks/acquirer-api/MCCType";
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { SettingsState } from "./types";
interface AppState {
acquirerSettings: SettingsState;
}
const initialState: SettingsState = {
category_codes: [],
};
const acquirerSettingsSlice = createSlice({
name: "acquirerSettings",
initialState,
reducers: {
setCategoryCodes: (
state: SettingsState,
action: PayloadAction<MCCType[]>,
) => {
const existingCodes = state.category_codes;
const newCodes = action.payload.filter(
(code) => !existingCodes.includes(code),
);
state.category_codes = [...newCodes];
},
setCategoryCode: (state: SettingsState, action: PayloadAction<MCCType>) => {
state.category_codes = [...state.category_codes, action.payload];
},
},
});
export const { setCategoryCodes, setCategoryCode } =
acquirerSettingsSlice.actions;
export const selectCategoryCodes = (state: AppState): MCCType[] =>
state.acquirerSettings.category_codes;
export default acquirerSettingsSlice.reducer;
|