Browse Source

new method with checkbox

amenpunk 3 years ago
parent
commit
46c5e0bfd0

+ 6 - 2
src/Components/Modal/PasswordModal.jsx

8
 
8
 
9
 import { StepOne } from '../Password/Steps/one'
9
 import { StepOne } from '../Password/Steps/one'
10
 import { StepTwo } from '../Password/Steps/two'
10
 import { StepTwo } from '../Password/Steps/two'
11
-
11
+import { StepTree } from '../Password/Steps/tree'
12
 
12
 
13
 export function HelpModal (props) {
13
 export function HelpModal (props) {
14
 
14
 
60
         },
60
         },
61
         {
61
         {
62
             label : 'Seleccionar pruebas',
62
             label : 'Seleccionar pruebas',
63
-            operation: <h1>preubas</h1>
63
+            operation:
64
+                <StepTree
65
+                    handleNext={handleNext} 
66
+                    handleBack={handleBack} 
67
+                />
64
         },
68
         },
65
         {
69
         {
66
             label : 'Confirmar',
70
             label : 'Confirmar',

+ 29 - 0
src/Components/Password/Steps/tree.js

1
+import {
2
+    Box, Button, Stack,
3
+    TextField, Autocomplete
4
+} from '@mui/material';
5
+
6
+export function StepTree(props) {
7
+    return(
8
+        <Box sx={{ mb: 2 }}>
9
+            <div style={{ paddingTop  : 15}}>
10
+                <Button
11
+                    type="submit"
12
+                    className="registerBtn" 
13
+                    variant="contained"
14
+                    sx={{ mt: 1, mr: 1 }}
15
+                >
16
+                    {'Siguiente'}
17
+                </Button>
18
+                <Button
19
+                    disabled={false}
20
+                    onClick={props.handleBack}
21
+                    sx={{ mt: 1, mr: 1 }}
22
+                >
23
+                    Regresar
24
+                </Button>
25
+            </div>
26
+        </Box>
27
+
28
+    )
29
+}

+ 33 - 27
src/Components/Password/Steps/two.js

4
 import { useFormik, Form, FormikProvider } from 'formik';
4
 import { useFormik, Form, FormikProvider } from 'formik';
5
 
5
 
6
 import {
6
 import {
7
-    Box, Button, Stack,
8
-    TextField, Autocomplete
7
+    Box, Button, Stack, Checkbox,
8
+    TextField, Autocomplete,
9
 } from '@mui/material';
9
 } from '@mui/material';
10
 
10
 
11
+import {
12
+    CheckBox as CheckBoxIcon,
13
+    CheckBoxOutlineBlank as CheckBoxOutlineBlankIcon
14
+} from '@mui/icons-material';
15
+
16
+const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
17
+const checkedIcon = <CheckBoxIcon fontSize="small" />;
18
+
11
 export function StepTwo(props) {
19
 export function StepTwo(props) {
12
 
20
 
13
     const PlazaScheme = Yup.object().shape({
21
     const PlazaScheme = Yup.object().shape({
15
     });
23
     });
16
 
24
 
17
     let {  handleNext, handleBack } = props
25
     let {  handleNext, handleBack } = props
18
-    const [value, setValue] = React.useState(top100Films[0]);
19
-    const [inputValue, setInputValue] = React.useState('');
20
 
26
 
21
     const formik = useFormik({
27
     const formik = useFormik({
22
         initialValues: {
28
         initialValues: {
23
-            puesto: {},
29
+            puesto: {}
24
         },
30
         },
25
         onSubmit: (fields) => {
31
         onSubmit: (fields) => {
26
             console.log('SUBMIT > ',fields)
32
             console.log('SUBMIT > ',fields)
29
         validationSchema: PlazaScheme,
35
         validationSchema: PlazaScheme,
30
     });
36
     });
31
 
37
 
32
-    const {errors, touched, handleSubmit, getFieldProps } = formik;
38
+    const {errors, touched, handleSubmit, getFieldProps, setValues } = formik;
33
 
39
 
34
     return (
40
     return (
35
         <FormikProvider style={{ padding : 25 }} value={formik}>
41
         <FormikProvider style={{ padding : 25 }} value={formik}>
38
 
44
 
39
                     <Autocomplete
45
                     <Autocomplete
40
                         multiple
46
                         multiple
41
-                        autoSelect={true}
42
-                        id="tags-standard"
47
+                        id="checkboxes-tags-demo"
43
                         options={top100Films}
48
                         options={top100Films}
49
+                        disableCloseOnSelect
44
                         getOptionLabel={(option) => option.label}
50
                         getOptionLabel={(option) => option.label}
45
-                        onChange={(event, newValue) => {
46
-                            console.log('NEW VAL', newValue[0])
47
-                            setValue(newValue[0]);
51
+                        onChange={(a,b,c) => {
52
+                            setValues({
53
+                                puesto : b[0]
54
+                            })
48
                         }}
55
                         }}
49
-                        inputValue={inputValue}
50
-                        onInputChange={(event, newInputValue) => {
51
-                            console.log('NEW', newInputValue)
52
-                            setInputValue(newInputValue);
53
-                        }}
54
-
55
-
56
+                        renderOption={(props, option, { selected }) => (
57
+                            <li {...props}>
58
+                                <Checkbox
59
+                                    icon={icon}
60
+                                    checkedIcon={checkedIcon}
61
+                                    // style={{ marginRight: 8 }}
62
+                                    checked={selected}
63
+                                    />
64
+                                {option.label}
65
+                            </li>
66
+                        )}
56
                         renderInput={(params) => (
67
                         renderInput={(params) => (
57
-                            <TextField
68
+                            <TextField 
58
                                 {...getFieldProps('puesto')}
69
                                 {...getFieldProps('puesto')}
59
-                                {...params}
60
                                 error={Boolean(touched.puesto && errors.puesto)}
70
                                 error={Boolean(touched.puesto && errors.puesto)}
61
                                 helperText={touched.puesto && errors.puesto}
71
                                 helperText={touched.puesto && errors.puesto}
62
-                                variant="standard"
63
-                                label="Buscar Plaza" 
64
-                                placeholder="Favorites"
65
-                                fullWidth
66
-
72
+                                {...params} 
73
+                                label="Checkboxes" placeholder="Favorites" 
67
                                 />
74
                                 />
68
                         )}
75
                         )}
69
-                        />
70
-
76
+                    />
71
 
77
 
72
                     <Box sx={{ mb: 2 }}>
78
                     <Box sx={{ mb: 2 }}>
73
                         <div style={{ paddingTop  : 15}}>
79
                         <div style={{ paddingTop  : 15}}>