version estable router, interceptos, menu

develop
Al Garcia 2 years ago
parent 9dde627214
commit 84ceea673b
  1. 2
      src/App.tsx
  2. 120
      src/Components/Catalogos/CatUsuarios.tsx
  3. 12
      src/Components/Home/Home.tsx
  4. 14
      src/Components/Login/Login.tsx
  5. 2
      src/Components/Operaciones/Viaje/Viaje.tsx
  6. 5
      src/css/generalStyles.css

@ -16,6 +16,7 @@ import { CatUbicaciones } from './Components/Catalogos/CatUbicaciones'
import { CatRutas } from './Components/Catalogos/CatRutas'
import { OpMonitor } from './Components/Operaciones/OpMonitor'
import { CatServicios } from './Components/Catalogos/CatServicios'
import { CatUsuarios } from './Components/Catalogos/CatUsuarios'
function App() {
const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado)
@ -49,6 +50,7 @@ function App() {
<Route path='CatTipoUnidades' element={<CatTipoUnidades />} />
<Route path='CatUbicaciones' element={<CatUbicaciones />} />
<Route path='CatRutas' element={<CatRutas />} />
<Route path='CatUsuarios' element={<CatUsuarios />} />
</Route>
<Route path='*' element={<PageNotFound />} />
</Routes>

@ -0,0 +1,120 @@
import React, { FC, useState } from 'react'
import { Card, Col, FloatingLabel, Form, Row } from 'react-bootstrap'
import { useSelector } from 'react-redux'
import { RootState } from '../../store/store'
interface IProps {}
export const CatUsuarios: FC<IProps> = (props) => {
const mCatClientes = useSelector((state: RootState) => state.CatClientes.CatClientes)
const mCatProveedores = useSelector((state: RootState) => state.CatProveedores.CatProveedores)
const [Usuario, setUsuario] = useState('')
const [TipoUsuario, setTipoUsuario] = useState(0)
const [Search, setSearch] = useState('')
return (
<div>
<br />
<Card>
<Card.Body>
<Row>
<Col xs={6}>
<Card style={{ backgroundColor: 'rgba(245, 245, 245, 0.4)' }}>
<Card.Body>
<Row>
<Col xs={8}>
<FloatingLabel controlId='TxtNombre' label='Nombre' className='mb-3'>
<Form.Control type='text' placeholder='Nombre' value={Usuario} />
</FloatingLabel>
</Col>
<Col xs={4}>
<FloatingLabel controlId='CmbTipoUsuario' label='Tipo de usuario'>
<Form.Select
aria-label='Tipo usuario'
value={TipoUsuario}
onChange={(e) => {
setTipoUsuario(parseInt(e.target.value))
}}
>
<option value='0'></option>
<option value='1'>Usuario interno</option>
<option value='2'>Cliente</option>
<option value='3'>Proveedor</option>
</Form.Select>
</FloatingLabel>
</Col>
</Row>
<Row>
<Col xs={6}>
<FloatingLabel controlId='floatingInput' label='Nombre de usuario' className='mb-3'>
<Form.Control type='text' placeholder='name@empresa.com' />
</FloatingLabel>
</Col>
<Col xs={6}>
<FloatingLabel controlId='floatingPassword' label='Contraseña'>
<Form.Control type='password' placeholder='Password' />
</FloatingLabel>
</Col>
</Row>
</Card.Body>
</Card>
</Col>
<Col xs={6}>
<Card style={{ backgroundColor: 'rgba(245, 245, 245, 0.4)' }}>
<Card.Body>
<Row>
<Col>
<Form.Control
type='text'
id='Search'
aria-describedby='passwordHelpBlock'
value={Search}
onChange={(e) => {
setSearch(e.target.value)
}}
/>
</Col>
</Row>
<Row style={{ paddingTop: '5px' }}>
<Col xs={12}>
<div className='divTipoCatalogo'>
{TipoUsuario === 2
? mCatClientes
.filter((c) => c.cliente.toLocaleLowerCase().includes(Search.toLocaleLowerCase()))
.map((c) => {
return (
<Form.Check
type='checkbox'
id={`default-${c.id}`}
label={`${c.cliente}`}
style={{ textAlign: 'left', fontWeight: 'normal' }}
/>
)
})
: null}
{TipoUsuario === 3
? mCatProveedores
.filter((c) => c.proveedor.toLocaleLowerCase().includes(Search.toLocaleLowerCase()))
.map((c) => {
return (
<Form.Check
type='checkbox'
id={`default-${c.id}`}
label={`${c.proveedor}`}
style={{ textAlign: 'left', fontWeight: 'normal' }}
/>
)
})
: null}
</div>
</Col>
</Row>
</Card.Body>
</Card>
</Col>
</Row>
</Card.Body>
</Card>
</div>
)
}

@ -64,9 +64,6 @@ export const Home: FC<IProps> = (props) => {
const validateToken = () => {
DSAuth.Validate()
.then((response) => {
// dispatch(populateMenuItems(JSON.parse(menuStr)))
// dispatch(populateUserProfile(token))
alert('token valido')
loadCatalogs()
navigate('/', { replace: true })
})
@ -75,15 +72,6 @@ export const Home: FC<IProps> = (props) => {
})
}
useEffect(() => {
// if (!UserLogued)
// validateToken()
}, [])
useEffect(() => {
alert('token: ' + token)
}, [token])
return (
<div>
<div className='centerV'>

@ -18,7 +18,6 @@ import { populateMenuItems } from '../../store/features/Auth/MenuItemsSlice'
import { RootState } from '../../store/store'
import Leyend from '../../images/leyend.png'
import jwt_decode from 'jwt-decode'
import IjwtStructure from '../../Interfaces/Auth/IjwtStructure'
interface IProps {}
@ -48,8 +47,6 @@ export const Login: FC<IProps> = (props) => {
localStorage.setItem('tokenInfo', JSON.stringify(jwt_decode(response.data.token)))
dispatch(populateMenuItems(response.data.menu))
dispatch(populateUserProfile(response.data.token))
//loadCatalogs()
//alert(localStorage.getItem('token'))
navigate('/', { replace: true })
})
.catch((e: Error) => {
@ -88,9 +85,6 @@ export const Login: FC<IProps> = (props) => {
const validateToken = () => {
DSAuth.Validate()
.then((response) => {
// dispatch(populateMenuItems(JSON.parse(menuStr)))
// dispatch(populateUserProfile(token))
//alert('token valido')
loadCatalogs()
navigate('/', { replace: true })
})
@ -106,11 +100,11 @@ export const Login: FC<IProps> = (props) => {
}, [token])
useEffect(() => {
//alert('user logued:' + UserLogued)
if (UserLogued) {
//loadCatalogs()
if (menuStr) {
dispatch(populateMenuItems(JSON.parse(menuStr)))
dispatch(populateUserProfile(token))
}
}, [UserLogued])
}, [menuStr])
return (
<div hidden={token ? true : false}>

@ -734,7 +734,7 @@ export const Viaje: FC<IProps> = (props) => {
setAduana(parseInt(e.target.value))
}}
value={Aduana}
disabled={DisableAduana}
disabled={Hazmat === 1}
className='form-select form-select-sm dialogLabel'
>
{CatAduanas

@ -12,3 +12,8 @@
.rowSplit {
padding-top: '5px'
}
.divTipoCatalogo {
height: 200px;
overflow-y: scroll;
}

Loading…
Cancel
Save