Дозаливка
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { ALLOW_RENDER, SET_STEP, CLEAN_STATE } from './types.js';
|
||||
|
||||
/**
|
||||
* @param {{ currentStep: Number, isAllowRender: boolean}} state
|
||||
*/
|
||||
|
||||
export const rootReducer = (state, action) => {
|
||||
const { type, payload } = action;
|
||||
|
||||
switch (type) {
|
||||
case ALLOW_RENDER:
|
||||
return { ...state, isAllowRender: true };
|
||||
|
||||
case SET_STEP:
|
||||
setStepToLocalStorage(payload);
|
||||
return { ...state, currentStep: payload };
|
||||
|
||||
case CLEAN_STATE:
|
||||
setStepToLocalStorage(1);
|
||||
return { ...state, isAllowRender: false, currentStep: 1 };
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
function setStepToLocalStorage(nextStep) {
|
||||
localStorage.setItem('trainingModalCurrentStep', nextStep);
|
||||
}
|
||||
Reference in New Issue
Block a user