import { createSlice } from '@reduxjs/toolkit';
import { aGetInitSuccess, aLocationChange } from './bonus';
/**
* @namespace reducer/settingsReducer
*/
const initialState = {
marketsSettings: null,
roundSpecialShopSettings: null,
goalGaloreMarginsSettings: null,
marketsShopSettings: null,
goalGaloreSettings: null,
roundSpecialMarginsSettings: null,
leaguesSettings: null,
gamesSettings: null,
gamesShopSettings: null,
roundDurationSettings: undefined,
oddsTemplatesFiles: null,
downloadedFile: null,
oddsTemplate: null,
oddsShopTemplate: null,
templateExelList: null,
oddsTemplatesPageToken: '',
oddsTemplateLastId: '',
oddsShopTemplateLastId: '',
statsTemplateLastId: '',
statsTemplatesPageToken: '',
videoActionList: null,
saveGameDurationSuccess: false,
};
const settingsSlice = createSlice({
name: 'settings',
initialState,
reducers: {
aGetMarketsMarginsSettingsSuccess: (state, action) => {
state.marketsMarginsSettings = action.payload.marketsMarginsSettings;
},
aGetGoalGaloreMarginsSuccess: (state, action) => {
state.goalGaloreMarginsSettings = action.payload.goalGaloreMarginsSettings;
},
aGetRoundSpecialMarginsSuccess: (state, action) => {
state.roundSpecialMarginsSettings = action.payload.roundSpecialMarginsSettings;
},
aGetMarketsSettingsSuccess: (state, action) => {
state.marketsSettings = action.payload.marketsSettings;
},
aGetGoalGaloreSuccess: (state, action) => {
state.goalGaloreSettings = action.payload.goalGaloreSettings;
},
aGetRoundSpecialShopSettingsSuccess: (state, action) => {
state.roundSpecialShopSettings = action.payload.roundSpecialShopSettings;
},
aGetMarketsShopSettingsSuccess: (state, action) => {
state.marketsShopSettings = action.payload.marketsShopSettings;
},
aGetLeaguesSettingsSuccess: (state, action) => {
state.leaguesSettings = action.payload.leaguesSettings;
},
aGetLeaguesSettings: (state) => {
state.leaguesSettings = null;
},
aGetMarketsSettings: (state) => {
state.marketsSettings = null;
},
aGetRoundSpecialShopSettings: (state) => {
state.roundSpecialShopSettings = null;
},
aGetMarketsShopSettings: (state) => {
state.marketsShopSettings = null;
},
aGetGoalGaloreSettings: (state) => {
state.goalGaloreSettings = null;
},
aGetGamesSettingsSuccess: (state, action) => {
state.gamesSettings = action.payload.gamesSettings;
},
aGetGamesShopSettingsSuccess: (state, action) => {
state.gamesShopSettings = action.payload.gamesShopSettings;
},
aGetGamesSettings: (state) => {
state.gamesSettings = null;
},
aGetGamesShopSettings: (state) => {
state.gamesShopSettings = null;
},
aOddsTemplatesFilesSuccess: (state, action) => {
state.oddsTemplatesFiles = action.payload.oddsTemplatesFiles;
state.oddsTemplatesPageToken = action.payload.oddsTemplatesPageToken;
},
aStatsTemplatesFilesSuccess: (state, action) => {
state.statsTemplatesFiles = action.payload.statsTemplatesFiles;
state.statsTemplatesPageToken = action.payload.statsTemplatesPageToken;
},
aDownloadOddsTemplatesFileSuccess: (state, action) => {
state.downloadedFile = action.payload.downloadedFile;
},
aOddsTemplateSuccess: (state, action) => {
state.oddsTemplate = action.payload.oddsTemplate;
state.oddsTemplateLastId = action.payload.oddsTemplateLastId;
},
aGetStatsTemplateSuccess: (state, action) => {
state.statsTemplate = action.payload.statsTemplate;
state.statsTemplateLastId = action.payload.statsTemplateLastId;
},
aClearStatsTemplateMobile: (state) => {
state.statsTemplate = [];
state.statsTemplateLastId = '';
},
aOddsShopTemplateSuccess: (state, action) => {
state.oddsShopTemplate = action.payload.oddsShopTemplate;
state.oddsShopTemplateLastId = action.payload.oddsShopTemplateLastId;
},
aGetTemplateExelListSuccess: (state, action) => {
state.templateExelList = action.payload.templateExelList;
},
aForceTurboSuccess: (state, action) => {
state.oddsTemplate = action.payload.oddsTemplate;
},
aGetVideoActionSuccess: (state, action) => {
state.videoActionList = action.payload.videoActionList;
},
aGetRoundDurationSettings: () => {},
aGetRoundDurationSettingsSuccess: (state, action) => {
state.roundDurationSettings = action.payload.roundDurationSettings;
},
aGetRoundDurationSettingsFail: (state) => {
state.roundDurationSettings = state.roundDurationSettings ? state.roundDurationSettings : null;
},
aSaveMatchRoundDurationSettings: (state) => {
state.saveGameDurationSuccess = false;
state.saveGameDurationError = '';
},
aSaveMatchRoundDurationSettingsFail: () => {},
aSaveMatchRoundDurationSettingsSuccess: (state, action) => {
state.roundDurationSettings = action.payload.roundDurationSettings;
state.saveGameDurationSuccess = true;
},
},
extraReducers: (builder) => {
builder.addCase(aGetInitSuccess, (state, action) => {
state.cashoutNumberofSlots = action.payload.selects.cashoutNumberofSlots;
state.videoActionType = action.payload.selects.videoActionType;
state.videoActionStatus = action.payload.selects.videoActionStatus;
});
builder.addCase(aLocationChange, (state) => {
state.oddsTemplatesFiles = null;
state.oddsTemplate = null;
state.oddsShopTemplate = null;
state.oddsTemplatesPageToken = '';
state.oddsTemplateLastId = '';
state.oddsShopTemplateLastId = '';
});
},
});
export default settingsSlice.reducer;
export const {
aGetMarketsMarginsSettingsSuccess,
aGetRoundSpecialMarginsSuccess,
aGetGoalGaloreMarginsSuccess,
aGetMarketsSettingsSuccess,
aGetGoalGaloreSuccess,
aGetRoundSpecialShopSettingsSuccess,
aGetMarketsShopSettingsSuccess,
aGetLeaguesSettingsSuccess,
aGetLeaguesSettings,
aGetMarketsSettings,
aGetRoundSpecialShopSettings,
aGetMarketsShopSettings,
aGetGamesSettingsSuccess,
aGetGamesShopSettingsSuccess,
aGetGamesSettings,
aGetGamesShopSettings,
aGetGoalGaloreSettings,
aOddsTemplatesFilesSuccess,
aStatsTemplatesFilesSuccess,
aDownloadOddsTemplatesFileSuccess,
aOddsTemplateSuccess,
aGetStatsTemplateSuccess,
aClearStatsTemplateMobile,
aOddsShopTemplateSuccess,
aGetTemplateExelListSuccess,
aForceTurboSuccess,
aGetVideoActionSuccess,
aGetRoundDurationSettingsSuccess,
aGetRoundDurationSettingsFail,
aGetRoundDurationSettings,
aSaveMatchRoundDurationSettings,
aSaveMatchRoundDurationSettingsFail,
aSaveMatchRoundDurationSettingsSuccess,
} = settingsSlice.actions;