PromucFlow_constructor/app/client/src/reducers/uiReducers/tourReducer.ts
Valera Melnikov 9eac55a380
chore: add consistent-type-definitions rule (#27907)
## Description
Add consistent-type-definitions rule
2023-10-11 10:35:24 +03:00

42 lines
1.1 KiB
TypeScript

import { createReducer } from "utils/ReducerUtils";
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import type { TourType } from "entities/Tour";
const initialState: TourReducerState = {
isTourInProgress: false,
activeTourIndex: -1,
activeTourType: undefined,
};
const tourReducer = createReducer(initialState, {
[ReduxActionTypes.SET_ACTIVE_TOUR]: (
state: TourReducerState,
action: ReduxAction<TourType>,
) => ({
...state,
activeTourType: action.payload,
activeTourIndex: 0,
}),
[ReduxActionTypes.RESET_ACTIVE_TOUR]: (state: TourReducerState) => ({
...state,
activeTourType: undefined,
activeTourIndex: -1,
}),
[ReduxActionTypes.SET_ACTIVE_TOUR_INDEX]: (
state: TourReducerState,
action: ReduxAction<number>,
) => ({
...state,
activeTourIndex: action.payload,
}),
});
export interface TourReducerState {
isTourInProgress: boolean;
activeTourType?: TourType;
activeTourIndex: number;
}
export default tourReducer;