amenpunk 1 年間 前
コミット
5133ba03a7
共有2 個のファイルを変更した136 個の追加141 個の削除を含む
  1. 60 24
      src/Components/Password/Steps/TypePwd.jsx
  2. 76 117
      src/temp.js

+ 60 - 24
src/Components/Password/Steps/TypePwd.jsx

@@ -2,8 +2,8 @@ import { useEffect, useState } from 'react'
2 2
 import { Service } from '../../../Utils/HTTP.js'
3 3
 import { useSelector } from 'react-redux'
4 4
 import {
5
-  FormControl, RadioGroup, FormControlLabel, Radio, FormLabel, Checkbox,
6
-  TextField, Box
5
+  FormControl, RadioGroup, FormControlLabel, FormLabel, Checkbox,
6
+  TextField, Box, FormGroup, Button, Stack
7 7
 } from '@mui/material'
8 8
 
9 9
 import { Simple as Loading } from '../../Generics/loading.jsx'
@@ -18,18 +18,12 @@ function Title({ title, step }) {
18 18
 
19 19
 function PasswordInfoForm() {
20 20
   return (
21
-    <Box
22
-      component="form"
23
-      sx={{
24
-        '& > :not(style)': { m: 1, width: '25ch' },
25
-      }}
26
-      noValidate
27
-      autoComplete="off"
28
-    >
29
-      <TextField id="outlined-basic" label="Outlined" variant="outlined" />
30
-      <TextField id="filled-basic" label="Filled" variant="filled" />
31
-      <TextField id="standard-basic" label="Standard" variant="standard" />
32
-    </Box>
21
+    <Stack >
22
+      <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} >
23
+        <TextField fullWidth id="outlined-basic" label="Correo" variant="outlined" />
24
+        <TextField fullWidth id="outlined-basic" label="Contraseña" variant="outlined" />
25
+      </Stack>
26
+    </Stack>
33 27
   );
34 28
 }
35 29
 
@@ -60,15 +54,20 @@ export default function PermisosList(props) {
60 54
 }
61 55
 
62 56
 function TipoUsuarios(props) {
57
+
63 58
   let { type, setType } = props
59
+
64 60
   const handleChange = (event) => {
65
-    setType(event.target.value);
61
+    let { value, checked } = event.target
62
+    console.log({ value, checked })
63
+    // let value = event.target.checked ? event.target.value : 0
64
+    setType(parseInt(value));
66 65
   };
67 66
 
68 67
   return (
69 68
     <FormControl>
70 69
       <FormLabel id="demo-radio-buttons-group-label">Nivel de Acceso</FormLabel>
71
-      <RadioGroup
70
+      <FormGroup
72 71
         className="seluser_type"
73 72
         row
74 73
         aria-labelledby="demo-row-radio-buttons-group-label"
@@ -76,10 +75,10 @@ function TipoUsuarios(props) {
76 75
         value={type}
77 76
         onChange={handleChange}
78 77
       >
79
-        <FormControlLabel value={0} control={<Checkbox />} label="Administrador" />
80
-        <FormControlLabel value={1} control={<Checkbox />} label="Asistente" />
81
-        <FormControlLabel value={2} control={<Checkbox />} label="Candidato" />
82
-      </RadioGroup>
78
+        <FormControlLabel value={1} onChange={handleChange} checked={type === 1} control={<Checkbox />} label="Administrador" />
79
+        <FormControlLabel value={2} onChange={handleChange} checked={type === 2} control={<Checkbox />} label="Asistente" />
80
+        <FormControlLabel value={3} onChange={handleChange} checked={type === 3} control={<Checkbox />} label="Candidato" />
81
+      </FormGroup>
83 82
     </FormControl>
84 83
   );
85 84
 }
@@ -132,11 +131,12 @@ export function TypePwd(props) {
132 131
 
133 132
   }, [auth.token])
134 133
 
