import * as React from "react";
import Box from "@mui/material/Box";
import Stepper from "@mui/material/Stepper";
import Step from "@mui/material/Step";
import StepLabel from "@mui/material/StepLabel";
import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography";
import { inputProps } from "../interface/inputfieldProps";
import {
JsonFormsDispatch,
useJsonForms,
withJsonFormsControlProps,
} from "@jsonforms/react";
import { useContext } from "react";
import { DataContext } from "../context/Context";
import RadioButtonCheckedIcon from "@mui/icons-material/RadioButtonChecked";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import PendingIcon from "@mui/icons-material/Pending";
import _ from "lodash";
import { StepContent, Tooltip } from "@mui/material";
import ComponentWrapper from "../common/ComponentWrapper";
import { getComponentProps } from "../common/getComponentProps";
import { getFieldName } from "../permissions/getFieldName";
const ImpaktAppsStepper = React.memo(function (props: inputProps) {
const {
data,
enabled,
uischema,
path,
schema,
rootSchema,
renderers,
cells,
} = props;
const uischemaData = uischema?.config?.main;
const [labels, setLabels] = React.useState(data?.steps || uischemaData.steps);
const [activeStep, setActiveStep] = React.useState(0);
const [allowedStep, setallowedStep] = React.useState([]);
React.useEffect(() => {
if (data) {
setActiveStep(data.active);
setLabels(data.steps);
}
}, [data]);
const handleNext = () => {
setActiveStep((pre) => pre + 1);
};
const handleBack = () => {
setActiveStep((pre) => pre - 1);
};
const handleReset = () => {
setActiveStep(0);
};
const ctx = useJsonForms();
const { theme, pageName, permissions, serviceProvider, setFormdata } =
useContext(DataContext);
const stepperHandler = (buttonType: string) => {
serviceProvider(
ctx,
{
...uischemaData,
[buttonType]: buttonType,
onClick: buttonType,
},
{
event: { _reactName: buttonType },
path,
...uischemaData.additionalData,
paramValue: {
buttonType,
handleNext,
handleBack,
handleReset,
},
}
);
};
function ColorlibStepIcon(props) {
const { active, completed } = props;
const icons = {
1: (