File size: 703 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { combineReducers } from '@wordpress/data';
import { SiteIntent } from '../onboard/constants';
import { StepperInternalAction } from './actions';
import type { Reducer } from 'redux';

type StepData = Record< string, unknown > & {
	path: string;
	intent: SiteIntent;
	previousStep: string;
	nextStep?: string;
};

export const stepData: Reducer< StepData | null, StepperInternalAction > = (
	state = null,
	action
) => {
	if ( action.type === 'SET_STEP_DATA' ) {
		return action.data;
	}
	if ( action.type === 'CLEAR_STEP_DATA' ) {
		return null;
	}
	return state;
};

const reducer = combineReducers( {
	stepData,
} );

export type State = ReturnType< typeof reducer >;

export default reducer;