135
-  console.log("USER TYPE:", userType)
136
-
137 134
   return (
138 135
     <div class="gapwdrole">
139
-      <Title title="Seleciona el tipo de contraseña" step={"A"} />
136
+
137
+      <div className="typepwdlist">
138
+        <Title title="Seleciona el tipo de contraseña" step={"A"} />
139
+      </div>
140 140
 
141 141
       <div className="typepwdlist">
142 142
         <TipoUsuarios type={userType} setType={setUserType} />
@@ -149,15 +149,51 @@ export function TypePwd(props) {
149 149
               <Title title="Informacion de la contraseña" step={"B"} />
150 150
               <PasswordInfoForm />
151 151
             </div>
152
+          </div>
153
+        )
154
+
155
+      }
156
+
157
+      {
158
+        parseInt(userType) === 2 && (
159
+          <div>
160
+            <div className="typepwdlist">
161
+              <Title title="Informacion de la contraseña" step={"B"} />
162
+              <PasswordInfoForm />
163
+            </div>
152 164
 
153 165
             <div className="typepwdlist">
154 166
               <Title title="Selecciona los privilegios" step={"C"} />
155
-              {recursos && Object.keys(recursos).map((k) => PermisosList( recursos[k] )) }
167
+              {recursos && Object.keys(recursos).map((k) => PermisosList(recursos[k]))}
156 168
             </div>
157 169
           </div>
158 170
         )
159 171
       }
160 172
 
173
+
174
+
175
+      <Box sx={{ mb: 2 }}>
176
+        <div style={{ paddingTop: 15 }}>
177
+          <Button
178
+            type="submit"
179
+            className="registerBtn"
180
+            variant="contained"
181
+            sx={{ mt: 1, mr: 1 }}
182
+          >
183
+            {'Siguiente'}
184
+          </Button>
185
+          <Button
186
+            disabled={true}
187
+            onClick={props.handleBack}
188
+            sx={{ mt: 1, mr: 1 }}
189
+          >
190
+            Regresar
191
+          </Button>
192
+        </div>
193
+      </Box>
194
+
195
+
196
+
161 197
     </div>
162 198
   )
163 199
 

+ 76 - 117
src/temp.js

@@ -1,126 +1,85 @@
1 1
 import * as React from 'react';
2
-import TextField from '@mui/material/TextField';
3
-import Autocomplete from '@mui/material/Autocomplete';
4
-import CircularProgress from '@mui/material/CircularProgress';
2
+import Box from '@mui/material/Box';
3
+import FormLabel from '@mui/material/FormLabel';
4
+import FormControl from '@mui/material/FormControl';
5
+import FormGroup from '@mui/material/FormGroup';
6
+import FormControlLabel from '@mui/material/FormControlLabel';
7
+import FormHelperText from '@mui/material/FormHelperText';
8
+import Checkbox from '@mui/material/Checkbox';
5 9
 
