Reac front end for psicometric app

PasswordModal.jsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import { Modal } from 'react-bootstrap'
  2. import * as React from 'react';
  3. import {
  4. Box, Stepper, Step,
  5. StepLabel, Button , Typography
  6. } from '@mui/material'
  7. import { StepOne } from '../Password/Steps/one'
  8. import { StepTwo } from '../Password/Steps/two'
  9. import { StepTree } from '../Password/Steps/tree'
  10. import { StepFour } from '../Password/Steps/four'
  11. export function HelpModal (props) {
  12. let { visible, handleClose } = props
  13. const [activeStep, setActiveStep] = React.useState(0);
  14. const [skipped, setSkipped] = React.useState(new Set());
  15. const isStepSkipped = (step) => {
  16. return skipped.has(step);
  17. };
  18. const handleNext = () => {
  19. let newSkipped = skipped;
  20. if (isStepSkipped(activeStep)) {
  21. newSkipped = new Set(newSkipped.values());
  22. newSkipped.delete(activeStep);
  23. }
  24. setActiveStep((prevActiveStep) => prevActiveStep + 1);
  25. setSkipped(newSkipped);
  26. };
  27. const handleBack = () => {
  28. setActiveStep((prevActiveStep) => prevActiveStep - 1);
  29. };
  30. const handleReset = () => {
  31. setActiveStep(0);
  32. };
  33. const steps = [
  34. {
  35. label : 'Información del candidato',
  36. operation:
  37. <StepOne
  38. handleNext={handleNext}
  39. handleBack={handleBack}
  40. />
  41. },
  42. {
  43. label : 'Seleccionar plaza',
  44. operation:
  45. <StepTwo
  46. handleNext={handleNext}
  47. handleBack={handleBack}
  48. />
  49. },
  50. {
  51. label : 'Seleccionar pruebas',
  52. operation:
  53. <StepTree
  54. handleNext={handleNext}
  55. handleBack={handleBack}
  56. />
  57. },
  58. {
  59. label : 'Confirmar',
  60. operation:
  61. <StepFour
  62. handleNext={handleNext}
  63. handleBack={handleBack}
  64. />
  65. },
  66. ];
  67. return (
  68. <Modal size="lg"
  69. aria-labelledby="contained-modal-title-vcenter"
  70. centered show={visible}
  71. onHide={handleClose}
  72. >
  73. <Modal.Header>
  74. <button type="button" className="close" onClick={handleClose}>&times;</button>
  75. <h4 className="modal-title">Crear Contraseña</h4>
  76. </Modal.Header>
  77. <Modal.Body className="modal-body">
  78. <Box sx={{ width: '100%' }}>
  79. <Stepper activeStep={activeStep}>
  80. {steps.map((step, index) => {
  81. const stepProps = {};
  82. const labelProps = {};
  83. if (isStepSkipped(index)) {
  84. stepProps.completed = false;
  85. }
  86. return (
  87. <Step key={step.label} {...stepProps}>
  88. <StepLabel {...labelProps}>{step.label}</StepLabel>
  89. </Step>
  90. );
  91. })}
  92. </Stepper>
  93. {activeStep === steps.length ? (
  94. <React.Fragment>
  95. <Typography sx={{ mt: 2, mb: 1 }}>
  96. All steps completed - you&apos;re finished
  97. </Typography>
  98. <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
  99. <Box sx={{ flex: '1 1 auto' }} />
  100. <Button onClick={handleReset}>Reiniciar</Button>
  101. </Box>
  102. </React.Fragment>
  103. ) : (
  104. <React.Fragment>
  105. <Box style={{ padding : 25, marginTop : 25}}>
  106. {steps[activeStep].operation}
  107. </Box>
  108. </React.Fragment>
  109. )}
  110. </Box>
  111. </Modal.Body>
  112. </Modal>
  113. )
  114. }