import { Modal } from 'react-bootstrap'
import * as React from 'react';

import { 
    Box, Stepper, Step,
    StepLabel, Button , Typography
} from '@mui/material'

import { StepOne } from '../Password/Steps/one'

const steps = [
    {
        label : 'Información del candidato',
        operation: <StepOne/>
    },
    {
        label : 'Seleccionar plaza',
        operation: <h1>plaza</h1>
    },
    {
        label : 'Seleccionar pruebas',
        operation: <h1>preubas</h1>
    },
    {
        label : 'Confirmar',
        operation: <h1>adios</h1>
    },
];

export function HelpModal (props) {

    let { visible, handleClose } = props

    const [activeStep, setActiveStep] = React.useState(0);
    const [skipped, setSkipped] = React.useState(new Set());

    const isStepSkipped = (step) => {
        return skipped.has(step);
    };

    const handleNext = () => {
        let newSkipped = skipped;
        if (isStepSkipped(activeStep)) {
            newSkipped = new Set(newSkipped.values());
            newSkipped.delete(activeStep);
        }

        setActiveStep((prevActiveStep) => prevActiveStep + 1);
        setSkipped(newSkipped);
    };

    const handleBack = () => {
        setActiveStep((prevActiveStep) => prevActiveStep - 1);
    };

    const handleReset = () => {
        setActiveStep(0);
    };


    return (
        <Modal size="lg" 
            aria-labelledby="contained-modal-title-vcenter" 
            centered show={visible} 
            onHide={handleClose}
        > 
            <Modal.Header>
                <button type="button" className="close" onClick={handleClose}>&times;</button>
                <h4 className="modal-title">Crear Contraseña</h4>
            </Modal.Header>
            <Modal.Body className="modal-body">

                <Box sx={{ width: '100%' }}>
                    <Stepper activeStep={activeStep}>
                        {steps.map((step, index) => {
                            const stepProps = {};
                            const labelProps = {};
                            if (isStepSkipped(index)) {
                                stepProps.completed = false;
                            }
                            return (
                                <Step key={step.label} {...stepProps}>
                                    <StepLabel {...labelProps}>{step.label}</StepLabel>
                                </Step>
                            );
                        })}
                    </Stepper>
                    {activeStep === steps.length ? (
                        <React.Fragment>
                            <Typography sx={{ mt: 2, mb: 1 }}>
                                All steps completed - you&apos;re finished
                            </Typography>
                            <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
                                <Box sx={{ flex: '1 1 auto' }} />
                                <Button onClick={handleReset}>Reiniciar</Button>
                            </Box>
                        </React.Fragment>
                    ) : (
                            <React.Fragment>

                                <Box style={{ padding : 25, marginTop : 25}}>
                                    {steps[activeStep].operation}
                                </Box>

                                <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
                                    <Button
                                        color="inherit"
                                        disabled={activeStep === 0}
                                        onClick={handleBack}
                                        sx={{ mr: 1 }}
                                    >
                                        Anterior
                                    </Button>
                                    <Box sx={{ flex: '1 1 auto' }} />
                                    <Button onClick={handleNext}>
                                        {activeStep === steps.length - 1 ? 'Guardar' : 'Siguiente'}
                                    </Button>
                                </Box>

                            </React.Fragment>
                        )}
                </Box>

            </Modal.Body>
        </Modal>
    )
}
