mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- 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.
55 lines
1.3 KiB
TypeScript
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,
|
|
};
|
|
}
|