File size: 790 Bytes
3201ca6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
export const ONBOARDING_PREVIEW_STEP_QUERY_PARAM = "previewOnboardingStep";

const MAX_ONBOARDING_STEP = 3;

/** Reads `?previewOnboardingStep=<0-3>` for dev/design review of a single slide. */
export function readOnboardingPreviewStep(
  search = typeof window !== "undefined" ? window.location.search : "",
): number | null {
  const raw = new URLSearchParams(search).get(
    ONBOARDING_PREVIEW_STEP_QUERY_PARAM,
  );
  if (raw == null) return null;

  const step = Number.parseInt(raw, 10);
  if (!Number.isFinite(step) || step < 0 || step > MAX_ONBOARDING_STEP) {
    return null;
  }
  return step;
}

export function isOnboardingPreviewActive(
  search = typeof window !== "undefined" ? window.location.search : "",
): boolean {
  return readOnboardingPreviewStep(search) != null;
}