"use client";
import { useAtom } from "jotai";
import { stepAtom, maxStep } from "@/components/state/autionAtoms";

export function useStepper() {
  const [step, setStep] = useAtom(stepAtom);

  function goto(n: number) {
    setStep(Math.max(1, Math.min(maxStep, n)));
  }
  function next() {
    goto(step + 1);
  }
  function prev() {
    goto(step - 1);
  }
  return { step, goto, next, prev, maxStep };
}
