# Code

## Props

<table><thead><tr><th width="298">Props</th><th width="359.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td><em>(WizardStep)</em></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>commland</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>show</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>title</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>type</td><td>string<br>(Initial, Edit)</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationLoading</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationValidation</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationStepTitle</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationContentTitle</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationContentDescription</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationButton</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationError</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationErrorTitle</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationErrorMessage</td><td>boolean</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>confirmationDismissAction</td><td>Function</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>nextButton</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>previousButton</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>cancelButton</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>onCancel</td><td>Function Event</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>onConfirm</td><td>Function Event</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

{% hint style="info" %}
commland prop is used to adjust the Alert component to the Commland UI-Shell automatically.
{% endhint %}

### Where to Insert This Component in Comm.land?

This component should overlay all the content inside the application. To keep a better order and avoiding problems with UI Shell, it is recommended inserting this component outside and next to the AppPage component. If it is inserted inside the AppPageContent component, the modal is not going to render correctly.

{% hint style="info" %}
For a general usage, outside Comm.land and the UI Shell, the Alert component is recommended to be inserted either at the beginning or at the end of the react component where it is going to be used.
{% endhint %}

### onCancel and onConfirm

These actions are going to be executed only at clicking the cancel and confirmation buttons respectively. A difference between the Mini Wizard and the Modal component, is that by default the Mini Wizard is locked and it cannoty be exited in other ways but clicking the cancel button.

### Children

To generate the structure required for the component, the developer is able to insert the following components as children elements:

#### WizardStep

<table><thead><tr><th>Props</th><th width="359.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td><p>WizardStepActions <em>(Opcional)</em></p><p>WizardStepContent, WizardStepReview </p></td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>stepTitle</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr><tr><td>validation</td><td>boolean<br>(This should be connected to a state on the developers side)</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

#### WizardStepActions

<table><thead><tr><th>Props</th><th width="359.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td>Any</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>type</td><td>string<br>(Actions)</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

#### WizardStepContent

<table><thead><tr><th>Props</th><th width="359.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td>Any</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>type</td><td>string<br>(Content)</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

#### WizardStepReview

<table><thead><tr><th>Props</th><th width="359.66666666666663">Data Type</th><th>Required</th></tr></thead><tbody><tr><td>children</td><td>Any</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>type</td><td>string<br>(Review)</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span></td></tr><tr><td>className</td><td>string</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span></td></tr></tbody></table>

### Example

```tsx
import React, { useState } from 'react';
import {
  Text,
  Button,
  MiniWizard,
  WizardStep,
  Checkbox
} from '@2600hz/sds-react-components';

const Example = ()=>{
  const [showMiniWizard, setShowMiniWizard] = useState(false);

  const [validations, setValidations] = useState({
    stepOne: true,
    stepTwo: true
  });

  const [confirmationValidation, setConfirmationValidation] = useState(true);

  const cancel = () => {
    console.log('cancel');
    setShowMiniWizard(false);
  };

  const confirm = () => {
    setConfirmationValidation(false);

    setTimeout(() => {
      console.log('Api test');
      setConfirmationValidation(true);
      setShowMiniWizard(false);
    }, 2000);
  };

  return (
    <>
      <MiniWizard
        title="Example"
        commland
        type="Edit"
        confirmationValidation={confirmationValidation}
        confirmationContentDescription="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque temporibus, hic ullam, ipsum corporis quas praesentium libero culpa eum accusamus, eos facere quasi ducimus voluptatibus aperiam necessitatibus reiciendis error totam."
        onCancel={cancel}
        onConfirm={confirm}
      >
        <WizardStep stepTitle="Step One" validation={validations.stepOne}>
          <WizardStepActions type="Actions" className="Actions">
            <Button icon="download">Download</Button>
            <Button icon="mail">Send Email</Button>
          </WizardStepActions>
          <WizardStepContent type="Content">
            <Text.p>
              Lorem ipsum dolor, sit amet consectetur adipisicing elit. Animi
              aliquam asperiores quis, fugiat dicta suscipit iusto voluptas
              ullam necessitatibus ducimus enim incidunt eos repellendus? Sunt
              nostrum vitae deleniti voluptatibus minima.
            </Text.p>
            <br />
            <Checkbox
              id="stepOne"
              checked={validations.stepOne}
              label="Validation"
              onChange={(e: any) => {
                setValidations((prevState) => ({
                  ...prevState,
                  stepOne: e.checked
                }));
              }}
            />
          </WizardStepContent>
          <WizardStepReview type="Review">
            <Text.p>Something...</Text.p>
            <Button>Example</Button>
          </WizardStepReview>
        </WizardStep>
  
        <WizardStep stepTitle="Step Two">
          <WizardStepContent type="Content">
            <Text.p>
              Lorem ipsum dolor, sit amet consectetur adipisicing elit. Animi
              aliquam asperiores quis, fugiat dicta suscipit iusto voluptas
              ullam necessitatibus ducimus enim incidunt eos repellendus? Sunt
              nostrum vitae deleniti voluptatibus minima.
            </Text.p>
          </WizardStepContent>
          <WizardStepReview type="Review">
            <Text.p>Something...</Text.p>
          </WizardStepReview>
        </WizardStep>
  
        <WizardStep stepTitle="Step Three" validation={validations.stepTwo}>
          <WizardStepContent type="Content">
            <Text.p>
              Lorem ipsum dolor, sit amet consectetur adipisicing elit. Animi
              aliquam asperiores quis, fugiat dicta suscipit iusto voluptas
              ullam necessitatibus ducimus enim incidunt eos repellendus? Sunt
              nostrum vitae deleniti voluptatibus minima.
            </Text.p>
            <br />
            <Checkbox
              id="stepTwo"
              checked={validations.stepTwo}
              label="Validation"
              onChange={(e: any) => {
                setValidations((prevState) => ({
                  ...prevState,
                  stepTwo: e.checked
                }));
              }}
            />
          </WizardStepContent>
          <WizardStepReview type="Review">
            <Text.p>Something...</Text.p>
          </WizardStepReview>
        </WizardStep>
        <WizardStep stepTitle="Step Four">
          <WizardStepContent type="Content">
            <Text.p>
              Lorem ipsum dolor, sit amet consectetur adipisicing elit. Animi
              aliquam asperiores quis, fugiat dicta suscipit iusto voluptas
              ullam necessitatibus ducimus enim incidunt eos repellendus? Sunt
              nostrum vitae deleniti voluptatibus minima.
            </Text.p>
          </WizardStepContent>
          <WizardStepReview type="Review">
            <Text.p>Something...</Text.p>
          </WizardStepReview>
        </WizardStep>
      </MiniWizard>
      
      <Button set={()=>{setShowMiniWizard(true}}>Show MiniWizard</Button>
    </>
);
}

export default App;

```

## Components Dependency

For this component elaboration there were used the following internal components:

* [Tooltip](https://2600hz.gitbook.io/sds/sds-components/simple-components/tooltip)
* [Telicon](https://2600hz.gitbook.io/sds/sds-components/simple-components/telicon)
* [Button](https://2600hz.gitbook.io/sds/sds-components/simple-components/button)
* [Text](https://2600hz.gitbook.io/sds/sds-components/simple-components/text)

## Live Demo <a href="#live-demo" id="live-demo"></a>

For detailed code usage documentation, see the Storybooks for each framework below.​

### &#x20;<a href="#react" id="react"></a>

{% embed url="<https://sipster-react-component-storybook.netlify.app/?path=%2Fstory%2Fgeneral-components-mini-wizard--mini-wizard>" %}