6
-function sleep(delay = 0) {
7
-  return new Promise((resolve) => {
8
-    setTimeout(resolve, delay);
10
+export default function CheckboxesGroup() {
11
+  const [state, setState] = React.useState({
12
+    gilad: true,
13
+    jason: false,
14
+    antoine: false,
9 15
   });
10
-}
11
-
12
-export default function Asynchronous() {
13
-  const [open, setOpen] = React.useState(false);
14
-  const [options, setOptions] = React.useState([]);
15
-  const loading = open && options.length === 0;
16
-
17
-  React.useEffect(() => {
18
-    let active = true;
19
-
20
-    if (!loading) {
21
-      return undefined;
22
-    }
23 16
 
24
-    (async () => {
25
-      await sleep(1e3); // For demo purposes.
17
+  const handleChange = (event) => {
18
+    setState({
19
+      ...state,
20
+      [event.target.name]: event.target.checked,
21
+    });
22
+  };
26 23
 
27
-      if (active) {
28
-        setOptions([...topFilms]);
29
-      }
30
-    })();
31
-
32
-    return () => {
33
-      active = false;
34
-    };
35
-  }, [loading]);
36
-
37
-  React.useEffect(() => {
38
-    if (!open) {
39
-      setOptions([]);
40
-    }
41
-  }, [open]);
24
+  const { gilad, jason, antoine } = state;
25
+  const error = [gilad, jason, antoine].filter((v) => v).length !== 2;
42 26
 
43 27
   return (
44
-    <Autocomplete
45
-      id="asynchronous-demo"
46
-      sx={{ width: 300 }}
47
-      open={open}
48
-      onOpen={() => {
49
-        setOpen(true);
50
-      }}
51
-      onClose={() => {
52
-        setOpen(false);
53
-      }}
54
-      isOptionEqualToValue={(option, value) => option.title === value.title}
55
-      getOptionLabel={(option) => option.title}
56
-      options={options}
57
-      loading={loading}
58
-      renderInput={(params) => (
59
-        <TextField
60
-          {...params}
61
-          label="Asynchronous"
62
-          InputProps={{
63
-            ...params.InputProps,
64
-            endAdornment: (
65
-              <React.Fragment>
66
-                {loading ? <CircularProgress color="inherit" size={20} /> : null}
67
-                {params.InputProps.endAdornment}
68
-              </React.Fragment>
69
-            ),
70
-          }}
71
-        />
72
-      )}
73
-    />
28
+    <Box sx={{ display: 'flex' }}>
29
+      <FormControl sx={{ m: 3 }} component="fieldset" variant="standard">
30
+        <FormLabel component="legend">Assign responsibility</FormLabel>
31
+        <FormGroup>
32
+          <FormControlLabel
33
+            control={
34
+              <Checkbox checked={gilad} onChange={handleChange} name="gilad" />
35
+            }
36
+            label="Gilad Gray"
37
+          />
38
+          <FormControlLabel
39
+            control={
40
+              <Checkbox checked={jason} onChange={handleChange} name="jason" />
41
+            }
42
+            label="Jason Killian"
43
+          />
44
+          <FormControlLabel
45
+            control={
46
+              <Checkbox checked={antoine} onChange={handleChange} name="antoine" />
47
+            }
48
+            label="Antoine Llorca"
49
+          />
50
+        </FormGroup>
51
+        <FormHelperText>Be careful</FormHelperText>
52
+      </FormControl>
53
+      <FormControl
54
+        required
55
+        error={error}
56
+        component="fieldset"
57
+        sx={{ m: 3 }}
58
+        variant="standard"
59
+      >
60
+        <FormLabel component="legend">Pick two</FormLabel>
61
+        <FormGroup>
62
+          <FormControlLabel
63
+            control={
64
+              <Checkbox checked={gilad} onChange={handleChange} name="gilad" />
65
+            }
66
+            label="Gilad Gray"
67
+          />
68
+          <FormControlLabel
69
+            control={
70
+              <Checkbox checked={jason} onChange={handleChange} name="jason" />
71
+            }
72
+            label="Jason Killian"
73
+          />
74
+          <FormControlLabel
75
+            control={
76
+              <Checkbox checked={antoine} onChange={handleChange} name="antoine" />
77
+            }
78
+            label="Antoine Llorca"
79
+          />
80
+        </FormGroup>
81
+        <FormHelperText>You can display an error</FormHelperText>
82
+      </FormControl>
83
+    </Box>
74 84
   );
75 85
 }
76
-
77
-// Top films as rated by IMDb users. http://www.imdb.com/chart/top
78
-const topFilms = [
79
-  { title: 'The Shawshank Redemption', year: 1994 },
80
-  { title: 'The Godfather', year: 1972 },
81
-  { title: 'The Godfather: Part II', year: 1974 },
82
-  { title: 'The Dark Knight', year: 2008 },
83
-  { title: '12 Angry Men', year: 1957 },
84
-  { title: "Schindler's List", year: 1993 },
85
-  { title: 'Pulp Fiction', year: 1994 },
86
-  {
87
-    title: 'The Lord of the Rings: The Return of the King',
88
-    year: 2003,
89
-  },
90
-  { title: 'The Good, the Bad and the Ugly', year: 1966 },
91
-  { title: 'Fight Club', year: 1999 },
92
-  {
93
-    title: 'The Lord of the Rings: The Fellowship of the Ring',
94
-    year: 2001,
95
-  },
96
-  {
97
-    title: 'Star Wars: Episode V - The Empire Strikes Back',
98
-    year: 1980,
99
-  },
100
-  { title: 'Forrest Gump', year: 1994 },
101
-  { title: 'Inception', year: 2010 },
102
-  {
103
-    title: 'The Lord of the Rings: The Two Towers',
104
-    year: 2002,
105
-  },
106
-  { title: "One Flew Over the Cuckoo's Nest", year: 1975 },
107
-  { title: 'Goodfellas', year: 1990 },
108
-  { title: 'The Matrix', year: 1999 },
109
-  { title: 'Seven Samurai', year: 1954 },
110
-  {
111
-    title: 'Star Wars: Episode IV - A New Hope',
112
-    year: 1977,
113
-  },
114
-  { title: 'City of God', year: 2002 },
115
-  { title: 'Se7en', year: 1995 },
116
-  { title: 'The Silence of the Lambs', year: 1991 },
117
-  { title: "It's a Wonderful Life", year: 1946 },
118
-  { title: 'Life Is Beautiful', year: 1997 },
119
-  { title: 'The Usual Suspects', year: 1995 },
120
-  { title: 'Léon: The Professional', year: 1994 },
121
-  { title: 'Spirited Away', year: 2001 },
122
-  { title: 'Saving Private Ryan', year: 1998 },
123
-  { title: 'Once Upon a Time in the West', year: 1968 },
124
-  { title: 'American History X', year: 1998 },
125
-  { title: 'Interstellar', year: 2014 },
126
-];