Prechádzať zdrojové kódy

some styles componentes

amenpunk 3 rokov pred
rodič
commit
0f93c18258

+ 1 - 0
src/App.css

@@ -416,6 +416,7 @@
   color:white !important;
   background:var(--main) !important;
 }
+
 .headert_pwdu{
   background:var(--main);
   color:white !important;

+ 1 - 1
src/App.js

@@ -12,7 +12,7 @@ import Routes from './Components/Routes'
 const queryClient = new QueryClient({
   defaultOptions: {
     queries: {
-      refetchOnWindowFocus: false,
+      refetchOnWindowFocus: true,
     },
   },
 })

+ 101 - 68
src/Components/Dashboard.js

@@ -2,16 +2,16 @@ import React from 'react';
 import { ThemeProvider, styled, createTheme } from '@mui/material/styles';
 
 import {
-    Container, IconButton, Divider,
-    Typography, List, Toolbar,useMediaQuery as Size,
-    Box, Badge, Menu, Avatar, MenuItem
+  Container, IconButton, Divider,
+  Typography, List, Toolbar, useMediaQuery as Size,
+  Box, Badge, Menu, Avatar, MenuItem
 } from '@mui/material'
 
 import {
-    Fullscreen as FullscreenIcon,
-    Menu as MenuIcon,
-    KeyboardDoubleArrowLeft as LeftKey,
-    Notifications as NotificationsIcon,
+  Fullscreen as FullscreenIcon,
+  Menu as MenuIcon,
+  KeyboardDoubleArrowLeft as LeftKey,
+  Notifications as NotificationsIcon,
 } from '@mui/icons-material'
 
 import Logo from '../Images/evaluacion.jpeg';
@@ -23,57 +23,86 @@ import Footer from "../Components/Footer";
 import { Drawer as MuiDrawer, AppBar as MuiAppBar } from "../Components/Navigation/AppBar"
 import { MainListItems, SecondaryListItems } from '../Components/Navigation/listItems';
 import ProfilePicture from '../Images/man.png';
-import { useDispatch } from 'react-redux';
+import { useDispatch, useSelector } from 'react-redux';
 import { removeToken } from '../Slices/tokenSlice';
 
 const drawerWidth = 240;
 const mdTheme = createTheme();
 
+function stringToColor(string) {
+  let hash = 0;
+  let i;
+  /* eslint-disable no-bitwise */
+  for (i = 0; i < string.length; i += 1) {
+    hash = string.charCodeAt(i) + ((hash << 5) - hash);
+  }
+
+  let color = '#';
+
+  for (i = 0; i < 3; i += 1) {
+    const value = (hash >> (i * 8)) & 0xff;
+    color += `00${value.toString(16)}`.slice(-2);
+  }
+  /* eslint-enable no-bitwise */
+  return color;
+}
+
+
+function stringAvatar(name) {
+  console.log("NAME: ", name)
+  return {
+    sx: {
+      bgcolor: stringToColor(name),
+    },
+    children: `${name.split(' ')[0][0]}${name.split(' ')[1][0]}`,
+  };
+}
+
 const AppBar = styled(MuiAppBar, {
-    shouldForwardProp: (prop) => prop !== 'open',
+  shouldForwardProp: (prop) => prop !== 'open',
 })(({ theme, open }) => ({
-    zIndex: theme.zIndex.drawer + 1,
+  zIndex: theme.zIndex.drawer + 1,
+  transition: theme.transitions.create(['width', 'margin'], {
+    easing: theme.transitions.easing.sharp,
+    duration: theme.transitions.duration.leavingScreen,
+  }),
+  ...(open && {
+    marginLeft: drawerWidth,
+    width: `calc(100% - ${drawerWidth}px)`,
     transition: theme.transitions.create(['width', 'margin'], {
-        easing: theme.transitions.easing.sharp,
-        duration: theme.transitions.duration.leavingScreen,
-    }),
-    ...(open && {
-        marginLeft: drawerWidth,
-        width: `calc(100% - ${drawerWidth}px)`,
-        transition: theme.transitions.create(['width', 'margin'], {
-            easing: theme.transitions.easing.sharp,
-            duration: theme.transitions.duration.enteringScreen,
-        }),
+      easing: theme.transitions.easing.sharp,
+      duration: theme.transitions.duration.enteringScreen,
     }),
+  }),
 }));
 
 
-const Drawer = styled(MuiDrawer, 
-    { shouldForwardProp: (prop) => prop !== 'open' })(
+const Drawer = styled(MuiDrawer,
+  { shouldForwardProp: (prop) => prop !== 'open' })(
     ({ theme, open }) => ({
-        '& .MuiDrawer-paper': {
-            position: 'relative',
-            whiteSpace: 'nowrap',
-            width: drawerWidth,
-            transition: theme.transitions.create('width', {
-                easing: theme.transitions.easing.sharp,
-                duration: theme.transitions.duration.enteringScreen,
-            }),
-            boxSizing: 'border-box',
-            ...(!open && {
-                overflowX: 'hidden',
-                transition: theme.transitions.create('width', {
-                    easing: theme.transitions.easing.sharp,
-                    duration: theme.transitions.duration.leavingScreen,
-                }),
-                width: theme.spacing(7),
-                [theme.breakpoints.up('sm')]: {
-                    width: theme.spacing(9),
-                },
-            }),
-        },
+      '& .MuiDrawer-paper': {
+        position: 'relative',
+        whiteSpace: 'nowrap',
+        width: drawerWidth,
+        transition: theme.transitions.create('width', {
+          easing: theme.transitions.easing.sharp,
+          duration: theme.transitions.duration.enteringScreen,
+        }),
+        boxSizing: 'border-box',
+        ...(!open && {
+          overflowX: 'hidden',
+          transition: theme.transitions.create('width', {
+            easing: theme.transitions.easing.sharp,
+            duration: theme.transitions.duration.leavingScreen,
+          }),
+          width: theme.spacing(7),
+          [theme.breakpoints.up('sm')]: {
+            width: theme.spacing(9),
+          },
+        }),
+      },
     }),
-);
+  );
 
 
 function DashboardContent() {
@@ -83,25 +112,29 @@ function DashboardContent() {
   const isMovil = Size('(max-width:1000px)');
   const dispatch = useDispatch();
   const navigate = useNavigate()
+  const profile = useSelector((state) => state.recluter.info)
+  console.log('PROFILE: ', profile)
 
   const CerrarSession = () => {
+    //TODO:
+    //remove all status
     dispatch(removeToken())
     navigate('/')
   }
 
   const [anchorEl, setAnchorEl] = React.useState(null);
   const open_profile = Boolean(anchorEl);
-  const handleClick = (event) =>  setAnchorEl(event.currentTarget);
+  const handleClick = (event) => setAnchorEl(event.currentTarget);
   const handleClose = () => setAnchorEl(null)
   const toggleDrawer = () => {
-    if(isMovil){
+    if (isMovil) {
       setAnchorElMov(!anchorElMovil)
-    }else{
+    } else {
       setOpen(!open);
     }
   }
   const [anchorElMovil, setAnchorElMov] = React.useState(false);
-  React.useEffect(() => isMovil ? setOpen(false) : null , [isMovil])
+  React.useEffect(() => isMovil ? setOpen(false) : null, [isMovil])
 
   return (
     <ThemeProvider theme={mdTheme}>
@@ -114,9 +147,8 @@ function DashboardContent() {
               edge="start"
               color="inherit"
               aria-label="open drawer"
-              // onClick={isMovil ? MenuResponsive : toggleDrawer}
               onClick={toggleDrawer}
-              sx={{ marginRight: '36px', ...( open && { display: 'none' }), }} >
+              sx={{ marginRight: '36px', ...(open && { display: 'none' }), }} >
               <MenuIcon style={{
                 background: '#ec5e69',
                 fontSize: "40",
@@ -125,19 +157,19 @@ function DashboardContent() {
             </IconButton>
             <Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
               {
-              open ? (
-                <React.Fragment>
-
-                  <IconButton onClick={toggleDrawer}>
-                    <LeftKey/>
-                  </IconButton>
-
-                  <IconButton onClick={(event) => event.target.requestFullscreen()}>
-                    <FullscreenIcon style={{ paddinLeft: 15 }} />
-                  </IconButton>
-                </React.Fragment>
-              ) : undefined
-            }
+                open ? (
+                  <React.Fragment>
+
+                    <IconButton onClick={toggleDrawer}>
+                      <LeftKey />
+                    </IconButton>
+
+                    <IconButton onClick={(event) => event.target.requestFullscreen()}>
+                      <FullscreenIcon style={{ paddinLeft: 15 }} />
+                    </IconButton>
+                  </React.Fragment>
+                ) : undefined
+              }
             </Typography>
 
             <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
@@ -146,8 +178,8 @@ function DashboardContent() {
                 size="large"
                 aria-label="show 17 new notifications"
                 color="inherit">
-                <Badge badgeContent={17} color="error">
-                  <NotificationsIcon style={{ color : '#212529' }}/>
+                <Badge badgeContent={1} color="error">
+                  <NotificationsIcon style={{ color: '#212529' }} />
                 </Badge>
               </IconButton>
 
@@ -161,7 +193,8 @@ function DashboardContent() {
                 onClick={handleClick}
                 color="inherit"
               >
-                <Avatar alt="Cindy Baker" src={ProfilePicture} />
+                {/* <Avatar alt="Cindy Baker" src={ProfilePicture} /> */ }
+                <Avatar {...stringAvatar(`${profile.nombre} ${profile.apelidos}`)} />
 
               </IconButton>
               <Menu
@@ -170,7 +203,7 @@ function DashboardContent() {
                 open={open_profile}
                 onClose={handleClose}
                 MenuListProps={{ 'aria-labelledby': 'basic-button', }}>
-                <MenuItem onClick={() => navigate('/dashboard/configuraciones') }>Perfil</MenuItem>
+                <MenuItem onClick={() => navigate('/dashboard/configuraciones')}>Perfil</MenuItem>
                 <MenuItem onClick={CerrarSession}>Cerrar Sesion</MenuItem>
               </Menu>
             </Box>
@@ -211,6 +244,6 @@ function DashboardContent() {
 }
 
 export function Dashboard() {
-    return <DashboardContent />;
+  return <DashboardContent />;
 }
 

+ 6 - 11
src/Components/Home/Candidato.jsx

@@ -24,19 +24,15 @@ function IconStatus(props) {
   let navigate = useNavigate()
   let auth = useSelector((state) => state.token)
 
-  console.log(props)
   const calificar = () => {
-    console.log('TOKEN: ',auth.token)
     let rest = new Service(`/prueba/calificacion/cleaver/report/${props.pwd}`);
 
     rest
       .getQuery(auth.token)
       .then(r => {
-        console.log("SUCCESS:", r)
         navigate('/dashboard/resultados/' + props.pwd)
       })
       .catch(e => {
-        console.log("ERROR:", e.message)
         // navigate('/dashboard/resultados/' + props.pwd)
       })
   }
@@ -51,7 +47,7 @@ function IconStatus(props) {
             // navigate('/dashboard/resultados/' + props.pwd)
           }
         }}
-        style={{ color: '#0bd641' }}
+        style={{ color: props.color }}
         components="label">
         {<props.icon />}
       </IconButton>
@@ -67,21 +63,20 @@ function getOperation(estado, SuperPWD) {
   // Patrik: 1 -> Solo esta asignado.
   switch (estado) {
     case 1: // solo asignado
-      return <IconStatus icon={AddTaskIcon} message="Candidato Asignado" />
+      return <IconStatus color="#0bd641" icon={AddTaskIcon} message="Candidato Asignado" />
     case 97: //error en las respuestas
-      return <IconStatus icon={ErrorIcon} message="Hay error en las respuestas" />
+      return <IconStatus color="var(--main)"  icon={ErrorIcon} message="Hay error en las respuestas" />
     case 99: // el candidato se encuentra realizndolo
-      return <IconStatus icon={AssignmentTurnedInIcon} message="El candidato se encuentra realizando la prueba" />
+      return <IconStatus color="#f5f511" icon={AssignmentTurnedInIcon} message="El candidato se encuentra realizando la prueba" />
     case 100: // finalizado
-      return <IconStatus estado={100} icon={CheckBoxIcon} message="Calificar el examen" pwd={SuperPWD} />
+      return <IconStatus color="#0bd641" estado={100} icon={CheckBoxIcon} message="Calificar el examen" pwd={SuperPWD} />
     default: return null
   }
 }
 
 function Asignaciones(props) {
 
-  let { estado, cattest, calificacionescleaver: test_result, id: SuperPWD } = props.asign;
-  console.log(props, test_result, SuperPWD)
+  let { estado, cattest, id: SuperPWD } = props.asign;
 
   return (
     <tr>

+ 91 - 87
src/Components/Navigation/listItems.js

@@ -3,108 +3,112 @@ import { Nav } from 'react-bootstrap';
 
 import { Fingerprint, ExpandLess, ExpandMore } from '@mui/icons-material/'
 import { useNavigate, useResolvedPath, useMatch } from 'react-router-dom'
-import { Collapse,ListItem, List ,ListItemIcon,ListItemText,ListSubheader } from '@mui/material/'
+import { Collapse, ListItem, List, ListItemIcon, ListItemText, ListSubheader } from '@mui/material/'
 
-import { 
-    MainItems, ExtraItems, PruebaItems, TxTStyle,
-    UserItems
+import {
+  MainItems, ExtraItems, PruebaItems, TxTStyle,
+  UserItems
 } from '../../Utils/MenuItems'
 
 
-function NavItem (props) {
-    
-    let navigate = useNavigate()
-    let resolved = useResolvedPath(props.route);
-    let match = useMatch({ path: resolved.pathname, end: true });
+function NavItem(props) {
+
+  let navigate = useNavigate()
+  let resolved = useResolvedPath(props.route);
+  let match = useMatch({ path: resolved.pathname, end: true });
+
+  let { title, route, icon, open, AppBarVisible, setOpen } = props
+
+  if (route.startsWith('prueba') && match && open && !AppBarVisible) {
+    setOpen(false);
+  }
+
+  return (
+    <ListItem
+      sx={{ color: '#25344f' }}
+      selected={match && typeof (match) === "object"}
+      onClick={() => navigate(route)}
+      button >
+      <ListItemIcon>
+        {icon && icon}
+      </ListItemIcon>
+      <ListItemText
+        sx={TxTStyle}
+        primary={title}
+      />
+    </ListItem>
+  )
+}
 
-    let { title, route, icon, open, AppBarVisible, setOpen } = props
 
-    if(route.startsWith('prueba') && match && open && !AppBarVisible ){
-        setOpen(false);
-    }
+export const MainListItems = (props) => {
 
-    return(
-        <ListItem
-            sx={{ color : '#25344f'}}
-            selected={ match && typeof(match) === "object" }
-            onClick={() => navigate(route) } 
-            button >
-            <ListItemIcon>
-                {icon && icon}
-            </ListItemIcon>
-            <ListItemText 
-                sx={TxTStyle}
-                primary={title} 
-            />
-        </ListItem>
-    )
-}
+  const [open, setOpen] = React.useState(false);
 
+  const showPruebas = () => {
+    if (!props.AppBarVisible) {
+      props.setAppBarVisible(true);
+    }
+    setOpen(!open);
+  };
+
+  return (
+    <List>
+      <ListSubheader inset>MENÚ</ListSubheader>
+      {
+        MainItems.map(({ icon, title, route }, i) => (
+          <NavItem key={i} icon={icon} title={title} route={route} />
+        ))
+      }
+
+      {/*
+        <ListItem selected={open} onClick={showPruebas}>
+          <ListItemIcon>
+            <Fingerprint />
+          </ListItemIcon>
+          <ListItemText
+            sx={TxTStyle}
+            primary="Pruebas"
+          />
+          {open ? <ExpandLess /> : <ExpandMore />}
+        </ListItem>
 
-export const MainListItems = (props) =>  {
-
-    const [open, setOpen] = React.useState(false);
-
-    const showPruebas = () => {
-        if(!props.AppBarVisible){
-            props.setAppBarVisible(true);
-        }
-        setOpen(!open);
-    };
-
-    return(
-        <List>
-            <ListSubheader inset>MENÚ</ListSubheader>
-            {
-                MainItems.map( ({ icon, title, route}, i) =>  (
-                    <NavItem key={i} icon={icon} title={title} route={route} />
-                ))
-            }
-            <ListItem selected={open} onClick={showPruebas}>
-                <ListItemIcon>
-                    <Fingerprint />
-                </ListItemIcon>
-                <ListItemText 
-                    sx={TxTStyle}
-                    primary="Pruebas" 
-                />
-                {open ? <ExpandLess /> : <ExpandMore />}
-            </ListItem>
-            <Collapse in={open} timeout="auto" unmountOnExit>
-                <List component="div" disablePadding>
-                    {
-                        PruebaItems.map( ({ route, title},i) => 
-                            ( <NavItem key={i} setOpen={setOpen} { ...props} open={open} route={route} title={title} />)
-                        )
-                    }
-                </List>
+          <Collapse in={open} timeout="auto" unmountOnExit>
+            <List component="div" disablePadding>
+              {
+                PruebaItems.map(({ route, title }, i) =>
+                  (<NavItem key={i} setOpen={setOpen} {...props} open={open} route={route} title={title} />)
+                )
+              }
+            </List>
             </Collapse>
+      */}
 
-        </List>
-    )
+    </List>
+  )
 };
 
-export const UserListItems = (_props) =>  {
-    return(
-        <List>
-            <ListSubheader inset>MENÚ</ListSubheader>
-            {
-                UserItems.map( ({ icon, title, route}, i) =>  (
-                    <NavItem key={i} icon={icon} title={title} route={route} />
-                ))
-            }
-        </List>
-    )
+export const UserListItems = (_props) => {
+  return (
+    <List>
+      <ListSubheader inset>MENÚ</ListSubheader>
+      {
+        UserItems.map(({ icon, title, route }, i) => (
+          <NavItem key={i} icon={icon} title={title} route={route} />
+        ))
+      }
+    </List>
+  )
 };
 
 export const SecondaryListItems = (
-    <Nav>
-        <ListSubheader inset>EXTRAS</ListSubheader>
-        {
-            ExtraItems.map( ({ icon, route, title}) => 
-                ( <NavItem key={route} icon={icon} title={title} route={route} />)
-            )
-        }
-    </Nav>
+  <Nav>
+    <ListSubheader inset>EXTRAS</ListSubheader>
+    {
+      ExtraItems.map(({ icon, route, title }) =>
+        (<NavItem key={route} icon={icon} title={title} route={route} />)
+      )
+    }
+  </Nav>
 );
 

+ 4 - 0
src/Components/Routes.js

@@ -23,6 +23,7 @@ import { RestorePassword } from '../Pages/RestorePassword'
 import { HomeUser } from '../Pages/HomeUser'
 import { Prueba } from '../Pages/Prueba.jsx'
 import { RequireToken, RequireUserToken } from '../Components/PrivateRoute'
+import { Default } from '../Pages/Default';
 
 export default function MyRoutes() {
 
@@ -74,6 +75,9 @@ export default function MyRoutes() {
         <Route path="pruebas/listar" element={<Pruebas />} />
         <Route path="pruebas/crear" element={<PruebaNueva />} />
         <Route path="pruebas/aplicar" element={<PruebaAsignar />} />
+        <Route path="default" element={<Default />} />
+        <Route path="default2" element={<Default />} />
+
       </Route>
       <Route path="*" element={<NotFound />} />
 

+ 18 - 0
src/Pages/Default.jsx

@@ -0,0 +1,18 @@
+import { Row, Container } from 'react-bootstrap'
+
+export function Default() {
+
+  return (
+
+    <section>
+      <div className="content-section">
+        <div className="main">
+          <Container >
+            <Row style={{ display: 'flex', flexWrap: 'wrap', justifyContent: "center" }}></Row>
+          </Container>
+        </div>
+      </div>
+    </section>
+  )
+
+}

+ 7 - 7
src/Utils/MenuItems.js

@@ -65,19 +65,19 @@ export const MainItems = [
 ]
 
 export const ExtraItems = [
-  {
-    icon: <Star />,
-    route: 'elementos',
-    title: 'Elementos'
-  },
+  // {
+  //   icon: <Star />,
+  //   route: 'elementos',
+  //   title: 'Elementos'
+  // },
   {
     icon: <OndemandVideo />,
-    route: 'tutoriales',
+    route: 'default',
     title: 'Tutoriales'
   },
   {
     icon: <SupportAgent />,
-    route: 'help',
+    route: 'default2',
     title: 'Asistencia Técnica'
   },
 ]