Browse Source

new method with checkbox

amenpunk 3 years ago
parent
commit
46c5e0bfd0

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

@@ -8,7 +8,7 @@ import {
8 8
 
9 9
 import { StepOne } from '../Password/Steps/one'
10 10
 import { StepTwo } from '../Password/Steps/two'
11
-
11
+import { StepTree } from '../Password/Steps/tree'
12 12
 
13 13
 export function HelpModal (props) {
14 14
 
@@ -60,7 +60,11 @@ export function HelpModal (props) {
60 60
         },
61 61
         {
62 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 70
             label : 'Confirmar',

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

@@ -0,0 +1,29 @@
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,10 +4,18 @@ import * as Yup from 'yup';
4 4
 import { useFormik, Form, FormikProvider } from 'formik';
5 5
 
6 6
 import {
7
-    Box, Button, Stack,
8
-    TextField, Autocomplete
7
+    Box, Button, Stack, Checkbox,
8
+    TextField, Autocomplete,
9 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 19
 export function StepTwo(props) {
12 20
 
13 21
     const PlazaScheme = Yup.object().shape({
@@ -15,12 +23,10 @@ export function StepTwo(props) {
15 23
     });
16 24
 
17 25
     let {  handleNext, handleBack } = props
18
-    const [value, setValue] = React.useState(top100Films[0]);
19
-    const [inputValue, setInputValue] = React.useState('');
20 26
 
21 27
     const formik = useFormik({
22 28
         initialValues: {
23
-            puesto: {},
29
+            puesto: {}
24 30
         },
25 31
         onSubmit: (fields) => {
26 32
             console.log('SUBMIT > ',fields)
@@ -29,7 +35,7 @@ export function StepTwo(props) {
29 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 40
     return (
35 41
         <FormikProvider style={{ padding : 25 }} value={formik}>
@@ -38,36 +44,36 @@ export function StepTwo(props) {
38 44
 
39 45
                     <Autocomplete
40 46
                         multiple
41
-                        autoSelect={true}
42
-                        id="tags-standard"
47
+                        id="checkboxes-tags-demo"
43 48
                         options={top100Films}
49
+                        disableCloseOnSelect
44 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 67
                         renderInput={(params) => (
57
-                            <TextField
68
+                            <TextField 
58 69
                                 {...getFieldProps('puesto')}
59
-                                {...params}
60 70
                                 error={Boolean(touched.puesto && errors.puesto)}
61 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 78
                     <Box sx={{ mb: 2 }}>
73 79
                         <div style={{ paddingTop  : 15}}>