mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
49309b43d3
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com> Co-authored-by: Alejandro Bailo <59607668+alejandrobailo@users.noreply.github.com>
33 lines
893 B
TypeScript
33 lines
893 B
TypeScript
import {
|
|
getOrderedFlows,
|
|
type OnboardingFlow,
|
|
onboardingFlows,
|
|
} from "@/lib/onboarding";
|
|
|
|
// Framework-free projection of the active sequence position — unit-testable without React.
|
|
export interface SequenceProgress {
|
|
index: number; // 0-based
|
|
total: number;
|
|
flow: OnboardingFlow;
|
|
nextFlow: OnboardingFlow | null; // null when on the last step
|
|
}
|
|
|
|
// Returns null when `currentFlowId` is absent or not in the registry.
|
|
export function getSequenceProgress(
|
|
currentFlowId: string | null,
|
|
flows: readonly OnboardingFlow[] = onboardingFlows,
|
|
): SequenceProgress | null {
|
|
if (!currentFlowId) return null;
|
|
|
|
const ordered = getOrderedFlows(flows);
|
|
const index = ordered.findIndex((flow) => flow.id === currentFlowId);
|
|
if (index < 0) return null;
|
|
|
|
return {
|
|
index,
|
|
total: ordered.length,
|
|
flow: ordered[index],
|
|
nextFlow: ordered[index + 1] ?? null,
|
|
};
|
|
}
|