Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying total number of steps #35

Open
nickcanarelli opened this issue Sep 11, 2020 · 0 comments
Open

Displaying total number of steps #35

nickcanarelli opened this issue Sep 11, 2020 · 0 comments

Comments

@nickcanarelli
Copy link

nickcanarelli commented Sep 11, 2020

I'm having difficulties displaying the current step count with the total number of steps.

It says Step 1 of 1 for each form page when there are 3 total steps so far. It should say Step 1 of 3, Step 2 of 3, etc... Any help is appreciated.

function FormWrapper({ children, isLastStep, status, goToPreviousStep, canGoBack, actionLabel }) {
  const [stepNumber, setStepNumber] = useState(0);
  const steps = Children.toArray(children);

  const step = steps[stepNumber];
  const totalSteps = steps.length;

  return (
    <>
      <p>
        Step {stepNumber + 1} of {totalSteps}
      </p>
      {status && (
        <div>
          {status.message}
          <hr />
        </div>
      )}
      {children}
      <Row>
        <Col lg={{ span: 9, offset: 3 }} className='onboard__actions'>
          <button
            type='button'
            onClick={goToPreviousStep}
            disabled={!canGoBack}
            className='onboard_btn onboard_btn-secondary'
          >
            Previous
          </button>
          <button type='submit' className='onboard_btn onboard_btn-primary'>
            {actionLabel || (isLastStep ? 'Submit' : 'Next step')}
          </button>
        </Col>
      </Row>
    </>
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant