From dc30111972ef2814a1b5a61423f67153cf44dbc4 Mon Sep 17 00:00:00 2001 From: Al Garcia Date: Mon, 12 Sep 2022 17:37:39 -0500 Subject: [PATCH] Master Detail del monitor de operaciones quedo de lujo --- src/App.tsx | 4 +- src/Components/Operaciones/OpMonitor.tsx | 196 ++++++++++++------ src/Components/Operaciones/OpViajes.tsx | 1 + src/Components/Operaciones/Viaje/Viaje.tsx | 23 +- .../ViajesServicios/ViajesServicios.tsx | 72 +++++-- src/DTOs/Operaciones/DTOViajes.ts | 2 +- src/DTOs/Operaciones/DTOViajesServicios.ts | 6 + src/Services/Operaciones/OpViajes.Services.ts | 10 + src/css/masterDetail.css | 44 +++- .../Operaciones/OpViajesServiciosSlice.ts | 32 +++ src/store/store.ts | 4 +- 11 files changed, 307 insertions(+), 87 deletions(-) create mode 100644 src/DTOs/Operaciones/DTOViajesServicios.ts create mode 100644 src/store/features/Operaciones/OpViajesServiciosSlice.ts diff --git a/src/App.tsx b/src/App.tsx index 9237c6e..1c350f6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,9 +20,9 @@ import { OpMonitor } from './Components/Operaciones/OpMonitor' function App() { const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado) - useEffect(() => { + /* useEffect(() => { console.log('Entro al proceso de router ' + UserLogued) - }, [UserLogued]) + }, [UserLogued]) */ function PageNotFound() { return ( diff --git a/src/Components/Operaciones/OpMonitor.tsx b/src/Components/Operaciones/OpMonitor.tsx index aa3f5e6..1ca8508 100644 --- a/src/Components/Operaciones/OpMonitor.tsx +++ b/src/Components/Operaciones/OpMonitor.tsx @@ -1,17 +1,19 @@ import React, { FC, useEffect, useState } from 'react' import { Alert, Button, Card, Col, Form, Modal, Row, Table } from 'react-bootstrap' import { IconContext } from 'react-icons' -import { BsFillPencilFill, BsPlusSquareFill } from 'react-icons/bs' - +import { BsChevronDown, BsChevronUp, BsFillPencilFill, BsPlusSquareFill } from 'react-icons/bs' import { useDispatch, useSelector } from 'react-redux' import { RootState } from '../../store/store' - import DTOOpViajes from '../../DTOs/Operaciones/DTOViajes' import DSOpViajes from '../../Services/Operaciones/OpViajes.Services' import { ViajesServicios } from './ViajesServicios/ViajesServicios' -import { populateOpViajes } from '../../store/features/Operaciones/OpViajesSlice' +import { populateOpViajes, updateOpViajes } from '../../store/features/Operaciones/OpViajesSlice' import { Viaje } from './Viaje/Viaje' import '../../css/masterDetail.css' +import { + populateOpViajesServicios, + updateOpViajesServicios, +} from '../../store/features/Operaciones/OpViajesServiciosSlice' interface IProps {} @@ -25,6 +27,7 @@ export const OpMonitor: FC = (props) => { const CatUbicaciones = useSelector((state: RootState) => state.CatUbicaciones.CatUbicaciones) const CatServicios = useSelector((state: RootState) => state.CatServicios.CatServicios) const AllTrips = useSelector((state: RootState) => state.OpViajes.OpViajes) + const AllTripsServices = useSelector((state: RootState) => state.OpViajesServicios.OpViajesServicios) const [OpViajes, setOpViajes] = useState([]) const [showTripDialog, setShowTripDialog] = useState(false) const [Switch, setSwitch] = useState(false) @@ -98,6 +101,7 @@ export const OpMonitor: FC = (props) => { hazmat: Hazmat, noCaja: NoCaja, pickUpNumber: PickUpNumber, + max: true, } DSOpViajes.Append(data) .then((response) => { @@ -119,54 +123,54 @@ export const OpMonitor: FC = (props) => { }) setOpViajes(data) dispatch(populateOpViajes(data)) + DSOpViajes.GetAllServices() + .then((responsed) => { + dispatch(populateOpViajesServicios(responsed.data)) + }) + .catch((e: Error) => {}) }) .catch((e: Error) => {}) } const changeToggle = (row: DTOOpViajes) => { - const data = OpViajes - for (const obj of data) { - if (obj.id === row.id) { - obj.max = !obj.max - setSwitch(obj.max) - break + let x = AllTrips.filter((a) => { + if (a.id === row.id) { + return a } + }) + if (x) { + const obj = { ...x[0] } + obj.max = !obj.max + dispatch(updateOpViajes(obj)) } - // console.log('La informacion ha cambiado: ' + JSON.stringify(data)) - setOpViajes(data) } return (
- - - - - - AOL : Monitor de viajes - - -
{ - newTrip() - }} - title='De un click aqui para crear un nuevo viaje' - > - - - -
- - -
-
-
+ + + + + AOL : Monitor de viajes + + +
{ + newTrip() + }} + title='De un click aqui para crear un nuevo viaje' + > + + + +
+ + +
+
-   - - - + = (props) => { }} /> + + Total: {AllTrips.length} viajes en curso + @@ -184,6 +191,7 @@ export const OpMonitor: FC = (props) => { id +   Cliente Servicio Proveedor @@ -198,32 +206,102 @@ export const OpMonitor: FC = (props) => { - {OpViajes - ? OpViajes.map((MasterData) => { + {AllTrips + ? AllTrips.map((MasterData) => { return ( <> { - changeToggle(MasterData) - }} style={{ cursor: 'pointer' }} + className={MasterData.max === true ? 'masterSelected' : 'normalSelected'} > - {MasterData.id} - {MasterData.sCliente} - {MasterData.sServicio} - {MasterData.sProveedor} - {MasterData.sOrigen} - {MasterData.sDestino} - {MasterData.sTipoUnidad} - {MasterData.noCaja} - {MasterData.hazmat} - {MasterData.refAgenciaAduanal} - {MasterData.pickUpNumber} - + + {MasterData.id} + + { + changeToggle(MasterData) + }} + > + {MasterData.max === true ? ( + + + + ) : ( + + + + )} + + + {MasterData.sCliente} + + + {MasterData.sServicio} + + + {MasterData.sProveedor} + + + {MasterData.sOrigen} + + + {MasterData.sDestino} + + + {MasterData.sTipoUnidad} + + + {MasterData.noCaja} + + + {MasterData.hazmat === 1 ? 'Si' : 'No'} + + + {MasterData.refAgenciaAduanal} + + + {MasterData.pickUpNumber} + + - {MasterData.max === true && Switch === true ? ( + {MasterData.max === true ? ( diff --git a/src/Components/Operaciones/OpViajes.tsx b/src/Components/Operaciones/OpViajes.tsx index 941fe34..25d997d 100644 --- a/src/Components/Operaciones/OpViajes.tsx +++ b/src/Components/Operaciones/OpViajes.tsx @@ -171,6 +171,7 @@ export const OpViajes: FC = (props) => { hazmat: Hazmat, noCaja: NoCaja, pickUpNumber: PickUpNumber, + max: true, } DSOpViajes.Append(data) .then((response) => { diff --git a/src/Components/Operaciones/Viaje/Viaje.tsx b/src/Components/Operaciones/Viaje/Viaje.tsx index 000bc5f..9d31978 100644 --- a/src/Components/Operaciones/Viaje/Viaje.tsx +++ b/src/Components/Operaciones/Viaje/Viaje.tsx @@ -5,6 +5,8 @@ import DTOOpViajes from '../../../DTOs/Operaciones/DTOViajes' import DSOpViajes from '../../../Services/Operaciones/OpViajes.Services' import { updateOpViajes } from '../../../store/features/Operaciones/OpViajesSlice' import { RootState } from '../../../store/store' +import { populateOpViajesServicios } from '../../../store/features/Operaciones/OpViajesServiciosSlice' +import DTOViajesServicios from '../../../DTOs/Operaciones/DTOViajesServicios' interface IProps { IDViaje: number @@ -38,7 +40,6 @@ export const Viaje: FC = (props) => { useEffect(() => { let selectedRow = mAllTrips.filter((row) => { - console.log(row.id) if (row.id === props.IDViaje) { setIDViaje(row.id) setRefAA(row.refAgenciaAduanal) @@ -58,7 +59,20 @@ export const Viaje: FC = (props) => { // console.log(JSON.stringify(selectedRow) + ' ' + props.IDViaje) }, [props.IDViaje]) - const addNewService = () => {} + const addService = () => { + const data: DTOViajesServicios = { + id: 0, + idServicio: IDNuevoServicio, + sServicio: '', + idViaje: props.IDViaje, + } + DSOpViajes.AppendServices(data) + .then((responsed) => { + console.log('Item regresado del post=' + JSON.stringify(responsed.data)) + dispatch(populateOpViajesServicios(responsed.data)) + }) + .catch((e: Error) => {}) + } const saveInfo = () => { const data: DTOOpViajes = { @@ -82,9 +96,12 @@ export const Viaje: FC = (props) => { hazmat: Hazmat, noCaja: NoCaja, pickUpNumber: PickUpNumber, + max: true, } DSOpViajes.Append(data) .then((response) => { + const data = response.data + data['max'] = false dispatch(updateOpViajes(data)) }) .catch((e: Error) => {}) @@ -326,7 +343,7 @@ export const Viaje: FC = (props) => {