turash/bugulma/frontend/hooks/useWizardSteps.ts
Damir Mukimov 6347f42e20
Consolidate repositories: Remove nested frontend .git and merge into main repository
- Remove nested git repository from bugulma/frontend/.git
- Add all frontend files to main repository tracking
- Convert from separate frontend/backend repos to unified monorepo
- Preserve all frontend code and development history as tracked files
- Eliminate nested repository complexity for simpler development workflow

This creates a proper monorepo structure with frontend and backend
coexisting in the same repository for easier development and deployment.
2025-11-25 06:02:57 +01:00

55 lines
1.3 KiB
TypeScript

import { useCallback, useState } from 'react';
interface UseWizardStepsOptions {
totalSteps: number;
initialStep?: number;
onStepChange?: (step: number) => void;
onComplete?: () => void;
}
/**
* Hook for managing wizard/multi-step processes
*/
export function useWizardSteps({
totalSteps,
initialStep = 1,
onStepChange,
onComplete,
}: UseWizardStepsOptions) {
const [currentStep, setCurrentStep] = useState(initialStep);
const goToStep = useCallback((step: number) => {
const clampedStep = Math.max(1, Math.min(totalSteps, step));
setCurrentStep(clampedStep);
onStepChange?.(clampedStep);
}, [totalSteps, onStepChange]);
const nextStep = useCallback(() => {
if (currentStep < totalSteps) {
goToStep(currentStep + 1);
} else {
onComplete?.();
}
}, [currentStep, totalSteps, goToStep, onComplete]);
const prevStep = useCallback(() => {
goToStep(currentStep - 1);
}, [currentStep, goToStep]);
const reset = useCallback(() => {
setCurrentStep(initialStep);
}, [initialStep]);
return {
currentStep,
totalSteps,
isFirstStep: currentStep === 1,
isLastStep: currentStep === totalSteps,
goToStep,
nextStep,
prevStep,
reset,
progress: (currentStep / totalSteps) * 100,
};
}