2025-04-10 11:37:27 +03:00

20 lines
658 B
TypeScript

'use client';
import { stepsReducer } from './reducer';
import { type Steps } from './types';
import { useReducer, useState } from 'react';
export function useEntityState() {
const [entityId, setEntityId] = useState<null | string>(null);
return { entityId, setEntityId };
}
export function useStep() {
const [state, dispatch] = useReducer(stepsReducer, { step: 'master-select' });
const setStep = (payload: Steps) => dispatch({ payload, type: 'SET_STEP' });
const nextStep = () => dispatch({ type: 'NEXT_STEP' });
const previousStep = () => dispatch({ type: 'PREV_STEP' });
return { nextStep, prevStep: previousStep, setStep, ...state };
}