All files / src/components/form/MultiStepForm MultiStepForm.tsx

0% Statements 0/2
0% Branches 0/2
0% Functions 0/1
0% Lines 0/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import React, { useState } from "react";
import { Progress } from "@/components/ui/progress";
import { ChevronRight } from "lucide-react";
import { ChevronLeft } from "lucide-react";
import { Button } from "@/components/ui/button";
 
export interface MultiStepFormInterface {
  idx: number;
  //   setIdx: (idx: number) => void;
  steps: React.ReactNode[];
}
 
export const MultiStepForm: React.FC<MultiStepFormInterface> = (
  props: MultiStepFormInterface
) => {
  //   const [idx, setIdx] = useState(0);
  //   const handleNext = () => setIdx((prev) => prev + 1);
  //   const handleBack = () => setIdx((prev) => prev - 1);
  //   console.log(props.idx);
  return (
    <div className="flex flex-col gap-8">
      <Progress
        value={(100 * (props.idx + 1)) / props.steps.length}
        className="h-2"
      />
      <p>
        Step {props.idx + 1}/{props.steps.length}
      </p>
      {props.steps[props.idx]}
 
      <br></br>
      {props.idx + 1 === props.steps.length && (
        <>
          <Button type="submit">Submit</Button>
          <br></br>
        </>
      )}
    </div>
  );
};