Skip to content

Commit

Permalink
Merge pull request #20 from BananasDev0/RD-53
Browse files Browse the repository at this point in the history
Rd 53
  • Loading branch information
edmdz authored Mar 25, 2024
2 parents e0e46e2 + 58cb0e7 commit 34ebe76
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 9 deletions.
Binary file added src/assets/IMAGEN SIN FONDO CIRCULO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/LOGO CON CONTORNO BLANCO RD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/components/CustomToolBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react';
import { Toolbar, IconButton, Typography, Menu, MenuItem } from "@mui/material";
import MenuIcon from "@mui/icons-material/Menu";
import AccountCircle from "@mui/icons-material/AccountCircle";
import Logo from '../assets/IMAGEN SIN FONDO CIRCULO.png';

export default function CustomToolBar({ handleDrawerOpen, open }) {
const [anchorEl, setAnchorEl] = useState(null);
Expand All @@ -28,9 +29,13 @@ export default function CustomToolBar({ handleDrawerOpen, open }) {
>
<MenuIcon />
</IconButton>

<img
src={Logo}
alt='Logotipo Refaccionaria Diaz'
style={{ width: 50, height: 'auto', marginBottom: 10,marginRight:10,marginTop:10 }}
/>
<Typography variant="h6" noWrap component="div" sx={{ flexGrow: 1 }}>
Refa Diaz
Radiadorez Diaz
</Typography>

<IconButton
Expand Down
18 changes: 15 additions & 3 deletions src/components/ElementList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import InboxIcon from '@mui/icons-material/MoveToInbox';
import MailIcon from '@mui/icons-material/Mail';

import MiscellaneousServicesIcon from '@mui/icons-material/MiscellaneousServices';
import DirectionsCarFilledIcon from '@mui/icons-material/DirectionsCarFilled';
import InventoryIcon from '@mui/icons-material/Inventory';
import PersonIcon from '@mui/icons-material/Person';

export default function ElementList() {

const icons = [
<InventoryIcon />,
<MiscellaneousServicesIcon />,
<DirectionsCarFilledIcon />,
<PersonIcon />,
];


return (
<List>
{['Productos', 'Servicios', 'Autos', 'Proveedores'].map((text, index) => (
Expand All @@ -25,7 +37,7 @@ export default function ElementList() {
justifyContent: 'center',
}}
>
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
{icons[index]}
</ListItemIcon>
<ListItemText primary={text} sx={{ opacity: open ? 1 : 0 }} />
</ListItemButton>
Expand Down
16 changes: 15 additions & 1 deletion src/components/ProtectedRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { onAuthStateChanged } from 'firebase/auth';
import { Navigate } from 'react-router-dom';
import { auth } from '../services/Firebase/firebase';
import { CircularProgress, Box } from '@mui/material';

export const ProtectedRoute = ({ children }) => {
const [isLoading, setIsLoading] = useState(true);
Expand All @@ -18,7 +19,20 @@ export const ProtectedRoute = ({ children }) => {
});
}, []);

if (isLoading) return <div></div>; // O cualquier componente de carga
if (isLoading) {
return (
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
}}
>
<CircularProgress />
</Box>
);
}

if (!isAuthenticated) return <Navigate to="/login" />;

Expand Down
31 changes: 28 additions & 3 deletions src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import Link from '@mui/material/Link';
import Box from '@mui/material/Box';
import CircularProgress from '@mui/material/CircularProgress';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import { Alert, Stack } from '@mui/material';
import { useNavigate } from 'react-router-dom';
import { signIn } from '../services/Firebase/auth';
import Logo from '../assets/Logo_RD.png';
import Logo from '../assets/LOGO CON CONTORNO BLANCO RD.png';

function Copyright(props) {
return (
Expand Down Expand Up @@ -40,8 +41,10 @@ export default function Login() {
message: '',
severity: 'error',
});
const [isLoading, setIsLoading] = useState(false);
const navigate = useNavigate();


const handleSubmit = async (event) => {
event.preventDefault();
// Restablecer la alerta
Expand Down Expand Up @@ -71,16 +74,19 @@ export default function Login() {


try {
setIsLoading(true);
const validate = await signIn(email, password);

if (validate) {
navigate('/home');

} else {
setAlert({ show: true, message: 'Usuario o Contraseña incorrecta', severity: 'error' });
}
} catch (error) {
console.log(error);
setAlert({ show: true, message: 'Servicio no disponible', severity: 'error' });
} finally {
setIsLoading(false);
}


Expand All @@ -103,7 +109,7 @@ export default function Login() {
<img
src={Logo}
alt='Logotipo Refaccionaria Diaz'
style={{ width: 100, height: 'auto', marginBottom: 20 }}
style={{ width: 300, height: 'auto', marginBottom: 20 }}
/>
<Box component='form' onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
<TextField
Expand Down Expand Up @@ -143,6 +149,25 @@ export default function Login() {
Sign In
</Button>

{isLoading && (
<Box
sx={{
position: 'fixed',
top: '0',
left: '0',
width: '100%',
height: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
zIndex: 9999,
}}
>
<CircularProgress />
</Box>
)}

{alert.show && (
<Stack sx={{ width: '100%', mb: 2 }}>
<Alert severity={alert.severity}>{alert.message}</Alert>
Expand Down

0 comments on commit 34ebe76

Please sign in to comment.