develop
parent
5b477c5a29
commit
d620503e50
@ -0,0 +1,242 @@ |
||||
import React, { FC, useState } from 'react' |
||||
import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' |
||||
import DataTable from 'react-data-table-component' |
||||
import { IconContext } from 'react-icons' |
||||
import { useDispatch, useSelector } from 'react-redux' |
||||
import ICatClientes from '../../Interfaces/Catalogos/ICatClientes' |
||||
import { RootState } from '../../store/store' |
||||
import { BsFillPencilFill, BsFillTrashFill, BsSave } from 'react-icons/bs' |
||||
import DSCatClientes from '../../Services/Catalogos/CatClientes.Services' |
||||
import { updateCatClientes, deleteCatClientes } from '../../store/features/Catalogos/CatClientesSlice' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const CatClientes: FC<IProps> = (props) => { |
||||
const dispatch = useDispatch() |
||||
const CatClientes = useSelector((state: RootState) => state.CatClientes.CatClientes) |
||||
const [showCatClientesDialog, setShowCatClientesDialog] = useState(false) |
||||
const [deleteCatClientesDialog, setDeleteCatClientesDialog] = useState(false) |
||||
const [IDCliente, setIDCliente] = useState(0) |
||||
const [Cliente, setCliente] = useState('') |
||||
const [Search, setSearch] = useState('') |
||||
const columnsConcepts = [ |
||||
{ |
||||
name: 'id', |
||||
width: '80px', |
||||
selector: (row: ICatClientes) => row.id, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Cliente', |
||||
width: '450px', |
||||
selector: (row: ICatClientes) => row.cliente, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Editar', |
||||
width: '100px', |
||||
cell: (row: ICatClientes) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
showInfo(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'blue', size: '21px' }}> |
||||
<BsFillPencilFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Elimina', |
||||
width: '100px', |
||||
cell: (row: ICatClientes) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
confirmDelete(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'red', size: '21px' }}> |
||||
<BsFillTrashFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
] |
||||
|
||||
const showInfo = (data: ICatClientes) => { |
||||
setIDCliente(data.id) |
||||
setCliente(data.cliente) |
||||
setShowCatClientesDialog(true) |
||||
} |
||||
|
||||
const confirmDelete = (data: ICatClientes) => { |
||||
setIDCliente(data.id) |
||||
setCliente(data.cliente) |
||||
setDeleteCatClientesDialog(true) |
||||
} |
||||
|
||||
const deleteInfo = () => { |
||||
DSCatClientes.Delete(IDCliente) |
||||
.then((response) => { |
||||
dispatch(deleteCatClientes(IDCliente)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setDeleteCatClientesDialog(false) |
||||
} |
||||
|
||||
const saveInfo = () => { |
||||
const data: ICatClientes = { |
||||
id: IDCliente, |
||||
cliente: Cliente, |
||||
activo: 1, |
||||
} |
||||
DSCatClientes.Append(data) |
||||
.then((response) => { |
||||
dispatch(updateCatClientes(response.data)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setShowCatClientesDialog(false) |
||||
} |
||||
|
||||
const filtraReporte = (e: any) => { |
||||
setSearch(e.target.value) |
||||
} |
||||
|
||||
return ( |
||||
<div> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Card style={{}}> |
||||
<Card.Body> |
||||
<Card.Title style={{ textAlign: 'left' }}> |
||||
<Alert variant='primary'>Clientes</Alert> |
||||
</Card.Title> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Form.Control |
||||
type='text' |
||||
size='sm' |
||||
placeholder='Search...' |
||||
onChange={(e) => { |
||||
filtraReporte(e) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<DataTable |
||||
noHeader |
||||
defaultSortFieldId={'id'} |
||||
defaultSortAsc={true} |
||||
striped={true} |
||||
dense={true} |
||||
paginationPerPage={10} |
||||
pagination |
||||
highlightOnHover |
||||
columns={columnsConcepts} |
||||
data={CatClientes.filter(function (row: ICatClientes) { |
||||
return row.cliente.includes(Search) |
||||
})} |
||||
pointerOnHover |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Card.Body> |
||||
</Card> |
||||
</Col> |
||||
</Row> |
||||
<Modal |
||||
show={showCatClientesDialog} |
||||
onHide={() => { |
||||
setShowCatClientesDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Clientes</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<Row> |
||||
<Col xs={3}>No cliente</Col> |
||||
<Col xs={2}> |
||||
<Form.Control type='text' id='IDCliente' value={IDCliente} disabled size='sm' /> |
||||
</Col> |
||||
</Row> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={2}>Cliente</Col> |
||||
<Col xs={10}> |
||||
<Form.Control |
||||
type='text' |
||||
id='Cliente' |
||||
value={Cliente} |
||||
size='sm' |
||||
onChange={(e) => { |
||||
setCliente(e.target.value) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='primary' |
||||
onClick={() => { |
||||
saveInfo() |
||||
}} |
||||
> |
||||
Guarda |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
<Modal |
||||
show={deleteCatClientesDialog} |
||||
onHide={() => { |
||||
setDeleteCatClientesDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Clientes</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Alert variant='warning'> |
||||
¿Esta seguro de que desea eliminar el cliente: <br /> |
||||
<span style={{ fontWeight: 'bold', fontSize: '20px' }}>{Cliente}</span>? |
||||
</Alert> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='danger' |
||||
onClick={() => { |
||||
deleteInfo() |
||||
}} |
||||
> |
||||
Elimina |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
</div> |
||||
) |
||||
} |
@ -0,0 +1,241 @@ |
||||
import React, { FC, useState } from 'react' |
||||
import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' |
||||
import DataTable from 'react-data-table-component' |
||||
import { IconContext } from 'react-icons' |
||||
import { useDispatch, useSelector } from 'react-redux' |
||||
import ICatProveedores from '../../Interfaces/Catalogos/ICatProveedores' |
||||
import { RootState } from '../../store/store' |
||||
import { BsFillPencilFill, BsFillTrashFill, BsSave } from 'react-icons/bs' |
||||
import DSCatProveedores from '../../Services/Catalogos/CatProveedores.Services' |
||||
import { updateCatProveedores, deleteCatProveedores } from '../../store/features/Catalogos/CatProveedoresSlice' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const CatProveedores: FC<IProps> = (props) => { |
||||
const dispatch = useDispatch() |
||||
const CatProveedores = useSelector((state: RootState) => state.CatProveedores.CatProveedores) |
||||
const [showCatProveedoresDialog, setShowCatProveedoresDialog] = useState(false) |
||||
const [deleteCatProveedoresDialog, setDeleteCatProveedoresDialog] = useState(false) |
||||
const [IDProveedor, setIDProveedor] = useState(0) |
||||
const [Proveedor, setProveedor] = useState('') |
||||
const [Search, setSearch] = useState('') |
||||
const columnsConcepts = [ |
||||
{ |
||||
name: 'id', |
||||
width: '80px', |
||||
selector: (row: ICatProveedores) => row.id, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Proveedor', |
||||
width: '450px', |
||||
selector: (row: ICatProveedores) => row.proveedor, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Editar', |
||||
width: '100px', |
||||
cell: (row: ICatProveedores) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
showInfo(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'blue', size: '21px' }}> |
||||
<BsFillPencilFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Elimina', |
||||
width: '100px', |
||||
cell: (row: ICatProveedores) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
confirmDelete(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'red', size: '21px' }}> |
||||
<BsFillTrashFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
] |
||||
|
||||
const showInfo = (data: ICatProveedores) => { |
||||
setIDProveedor(data.id) |
||||
setProveedor(data.proveedor) |
||||
setShowCatProveedoresDialog(true) |
||||
} |
||||
|
||||
const confirmDelete = (data: ICatProveedores) => { |
||||
setIDProveedor(data.id) |
||||
setProveedor(data.proveedor) |
||||
setDeleteCatProveedoresDialog(true) |
||||
} |
||||
|
||||
const deleteInfo = () => { |
||||
DSCatProveedores.Delete(IDProveedor) |
||||
.then((response) => { |
||||
dispatch(deleteCatProveedores(IDProveedor)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setDeleteCatProveedoresDialog(false) |
||||
} |
||||
|
||||
const saveInfo = () => { |
||||
const data: ICatProveedores = { |
||||
id: IDProveedor, |
||||
proveedor: Proveedor, |
||||
activo: 1, |
||||
} |
||||
DSCatProveedores.Append(data) |
||||
.then((response) => { |
||||
dispatch(updateCatProveedores(response.data)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setShowCatProveedoresDialog(false) |
||||
} |
||||
|
||||
const filtraReporte = (e: any) => { |
||||
setSearch(e.target.value) |
||||
} |
||||
return ( |
||||
<div> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Card style={{}}> |
||||
<Card.Body> |
||||
<Card.Title style={{ textAlign: 'left' }}> |
||||
<Alert variant='primary'>Proveedores</Alert> |
||||
</Card.Title> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Form.Control |
||||
type='text' |
||||
size='sm' |
||||
placeholder='Search...' |
||||
onChange={(e) => { |
||||
filtraReporte(e) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<DataTable |
||||
noHeader |
||||
defaultSortFieldId={'id'} |
||||
defaultSortAsc={true} |
||||
striped={true} |
||||
dense={true} |
||||
paginationPerPage={10} |
||||
pagination |
||||
highlightOnHover |
||||
columns={columnsConcepts} |
||||
data={CatProveedores.filter(function (row: ICatProveedores) { |
||||
return row.proveedor.includes(Search) |
||||
})} |
||||
pointerOnHover |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Card.Body> |
||||
</Card> |
||||
</Col> |
||||
</Row> |
||||
<Modal |
||||
show={showCatProveedoresDialog} |
||||
onHide={() => { |
||||
setShowCatProveedoresDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Proveedores</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<Row> |
||||
<Col xs={4}>No proveedor</Col> |
||||
<Col xs={2}> |
||||
<Form.Control type='text' id='IDCliente' value={IDProveedor} disabled size='sm' /> |
||||
</Col> |
||||
</Row> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={2}>Proveedor</Col> |
||||
<Col xs={10}> |
||||
<Form.Control |
||||
type='text' |
||||
id='Proveedor' |
||||
value={Proveedor} |
||||
size='sm' |
||||
onChange={(e) => { |
||||
setProveedor(e.target.value) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='primary' |
||||
onClick={() => { |
||||
saveInfo() |
||||
}} |
||||
> |
||||
Guarda |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
<Modal |
||||
show={deleteCatProveedoresDialog} |
||||
onHide={() => { |
||||
setDeleteCatProveedoresDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Proveedores</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Alert variant='warning'> |
||||
¿Esta seguro de que desea eliminar el proveedor: <br /> |
||||
<span style={{ fontWeight: 'bold', fontSize: '20px' }}>{Proveedor}</span>? |
||||
</Alert> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='danger' |
||||
onClick={() => { |
||||
deleteInfo() |
||||
}} |
||||
> |
||||
Elimina |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
</div> |
||||
) |
||||
} |
@ -0,0 +1,128 @@ |
||||
import React, { FC, useState } from 'react' |
||||
import { Alert, Card, Col, Form, Row } from 'react-bootstrap' |
||||
import { useSelector } from 'react-redux' |
||||
import { RootState } from '../../store/store' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const CatRutas: FC<IProps> = (props) => { |
||||
const CatClientes = useSelector((state: RootState) => state.CatClientes.CatClientes) |
||||
const CatTipoUnidades = useSelector((state: RootState) => state.CatTipoUnidades.CatTipoUnidades) |
||||
const CatUbicaciones = useSelector((state: RootState) => state.CatUbicaciones.CatUbicaciones) |
||||
const [IDCliente, setIDCliente] = useState(0) |
||||
const [IDTipoUnidad, setIDTipoUnidad] = useState(0) |
||||
const [IDOrigen, setIDOrigen] = useState(0) |
||||
const [IDDestino, setIDDestino] = useState(0) |
||||
|
||||
return ( |
||||
<div> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Card style={{}}> |
||||
<Card.Body> |
||||
<Card.Title style={{ textAlign: 'left' }}> |
||||
<Alert variant='primary'>Rutas</Alert> |
||||
</Card.Title> |
||||
<Row> |
||||
<Col xs={2}>Cliente</Col> |
||||
<Col> |
||||
<Form.Control |
||||
as='select' |
||||
onChange={(e) => { |
||||
setIDCliente(parseInt(e.target.value)) |
||||
}} |
||||
value={IDCliente} |
||||
className='form-select form-select-sm' |
||||
> |
||||
<option value='0'>-SELECCIONE-</option> |
||||
{CatClientes |
||||
? CatClientes.map((c) => { |
||||
return ( |
||||
<option key={c.id} value={c.id}> |
||||
{c.cliente} |
||||
</option> |
||||
) |
||||
}) |
||||
: null} |
||||
</Form.Control> |
||||
</Col> |
||||
<Col xs={2}>Tipo unidad</Col> |
||||
<Col> |
||||
<Form.Control |
||||
as='select' |
||||
onChange={(e) => { |
||||
setIDTipoUnidad(parseInt(e.target.value)) |
||||
}} |
||||
value={IDTipoUnidad} |
||||
className='form-select form-select-sm' |
||||
> |
||||
<option value='0'>-SELECCIONE-</option> |
||||
{CatTipoUnidades |
||||
? CatTipoUnidades.map((c) => { |
||||
return ( |
||||
<option key={c.id} value={c.id}> |
||||
{c.tipoUnidad} |
||||
</option> |
||||
) |
||||
}) |
||||
: null} |
||||
</Form.Control> |
||||
</Col> |
||||
</Row> |
||||
<Row> |
||||
<Col> </Col> |
||||
</Row> |
||||
<Row> |
||||
<Col xs={2}>Origen</Col> |
||||
<Col> |
||||
<Form.Control |
||||
as='select' |
||||
onChange={(e) => { |
||||
setIDOrigen(parseInt(e.target.value)) |
||||
}} |
||||
value={IDOrigen} |
||||
className='form-select form-select-sm' |
||||
> |
||||
<option value='0'>-SELECCIONE-</option> |
||||
{CatUbicaciones |
||||
? CatUbicaciones.map((c) => { |
||||
return ( |
||||
<option key={c.id} value={c.id}> |
||||
{c.ubicacion} |
||||
</option> |
||||
) |
||||
}) |
||||
: null} |
||||
</Form.Control> |
||||
</Col> |
||||
<Col xs={2}>Destino</Col> |
||||
<Col> |
||||
<Form.Control |
||||
as='select' |
||||
onChange={(e) => { |
||||
setIDDestino(parseInt(e.target.value)) |
||||
}} |
||||
value={IDDestino} |
||||
className='form-select form-select-sm' |
||||
> |
||||
<option value='0'>-SELECCIONE-</option> |
||||
{CatUbicaciones |
||||
? CatUbicaciones.map((c) => { |
||||
return ( |
||||
<option key={c.id} value={c.id}> |
||||
{c.ubicacion} |
||||
</option> |
||||
) |
||||
}) |
||||
: null} |
||||
</Form.Control> |
||||
</Col> |
||||
</Row> |
||||
<Row></Row> |
||||
</Card.Body> |
||||
</Card> |
||||
</Col> |
||||
</Row> |
||||
</div> |
||||
) |
||||
} |
@ -0,0 +1,242 @@ |
||||
import React, { FC, useState } from 'react' |
||||
import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' |
||||
import DataTable from 'react-data-table-component' |
||||
import { IconContext } from 'react-icons' |
||||
import { useDispatch, useSelector } from 'react-redux' |
||||
import ICatTipoUnidades from '../../Interfaces/Catalogos/ICatTipoUnidades' |
||||
import { RootState } from '../../store/store' |
||||
import { BsFillPencilFill, BsFillTrashFill, BsSave } from 'react-icons/bs' |
||||
import DSCatTipoUnidades from '../../Services/Catalogos/CatTipoUnidades.Services' |
||||
import { updateCatTipoUnidades, deleteCatTipoUnidades } from '../../store/features/Catalogos/CatTipoUnidadesSlice' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const CatTipoUnidades: FC<IProps> = (props) => { |
||||
const dispatch = useDispatch() |
||||
const CatTipoUnidades = useSelector((state: RootState) => state.CatTipoUnidades.CatTipoUnidades) |
||||
const [showCatTipoUnidadesDialog, setShowCatTipoUnidadesDialog] = useState(false) |
||||
const [deleteCatTipoUnidadesDialog, setDeleteCatTipoUnidadesDialog] = useState(false) |
||||
const [IDTipoUnidad, setIDTipoUnidad] = useState(0) |
||||
const [TipoUnidad, setTipoUnidad] = useState('') |
||||
const [Search, setSearch] = useState('') |
||||
const columnsConcepts = [ |
||||
{ |
||||
name: 'id', |
||||
width: '80px', |
||||
selector: (row: ICatTipoUnidades) => row.id, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Tipo unidad', |
||||
width: '450px', |
||||
selector: (row: ICatTipoUnidades) => row.tipoUnidad, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Editar', |
||||
width: '100px', |
||||
cell: (row: ICatTipoUnidades) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
showInfo(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'blue', size: '21px' }}> |
||||
<BsFillPencilFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Elimina', |
||||
width: '100px', |
||||
cell: (row: ICatTipoUnidades) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
confirmDelete(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'red', size: '21px' }}> |
||||
<BsFillTrashFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
] |
||||
|
||||
const showInfo = (data: ICatTipoUnidades) => { |
||||
setIDTipoUnidad(data.id) |
||||
setTipoUnidad(data.tipoUnidad) |
||||
setShowCatTipoUnidadesDialog(true) |
||||
} |
||||
|
||||
const confirmDelete = (data: ICatTipoUnidades) => { |
||||
setIDTipoUnidad(data.id) |
||||
setTipoUnidad(data.tipoUnidad) |
||||
setDeleteCatTipoUnidadesDialog(true) |
||||
} |
||||
|
||||
const deleteInfo = () => { |
||||
DSCatTipoUnidades.Delete(IDTipoUnidad) |
||||
.then((response) => { |
||||
dispatch(deleteCatTipoUnidades(IDTipoUnidad)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setDeleteCatTipoUnidadesDialog(false) |
||||
} |
||||
|
||||
const saveInfo = () => { |
||||
const data: ICatTipoUnidades = { |
||||
id: IDTipoUnidad, |
||||
tipoUnidad: TipoUnidad, |
||||
activo: 1, |
||||
} |
||||
DSCatTipoUnidades.Append(data) |
||||
.then((response) => { |
||||
dispatch(updateCatTipoUnidades(response.data)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setShowCatTipoUnidadesDialog(false) |
||||
} |
||||
|
||||
const filtraReporte = (e: any) => { |
||||
setSearch(e.target.value) |
||||
} |
||||
|
||||
return ( |
||||
<div> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Card style={{}}> |
||||
<Card.Body> |
||||
<Card.Title style={{ textAlign: 'left' }}> |
||||
<Alert variant='primary'>Tipo Unidades</Alert> |
||||
</Card.Title> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Form.Control |
||||
type='text' |
||||
size='sm' |
||||
placeholder='Search...' |
||||
onChange={(e) => { |
||||
filtraReporte(e) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<DataTable |
||||
noHeader |
||||
defaultSortFieldId={'id'} |
||||
defaultSortAsc={true} |
||||
striped={true} |
||||
dense={true} |
||||
paginationPerPage={10} |
||||
pagination |
||||
highlightOnHover |
||||
columns={columnsConcepts} |
||||
data={CatTipoUnidades.filter(function (row: ICatTipoUnidades) { |
||||
return row.tipoUnidad.includes(Search) |
||||
})} |
||||
pointerOnHover |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Card.Body> |
||||
</Card> |
||||
</Col> |
||||
</Row> |
||||
<Modal |
||||
show={showCatTipoUnidadesDialog} |
||||
onHide={() => { |
||||
setShowCatTipoUnidadesDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Tipo unidades</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<Row> |
||||
<Col xs={4}>No tipo unidad</Col> |
||||
<Col xs={2}> |
||||
<Form.Control type='text' id='IDCliente' value={IDTipoUnidad} disabled size='sm' /> |
||||
</Col> |
||||
</Row> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={3}>Tipo unidad</Col> |
||||
<Col xs={9}> |
||||
<Form.Control |
||||
type='text' |
||||
id='TipoUnidad' |
||||
value={TipoUnidad} |
||||
size='sm' |
||||
onChange={(e) => { |
||||
setTipoUnidad(e.target.value) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='primary' |
||||
onClick={() => { |
||||
saveInfo() |
||||
}} |
||||
> |
||||
Guarda |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
<Modal |
||||
show={deleteCatTipoUnidadesDialog} |
||||
onHide={() => { |
||||
setDeleteCatTipoUnidadesDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Clientes</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Alert variant='warning'> |
||||
¿Esta seguro de que desea eliminar el cliente: <br /> |
||||
<span style={{ fontWeight: 'bold', fontSize: '20px' }}>{TipoUnidad}</span>? |
||||
</Alert> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='danger' |
||||
onClick={() => { |
||||
deleteInfo() |
||||
}} |
||||
> |
||||
Elimina |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
</div> |
||||
) |
||||
} |
@ -0,0 +1,242 @@ |
||||
import React, { FC, useState } from 'react' |
||||
import { Alert, Button, Card, Col, Form, Modal, Row } from 'react-bootstrap' |
||||
import DataTable from 'react-data-table-component' |
||||
import { IconContext } from 'react-icons' |
||||
import { useDispatch, useSelector } from 'react-redux' |
||||
import { RootState } from '../../store/store' |
||||
import { BsFillPencilFill, BsFillTrashFill, BsSave } from 'react-icons/bs' |
||||
import DSCatUbicaciones from '../../Services/Catalogos/CatUbicaciones.Services' |
||||
import { updateCatUbicaciones, deleteCatUbicaciones } from '../../store/features/Catalogos/CatUbicacionesSlice' |
||||
import ICatUbicaciones from '../../Interfaces/Catalogos/ICatUbicaciones' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const CatUbicaciones: FC<IProps> = (props) => { |
||||
const dispatch = useDispatch() |
||||
const CatUbicaciones = useSelector((state: RootState) => state.CatUbicaciones.CatUbicaciones) |
||||
const [showCatUbicacionesDialog, setShowCatUbicacionesDialog] = useState(false) |
||||
const [deleteCatUbicacionesDialog, setDeleteCatUbicacionesDialog] = useState(false) |
||||
const [IDUbicacion, setIDUbicacion] = useState(0) |
||||
const [Ubicacion, setUbicacion] = useState('') |
||||
const [Search, setSearch] = useState('') |
||||
const columnsConcepts = [ |
||||
{ |
||||
name: 'id', |
||||
width: '80px', |
||||
selector: (row: ICatUbicaciones) => row.id, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Ubicacion', |
||||
width: '450px', |
||||
selector: (row: ICatUbicaciones) => row.ubicacion, |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Editar', |
||||
width: '100px', |
||||
cell: (row: ICatUbicaciones) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
showInfo(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'blue', size: '21px' }}> |
||||
<BsFillPencilFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
{ |
||||
name: 'Elimina', |
||||
width: '100px', |
||||
cell: (row: ICatUbicaciones) => ( |
||||
<div |
||||
style={{ textAlign: 'center', cursor: 'pointer' }} |
||||
onClick={() => { |
||||
confirmDelete(row) |
||||
}} |
||||
> |
||||
<IconContext.Provider value={{ color: 'red', size: '21px' }}> |
||||
<BsFillTrashFill /> |
||||
</IconContext.Provider> |
||||
</div> |
||||
), |
||||
sortable: true, |
||||
}, |
||||
] |
||||
|
||||
const showInfo = (data: ICatUbicaciones) => { |
||||
setIDUbicacion(data.id) |
||||
setUbicacion(data.ubicacion) |
||||
setShowCatUbicacionesDialog(true) |
||||
} |
||||
|
||||
const confirmDelete = (data: ICatUbicaciones) => { |
||||
setIDUbicacion(data.id) |
||||
setUbicacion(data.ubicacion) |
||||
setDeleteCatUbicacionesDialog(true) |
||||
} |
||||
|
||||
const deleteInfo = () => { |
||||
DSCatUbicaciones.Delete(IDUbicacion) |
||||
.then((response) => { |
||||
dispatch(deleteCatUbicaciones(IDUbicacion)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setDeleteCatUbicacionesDialog(false) |
||||
} |
||||
|
||||
const saveInfo = () => { |
||||
const data: ICatUbicaciones = { |
||||
id: IDUbicacion, |
||||
ubicacion: Ubicacion, |
||||
activo: 1, |
||||
} |
||||
DSCatUbicaciones.Append(data) |
||||
.then((response) => { |
||||
dispatch(updateCatUbicaciones(response.data)) |
||||
}) |
||||
.catch((e: Error) => {}) |
||||
setShowCatUbicacionesDialog(false) |
||||
} |
||||
|
||||
const filtraReporte = (e: any) => { |
||||
setSearch(e.target.value) |
||||
} |
||||
|
||||
return ( |
||||
<div> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Card style={{}}> |
||||
<Card.Body> |
||||
<Card.Title style={{ textAlign: 'left' }}> |
||||
<Alert variant='primary'>Ubicacions</Alert> |
||||
</Card.Title> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Form.Control |
||||
type='text' |
||||
size='sm' |
||||
placeholder='Search...' |
||||
onChange={(e) => { |
||||
filtraReporte(e) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<DataTable |
||||
noHeader |
||||
defaultSortFieldId={'id'} |
||||
defaultSortAsc={true} |
||||
striped={true} |
||||
dense={true} |
||||
paginationPerPage={10} |
||||
pagination |
||||
highlightOnHover |
||||
columns={columnsConcepts} |
||||
data={CatUbicaciones.filter(function (row: ICatUbicaciones) { |
||||
return row.ubicacion.includes(Search) |
||||
})} |
||||
pointerOnHover |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Card.Body> |
||||
</Card> |
||||
</Col> |
||||
</Row> |
||||
<Modal |
||||
show={showCatUbicacionesDialog} |
||||
onHide={() => { |
||||
setShowCatUbicacionesDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Ubicaciones</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<Row> |
||||
<Col xs={3}>No. ubicacion</Col> |
||||
<Col xs={2}> |
||||
<Form.Control type='text' id='IDUbicacion' value={IDUbicacion} disabled size='sm' /> |
||||
</Col> |
||||
</Row> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={2}>Ubicacion</Col> |
||||
<Col xs={10}> |
||||
<Form.Control |
||||
type='text' |
||||
id='Ubicacion' |
||||
value={Ubicacion} |
||||
size='sm' |
||||
onChange={(e) => { |
||||
setUbicacion(e.target.value) |
||||
}} |
||||
/> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='primary' |
||||
onClick={() => { |
||||
saveInfo() |
||||
}} |
||||
> |
||||
Guarda |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
<Modal |
||||
show={deleteCatUbicacionesDialog} |
||||
onHide={() => { |
||||
setDeleteCatUbicacionesDialog(false) |
||||
}} |
||||
> |
||||
<Modal.Header closeButton> |
||||
<Modal.Title>Catalogo: Ubicaciones</Modal.Title> |
||||
</Modal.Header> |
||||
<Modal.Body> |
||||
<br /> |
||||
<Row> |
||||
<Col xs={12}> |
||||
<Alert variant='warning'> |
||||
¿Esta seguro de que desea eliminar la ubicacion: <br /> |
||||
<span style={{ fontWeight: 'bold', fontSize: '20px' }}>{Ubicacion}</span>? |
||||
</Alert> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Body> |
||||
<Modal.Footer> |
||||
<Row> |
||||
<Col xs={2}></Col> |
||||
<Col xs={3}> </Col> |
||||
<Col xs={3}> |
||||
<Button |
||||
variant='danger' |
||||
onClick={() => { |
||||
deleteInfo() |
||||
}} |
||||
> |
||||
Elimina |
||||
</Button> |
||||
</Col> |
||||
</Row> |
||||
</Modal.Footer> |
||||
</Modal> |
||||
</div> |
||||
) |
||||
} |
@ -1,12 +0,0 @@ |
||||
import React, { FC } from 'react' |
||||
|
||||
interface IProps {} |
||||
|
||||
/** |
||||
* @author |
||||
* @function @Protected |
||||
**/ |
||||
|
||||
export const Protected: FC<IProps> = (props) => { |
||||
return <div>Protected</div> |
||||
} |
@ -1,46 +1,25 @@ |
||||
import React, { FC, useEffect, useState } from 'react' |
||||
import { FC, useEffect } from 'react' |
||||
import { useDispatch } from 'react-redux' |
||||
import { useNavigate } from 'react-router-dom' |
||||
import { populateUserProfile } from '../../store/features/Auth/UserProfileSlice' |
||||
import DSAuth from '../../Services/Auth/Auth.Services' |
||||
import { resetUserProfile } from '../../store/features/Auth/UserProfileSlice' |
||||
import { resetMenuItems } from '../../store/features/Auth/MenuItemsSlice' |
||||
import { resetCatClientes } from '../../store/features/Catalogos/CatClientesSlice' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const Logout: FC<IProps> = (props) => { |
||||
const navigate = useNavigate() |
||||
const dispatch = useDispatch() |
||||
const [token, setToken] = useState<string>( |
||||
(window.localStorage.getItem('token') ? window.localStorage.getItem('token') : '')! |
||||
) |
||||
|
||||
useEffect(() => { |
||||
localStorage.removeItem('token') |
||||
localStorage.removeItem('menu') |
||||
//localStorage.setItem('token', '')
|
||||
//localStorage.setItem('menu', '')
|
||||
dispatch(populateUserProfile('')) |
||||
//alert('debe regresar al login')
|
||||
window.location.href = 'http://localhost:3000' |
||||
dispatch(resetUserProfile('')) |
||||
dispatch(resetMenuItems('')) |
||||
dispatch(resetCatClientes('')) |
||||
// alert('on logout')
|
||||
navigate('/', { replace: true }) |
||||
}, []) |
||||
|
||||
const ValidateToken = () => { |
||||
if (token.length > 10) { |
||||
DSAuth.Validate() |
||||
.then((response) => { |
||||
dispatch(populateUserProfile('')) |
||||
window.location.href = 'http://localhost:3000' |
||||
}) |
||||
.catch((e: Error) => { |
||||
console.log('Debe de salir al login') |
||||
window.location.href = 'http://localhost:3000' |
||||
}) |
||||
} |
||||
} |
||||
|
||||
useEffect(() => { |
||||
ValidateToken() |
||||
console.log(token) |
||||
}, [token]) |
||||
|
||||
return <div>Logout</div> |
||||
} |
||||
|
@ -1,32 +0,0 @@ |
||||
import { useEffect } from 'react' |
||||
import { Navigate, useLocation } from 'react-router' |
||||
|
||||
export type ProtectedRouteProps = { |
||||
isAuthenticated: boolean |
||||
authenticationPath: string |
||||
redirectPath: string |
||||
setRedirectPath: (path: string) => void |
||||
outlet: JSX.Element |
||||
} |
||||
|
||||
export default function ProtectedRoute({ |
||||
isAuthenticated, |
||||
authenticationPath, |
||||
redirectPath, |
||||
setRedirectPath, |
||||
outlet, |
||||
}: ProtectedRouteProps) { |
||||
const currentLocation = useLocation() |
||||
|
||||
useEffect(() => { |
||||
if (!isAuthenticated) { |
||||
setRedirectPath(currentLocation.pathname) |
||||
} |
||||
}, [isAuthenticated, setRedirectPath, currentLocation]) |
||||
|
||||
if (isAuthenticated && redirectPath === currentLocation.pathname) { |
||||
return outlet |
||||
} else { |
||||
return <Navigate to={{ pathname: isAuthenticated ? redirectPath : authenticationPath }} /> |
||||
} |
||||
} |
@ -0,0 +1,11 @@ |
||||
import React, { FC } from 'react' |
||||
import { useSelector } from 'react-redux' |
||||
import { Navigate, Outlet } from 'react-router-dom' |
||||
import { RootState } from '../../store/store' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const ProtectedRoute: FC<IProps> = (props) => { |
||||
const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado) |
||||
return UserLogued ? <Outlet /> : <Navigate to='login' /> |
||||
} |
@ -1,34 +1,7 @@ |
||||
import React, { FC, useEffect, useState } from 'react' |
||||
import { Navigate, useNavigate } from 'react-router-dom' |
||||
import { useDispatch } from 'react-redux' |
||||
import DSAuth from '../../Services/Auth/Auth.Services' |
||||
import { UserProfileSlice, populateUserProfile } from '../../store/features/Auth/UserProfileSlice' |
||||
import { FC } from 'react' |
||||
|
||||
interface IProps {} |
||||
|
||||
export const RptViajesPendientes: FC<IProps> = (props) => { |
||||
const navigate = useNavigate() |
||||
const [token, setToken] = useState<string>( |
||||
(window.localStorage.getItem('token') ? window.localStorage.getItem('token') : '')! |
||||
) |
||||
const dispatch = useDispatch() |
||||
|
||||
const ValidateToken = () => { |
||||
if (token.length > 10) { |
||||
DSAuth.Validate() |
||||
.then((response) => { |
||||
dispatch(populateUserProfile(token)) |
||||
}) |
||||
.catch((e: Error) => { |
||||
navigate('login', { replace: true }) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
useEffect(() => { |
||||
ValidateToken() |
||||
console.log(token) |
||||
}, [token]) |
||||
|
||||
return <div>RptViajesPendientes</div> |
||||
} |
||||
|
@ -0,0 +1,5 @@ |
||||
export default interface ICatClientes { |
||||
id: number, |
||||
cliente: string, |
||||
activo: number |
||||
} |
@ -0,0 +1,5 @@ |
||||
export default interface ICatProveedores { |
||||
id: number, |
||||
proveedor: string, |
||||
activo: number |
||||
} |
@ -0,0 +1,5 @@ |
||||
export default interface ICatTipoUnidades { |
||||
id: number, |
||||
tipoUnidad: string, |
||||
activo: number |
||||
} |
@ -0,0 +1,5 @@ |
||||
export default interface ICatUbicaciones { |
||||
id: number, |
||||
ubicacion: string, |
||||
activo: number |
||||
} |
@ -0,0 +1,3 @@ |
||||
export default interface IRespuesta { |
||||
Respuesta: string |
||||
} |
@ -0,0 +1,16 @@ |
||||
import http from "../../Services/Auth/config/http-common"; |
||||
import ICatClientes from "../../Interfaces/Catalogos/ICatClientes"; |
||||
import IRespuesta from "../../Interfaces/Respuestas/IRespuesta"; |
||||
|
||||
class CatClientesDataService { |
||||
Get() { |
||||
return http.get<ICatClientes[]>("Catalogos/CatClientes/Get"); |
||||
} |
||||
Append(data: ICatClientes) { |
||||
return http.post<ICatClientes>(`Catalogos/CatClientes/Append`,data); |
||||
} |
||||
Delete(id: number) { |
||||
return http.delete<IRespuesta>(`/Catalogos/CatClientes/Delete/${id}`); |
||||
} |
||||
} |
||||
export default new CatClientesDataService(); |
@ -0,0 +1,16 @@ |
||||
import http from "../../Services/Auth/config/http-common"; |
||||
import ICatProveedores from "../../Interfaces/Catalogos/ICatProveedores"; |
||||
import IRespuesta from "../../Interfaces/Respuestas/IRespuesta"; |
||||
|
||||
class CatProveedoresDataService { |
||||
Get() { |
||||
return http.get<ICatProveedores[]>("Catalogos/CatProveedores/Get"); |
||||
} |
||||
Append(data: ICatProveedores) { |
||||
return http.post<ICatProveedores>(`Catalogos/CatProveedores/Append`,data); |
||||
} |
||||
Delete(id: number) { |
||||
return http.delete<IRespuesta>(`/Catalogos/CatProveedores/Delete/${id}`); |
||||
} |
||||
} |
||||
export default new CatProveedoresDataService(); |
@ -0,0 +1,16 @@ |
||||
import http from "../../Services/Auth/config/http-common"; |
||||
import ICatTipoUnidades from "../../Interfaces/Catalogos/ICatTipoUnidades"; |
||||
import IRespuesta from "../../Interfaces/Respuestas/IRespuesta"; |
||||
|
||||
class CatTipoUnidadDataService { |
||||
Get() { |
||||
return http.get<ICatTipoUnidades[]>("Catalogos/CatTipoUnidad/Get"); |
||||
} |
||||
Append(data: ICatTipoUnidades) { |
||||
return http.post<ICatTipoUnidades>(`Catalogos/CatTipoUnidad/Append`,data); |
||||
} |
||||
Delete(id: number) { |
||||
return http.delete<IRespuesta>(`Catalogos/CatTipoUnidad/Delete/${id}`); |
||||
} |
||||
} |
||||
export default new CatTipoUnidadDataService(); |
@ -0,0 +1,16 @@ |
||||
import http from "../../Services/Auth/config/http-common"; |
||||
import ICatUbicaciones from "../../Interfaces/Catalogos/ICatUbicaciones"; |
||||
import IRespuesta from "../../Interfaces/Respuestas/IRespuesta"; |
||||
|
||||
class CatUbicacionesDataService { |
||||
Get() { |
||||
return http.get<ICatUbicaciones[]>("Catalogos/CatUbicaciones/Get"); |
||||
} |
||||
Append(data: ICatUbicaciones) { |
||||
return http.post<ICatUbicaciones>(`Catalogos/CatUbicaciones/Append`,data); |
||||
} |
||||
Delete(id: number) { |
||||
return http.delete<IRespuesta>(`Catalogos/CatUbicaciones/Delete/${id}`); |
||||
} |
||||
} |
||||
export default new CatUbicacionesDataService(); |
@ -0,0 +1,32 @@ |
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit' |
||||
import ICatClientes from '../../../Interfaces/Catalogos/ICatClientes' |
||||
const CatClientes: ICatClientes[] = [] |
||||
const initialState = { CatClientes } |
||||
|
||||
export const CatClientesSlice = createSlice({ |
||||
name: 'CatClientes', |
||||
initialState: initialState, |
||||
reducers: { |
||||
resetCatClientes : (state, action: PayloadAction<string>) => { |
||||
state.CatClientes = [] |
||||
},
|
||||
populateCatClientes : (state, action: PayloadAction<ICatClientes[]>) => { |
||||
action.payload.forEach(element => { |
||||
const index = state.CatClientes.findIndex(object => object.id === element.id) |
||||
if (index<0) state.CatClientes.push(element) |
||||
}) |
||||
}, |
||||
updateCatClientes : (state, action: PayloadAction<ICatClientes>) => { |
||||
const i = state.CatClientes.findIndex(_element => _element.id === action.payload.id); |
||||
if (i > -1) state.CatClientes[i] = action.payload; |
||||
else state.CatClientes.push(action.payload); |
||||
}, |
||||
deleteCatClientes : (state, action: PayloadAction<number>) => { |
||||
const newArr = state.CatClientes.filter(data => data.id != action.payload); |
||||
state.CatClientes=newArr |
||||
}, |
||||
}, |
||||
}) |
||||
|
||||
export const { resetCatClientes, populateCatClientes, updateCatClientes, deleteCatClientes } = CatClientesSlice.actions; |
||||
export default CatClientesSlice.reducer; |
@ -0,0 +1,32 @@ |
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit' |
||||
import ICatProveedores from '../../../Interfaces/Catalogos/ICatProveedores' |
||||
const CatProveedores: ICatProveedores[] = [] |
||||
const initialState = { CatProveedores } |
||||
|
||||
export const CatProveedoresSlice = createSlice({ |
||||
name: 'CatProveedores', |
||||
initialState: initialState, |
||||
reducers: { |
||||
resetCatProveedores : (state, action: PayloadAction<string>) => { |
||||
state.CatProveedores = [] |
||||
},
|
||||
populateCatProveedores : (state, action: PayloadAction<ICatProveedores[]>) => { |
||||
action.payload.forEach(element => { |
||||
const index = state.CatProveedores.findIndex(object => object.id === element.id) |
||||
if (index<0) state.CatProveedores.push(element) |
||||
}) |
||||
}, |
||||
updateCatProveedores : (state, action: PayloadAction<ICatProveedores>) => { |
||||
const i = state.CatProveedores.findIndex(_element => _element.id === action.payload.id); |
||||
if (i > -1) state.CatProveedores[i] = action.payload; |
||||
else state.CatProveedores.push(action.payload); |
||||
}, |
||||
deleteCatProveedores : (state, action: PayloadAction<number>) => { |
||||
const newArr = state.CatProveedores.filter(data => data.id != action.payload); |
||||
state.CatProveedores=newArr |
||||
}, |
||||
}, |
||||
}) |
||||
|
||||
export const { resetCatProveedores, populateCatProveedores, updateCatProveedores, deleteCatProveedores } = CatProveedoresSlice.actions; |
||||
export default CatProveedoresSlice.reducer; |
@ -0,0 +1,32 @@ |
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit' |
||||
import ICatTipoUnidades from '../../../Interfaces/Catalogos/ICatTipoUnidades' |
||||
const CatTipoUnidades: ICatTipoUnidades[] = [] |
||||
const initialState = { CatTipoUnidades } |
||||
|
||||
export const CatTipoUnidadesSlice = createSlice({ |
||||
name: 'CatTipoUnidades', |
||||
initialState: initialState, |
||||
reducers: { |
||||
resetCatTipoUnidades : (state, action: PayloadAction<string>) => { |
||||
state.CatTipoUnidades = [] |
||||
},
|
||||
populateCatTipoUnidades : (state, action: PayloadAction<ICatTipoUnidades[]>) => { |
||||
action.payload.forEach(element => { |
||||
const index = state.CatTipoUnidades.findIndex(object => object.id === element.id) |
||||
if (index<0) state.CatTipoUnidades.push(element) |
||||
}) |
||||
}, |
||||
updateCatTipoUnidades : (state, action: PayloadAction<ICatTipoUnidades>) => { |
||||
const i = state.CatTipoUnidades.findIndex(_element => _element.id === action.payload.id); |
||||
if (i > -1) state.CatTipoUnidades[i] = action.payload; |
||||
else state.CatTipoUnidades.push(action.payload); |
||||
}, |
||||
deleteCatTipoUnidades : (state, action: PayloadAction<number>) => { |
||||
const newArr = state.CatTipoUnidades.filter(data => data.id != action.payload); |
||||
state.CatTipoUnidades=newArr |
||||
}, |
||||
}, |
||||
}) |
||||
|
||||
export const { resetCatTipoUnidades, populateCatTipoUnidades, updateCatTipoUnidades, deleteCatTipoUnidades } = CatTipoUnidadesSlice.actions; |
||||
export default CatTipoUnidadesSlice.reducer; |
@ -0,0 +1,32 @@ |
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit' |
||||
import ICatUbicaciones from '../../../Interfaces/Catalogos/ICatUbicaciones' |
||||
const CatUbicaciones: ICatUbicaciones[] = [] |
||||
const initialState = { CatUbicaciones } |
||||
|
||||
export const CatUbicacionesSlice = createSlice({ |
||||
name: 'CatUbicaciones', |
||||
initialState: initialState, |
||||
reducers: { |
||||
resetCatUbicaciones : (state, action: PayloadAction<string>) => { |
||||
state.CatUbicaciones = [] |
||||
},
|
||||
populateCatUbicaciones : (state, action: PayloadAction<ICatUbicaciones[]>) => { |
||||
action.payload.forEach(element => { |
||||
const index = state.CatUbicaciones.findIndex(object => object.id === element.id) |
||||
if (index<0) state.CatUbicaciones.push(element) |
||||
}) |
||||
}, |
||||
updateCatUbicaciones : (state, action: PayloadAction<ICatUbicaciones>) => { |
||||
const i = state.CatUbicaciones.findIndex(_element => _element.id === action.payload.id); |
||||
if (i > -1) state.CatUbicaciones[i] = action.payload; |
||||
else state.CatUbicaciones.push(action.payload); |
||||
}, |
||||
deleteCatUbicaciones : (state, action: PayloadAction<number>) => { |
||||
const newArr = state.CatUbicaciones.filter(data => data.id != action.payload); |
||||
state.CatUbicaciones=newArr |
||||
}, |
||||
}, |
||||
}) |
||||
|
||||
export const { resetCatUbicaciones, populateCatUbicaciones, updateCatUbicaciones, deleteCatUbicaciones } = CatUbicacionesSlice.actions; |
||||
export default CatUbicacionesSlice.reducer; |
@ -1,6 +0,0 @@ |
||||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' |
||||
import type { RootState, AppDispatch } from './store' |
||||
|
||||
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
||||
export const useAppDispatch = () => useDispatch<AppDispatch>() |
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector |
Loading…
Reference in new issue