Master Detail del monitor de operaciones quedo de lujo

develop
Al Garcia 2 years ago
parent ee10f1d43b
commit dc30111972
  1. 4
      src/App.tsx
  2. 154
      src/Components/Operaciones/OpMonitor.tsx
  3. 1
      src/Components/Operaciones/OpViajes.tsx
  4. 23
      src/Components/Operaciones/Viaje/Viaje.tsx
  5. 72
      src/Components/Operaciones/ViajesServicios/ViajesServicios.tsx
  6. 2
      src/DTOs/Operaciones/DTOViajes.ts
  7. 6
      src/DTOs/Operaciones/DTOViajesServicios.ts
  8. 10
      src/Services/Operaciones/OpViajes.Services.ts
  9. 44
      src/css/masterDetail.css
  10. 32
      src/store/features/Operaciones/OpViajesServiciosSlice.ts
  11. 4
      src/store/store.ts

@ -20,9 +20,9 @@ import { OpMonitor } from './Components/Operaciones/OpMonitor'
function App() { function App() {
const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado) const UserLogued = useSelector((state: RootState) => state.UserProfile.UserProfile.logueado)
useEffect(() => { /* useEffect(() => {
console.log('Entro al proceso de router ' + UserLogued) console.log('Entro al proceso de router ' + UserLogued)
}, [UserLogued]) }, [UserLogued]) */
function PageNotFound() { function PageNotFound() {
return ( return (

@ -1,17 +1,19 @@
import React, { FC, useEffect, useState } from 'react' import React, { FC, useEffect, useState } from 'react'
import { Alert, Button, Card, Col, Form, Modal, Row, Table } from 'react-bootstrap' import { Alert, Button, Card, Col, Form, Modal, Row, Table } from 'react-bootstrap'
import { IconContext } from 'react-icons' 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 { useDispatch, useSelector } from 'react-redux'
import { RootState } from '../../store/store' import { RootState } from '../../store/store'
import DTOOpViajes from '../../DTOs/Operaciones/DTOViajes' import DTOOpViajes from '../../DTOs/Operaciones/DTOViajes'
import DSOpViajes from '../../Services/Operaciones/OpViajes.Services' import DSOpViajes from '../../Services/Operaciones/OpViajes.Services'
import { ViajesServicios } from './ViajesServicios/ViajesServicios' 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 { Viaje } from './Viaje/Viaje'
import '../../css/masterDetail.css' import '../../css/masterDetail.css'
import {
populateOpViajesServicios,
updateOpViajesServicios,
} from '../../store/features/Operaciones/OpViajesServiciosSlice'
interface IProps {} interface IProps {}
@ -25,6 +27,7 @@ export const OpMonitor: FC<IProps> = (props) => {
const CatUbicaciones = useSelector((state: RootState) => state.CatUbicaciones.CatUbicaciones) const CatUbicaciones = useSelector((state: RootState) => state.CatUbicaciones.CatUbicaciones)
const CatServicios = useSelector((state: RootState) => state.CatServicios.CatServicios) const CatServicios = useSelector((state: RootState) => state.CatServicios.CatServicios)
const AllTrips = useSelector((state: RootState) => state.OpViajes.OpViajes) const AllTrips = useSelector((state: RootState) => state.OpViajes.OpViajes)
const AllTripsServices = useSelector((state: RootState) => state.OpViajesServicios.OpViajesServicios)
const [OpViajes, setOpViajes] = useState<DTOOpViajes[]>([]) const [OpViajes, setOpViajes] = useState<DTOOpViajes[]>([])
const [showTripDialog, setShowTripDialog] = useState(false) const [showTripDialog, setShowTripDialog] = useState(false)
const [Switch, setSwitch] = useState(false) const [Switch, setSwitch] = useState(false)
@ -98,6 +101,7 @@ export const OpMonitor: FC<IProps> = (props) => {
hazmat: Hazmat, hazmat: Hazmat,
noCaja: NoCaja, noCaja: NoCaja,
pickUpNumber: PickUpNumber, pickUpNumber: PickUpNumber,
max: true,
} }
DSOpViajes.Append(data) DSOpViajes.Append(data)
.then((response) => { .then((response) => {
@ -119,30 +123,34 @@ export const OpMonitor: FC<IProps> = (props) => {
}) })
setOpViajes(data) setOpViajes(data)
dispatch(populateOpViajes(data)) dispatch(populateOpViajes(data))
DSOpViajes.GetAllServices()
.then((responsed) => {
dispatch(populateOpViajesServicios(responsed.data))
})
.catch((e: Error) => {})
}) })
.catch((e: Error) => {}) .catch((e: Error) => {})
} }
const changeToggle = (row: DTOOpViajes) => { const changeToggle = (row: DTOOpViajes) => {
const data = OpViajes let x = AllTrips.filter((a) => {
for (const obj of data) { if (a.id === row.id) {
if (obj.id === row.id) { return a
obj.max = !obj.max
setSwitch(obj.max)
break
} }
})
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 ( return (
<div> <div>
<Card> <Card style={{ textAlign: 'left' }}>
<Card.Title style={{ textAlign: 'left' }}>
<Alert variant='primary'> <Alert variant='primary'>
<Row> <Row>
<Col xs={2} style={{ textAlign: 'right' }}> <Col xs={3} style={{ textAlign: 'right', fontSize: '25px' }}>
AOL : Monitor de viajes AOL : Monitor de viajes
</Col> </Col>
<Col xs={1} style={{ textAlign: 'left', cursor: 'pointer' }}> <Col xs={1} style={{ textAlign: 'left', cursor: 'pointer' }}>
@ -157,16 +165,12 @@ export const OpMonitor: FC<IProps> = (props) => {
</IconContext.Provider> </IconContext.Provider>
</div> </div>
</Col> </Col>
<Col xs={9}></Col> <Col xs={8}></Col>
</Row> </Row>
</Alert> </Alert>
</Card.Title>
</Card> </Card>
<Row> <Row>
<Col xs={12}>&nbsp;</Col> <Col xs={10}>
</Row>
<Row>
<Col xs={12}>
<Form.Control <Form.Control
type='text' type='text'
size='sm' size='sm'
@ -176,6 +180,9 @@ export const OpMonitor: FC<IProps> = (props) => {
}} }}
/> />
</Col> </Col>
<Col xs={2} className='totalLabel'>
Total: {AllTrips.length} viajes en curso
</Col>
</Row> </Row>
<Card> <Card>
<Card.Body> <Card.Body>
@ -184,6 +191,7 @@ export const OpMonitor: FC<IProps> = (props) => {
<thead style={{ position: 'sticky', top: '0' }}> <thead style={{ position: 'sticky', top: '0' }}>
<tr> <tr>
<th>id</th> <th>id</th>
<th>&nbsp;</th>
<th>Cliente</th> <th>Cliente</th>
<th>Servicio</th> <th>Servicio</th>
<th>Proveedor</th> <th>Proveedor</th>
@ -198,32 +206,102 @@ export const OpMonitor: FC<IProps> = (props) => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{OpViajes {AllTrips
? OpViajes.map((MasterData) => { ? AllTrips.map((MasterData) => {
return ( return (
<> <>
<tr <tr
style={{ cursor: 'pointer' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.id}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
key={MasterData.id} key={MasterData.id}
onClick={() => { onClick={() => {
changeToggle(MasterData) changeToggle(MasterData)
}} }}
style={{ cursor: 'pointer' }}
> >
<td style={{ textAlign: 'left' }}>{MasterData.id}</td> {MasterData.max === true ? (
<td style={{ textAlign: 'left' }}>{MasterData.sCliente}</td> <IconContext.Provider value={{ color: 'blue', size: '15px' }}>
<td style={{ textAlign: 'left' }}>{MasterData.sServicio}</td> <BsChevronDown />
<td style={{ textAlign: 'left' }}>{MasterData.sProveedor}</td> </IconContext.Provider>
<td style={{ textAlign: 'left' }}>{MasterData.sOrigen}</td> ) : (
<td style={{ textAlign: 'left' }}>{MasterData.sDestino}</td> <IconContext.Provider value={{ color: 'blue', size: '15px' }}>
<td style={{ textAlign: 'left' }}>{MasterData.sTipoUnidad}</td> <BsChevronUp />
<td style={{ textAlign: 'left' }}>{MasterData.noCaja}</td> </IconContext.Provider>
<td style={{ textAlign: 'left' }}>{MasterData.hazmat}</td> )}
<td style={{ textAlign: 'left' }}>{MasterData.refAgenciaAduanal}</td> </td>
<td style={{ textAlign: 'left' }}>{MasterData.pickUpNumber}</td> <td
<td> style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.sCliente}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.sServicio}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.sProveedor}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.sOrigen}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.sDestino}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.sTipoUnidad}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.noCaja}
</td>
<td
style={{ textAlign: 'center' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.hazmat === 1 ? 'Si' : 'No'}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.refAgenciaAduanal}
</td>
<td
style={{ textAlign: 'left' }}
className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}
>
{MasterData.pickUpNumber}
</td>
<td className={MasterData.max === true ? 'masterSelected' : 'normalSelected'}>
<Button <Button
size='sm' size='sm'
variant='light' variant='white'
style={{ textAlign: 'right' }} style={{ textAlign: 'right' }}
onClick={() => { onClick={() => {
EditMaster(MasterData) EditMaster(MasterData)
@ -235,7 +313,7 @@ export const OpMonitor: FC<IProps> = (props) => {
</Button> </Button>
</td> </td>
</tr> </tr>
{MasterData.max === true && Switch === true ? ( {MasterData.max === true ? (
<tr> <tr>
<th colSpan={2} style={{ backgroundColor: '#F8F9FE' }}></th> <th colSpan={2} style={{ backgroundColor: '#F8F9FE' }}></th>
<th colSpan={14} style={{ backgroundColor: '#F8F9FE' }}> <th colSpan={14} style={{ backgroundColor: '#F8F9FE' }}>

@ -171,6 +171,7 @@ export const OpViajes: FC<IProps> = (props) => {
hazmat: Hazmat, hazmat: Hazmat,
noCaja: NoCaja, noCaja: NoCaja,
pickUpNumber: PickUpNumber, pickUpNumber: PickUpNumber,
max: true,
} }
DSOpViajes.Append(data) DSOpViajes.Append(data)
.then((response) => { .then((response) => {

@ -5,6 +5,8 @@ import DTOOpViajes from '../../../DTOs/Operaciones/DTOViajes'
import DSOpViajes from '../../../Services/Operaciones/OpViajes.Services' import DSOpViajes from '../../../Services/Operaciones/OpViajes.Services'
import { updateOpViajes } from '../../../store/features/Operaciones/OpViajesSlice' import { updateOpViajes } from '../../../store/features/Operaciones/OpViajesSlice'
import { RootState } from '../../../store/store' import { RootState } from '../../../store/store'
import { populateOpViajesServicios } from '../../../store/features/Operaciones/OpViajesServiciosSlice'
import DTOViajesServicios from '../../../DTOs/Operaciones/DTOViajesServicios'
interface IProps { interface IProps {
IDViaje: number IDViaje: number
@ -38,7 +40,6 @@ export const Viaje: FC<IProps> = (props) => {
useEffect(() => { useEffect(() => {
let selectedRow = mAllTrips.filter((row) => { let selectedRow = mAllTrips.filter((row) => {
console.log(row.id)
if (row.id === props.IDViaje) { if (row.id === props.IDViaje) {
setIDViaje(row.id) setIDViaje(row.id)
setRefAA(row.refAgenciaAduanal) setRefAA(row.refAgenciaAduanal)
@ -58,7 +59,20 @@ export const Viaje: FC<IProps> = (props) => {
// console.log(JSON.stringify(selectedRow) + ' ' + props.IDViaje) // console.log(JSON.stringify(selectedRow) + ' ' + props.IDViaje)
}, [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 saveInfo = () => {
const data: DTOOpViajes = { const data: DTOOpViajes = {
@ -82,9 +96,12 @@ export const Viaje: FC<IProps> = (props) => {
hazmat: Hazmat, hazmat: Hazmat,
noCaja: NoCaja, noCaja: NoCaja,
pickUpNumber: PickUpNumber, pickUpNumber: PickUpNumber,
max: true,
} }
DSOpViajes.Append(data) DSOpViajes.Append(data)
.then((response) => { .then((response) => {
const data = response.data
data['max'] = false
dispatch(updateOpViajes(data)) dispatch(updateOpViajes(data))
}) })
.catch((e: Error) => {}) .catch((e: Error) => {})
@ -326,7 +343,7 @@ export const Viaje: FC<IProps> = (props) => {
<Button <Button
variant='warning' variant='warning'
onClick={() => { onClick={() => {
addNewService() addService()
}} }}
> >
Agrega Agrega

@ -1,34 +1,76 @@
import React, { FC, useState } from 'react' import React, { FC, useState } from 'react'
import { Button } from 'react-bootstrap'
import { IconContext } from 'react-icons'
import { BsFillPencilFill, BsXSquareFill } from 'react-icons/bs'
import { useDispatch, useSelector } from 'react-redux'
import DTOOpViajes from '../../../DTOs/Operaciones/DTOViajes' import DTOOpViajes from '../../../DTOs/Operaciones/DTOViajes'
import DTOViajesServicios from '../../../DTOs/Operaciones/DTOViajesServicios'
import { RootState } from '../../../store/store'
import DSOpViajes from '../../../Services/Operaciones/OpViajes.Services'
import { deleteOpViajesServicios } from '../../../store/features/Operaciones/OpViajesServiciosSlice'
interface IProps { interface IProps {
DataMaster: DTOOpViajes DataMaster: DTOOpViajes
} }
/**
* @author
* @function @ViajesServicios
**/
export const ViajesServicios: FC<IProps> = (props) => { export const ViajesServicios: FC<IProps> = (props) => {
const dispatch = useDispatch()
const AllTripsServices = useSelector((state: RootState) => state.OpViajesServicios.OpViajesServicios)
const [DisplayTable, setDisplayTable] = useState(true) const [DisplayTable, setDisplayTable] = useState(true)
const deleteService = (id: number) => {
DSOpViajes.DeleteService(id)
.then((responsed) => {
dispatch(deleteOpViajesServicios(id))
})
.catch((e: Error) => {})
}
return ( return (
<div> <div>
<table className='zui-table zui-table-rounded'> <table className='zui-table zui-table-rounded'>
<thead> <thead>
<tr> <tr>
<th style={{ width: '50px', textAlign: 'center' }}>Partida</th> <th style={{ width: '50px', textAlign: 'center' }}>id</th>
<th style={{ width: '100px', textAlign: 'right' }}>Peso bruto</th> <th style={{ width: '300px', textAlign: 'left' }}>Servicio</th>
<th style={{ width: '100px', textAlign: 'right' }}>Pallets</th> <th style={{ width: '50px', textAlign: 'center' }}></th>
<th style={{ width: '250px', textAlign: 'left' }}>Producto Materia Prima</th>
<th style={{ width: '180px' }}>Fraccion Arancelaria</th>
<th style={{ width: '100px' }}>Clave SAT</th>
<th style={{ width: '250px' }}>Concepto Producto MP</th>
<th style={{ width: '50px', textAlign: 'center' }}>Edita</th>
<th style={{ width: '300px' }}>Empaque (descripcion)</th>
<th style={{ width: '100px' }}>Clave SAT</th>
</tr> </tr>
</thead> </thead>
<tbody>
{AllTripsServices
? AllTripsServices.filter(function (service) {
return service.idViaje === props.DataMaster.id
}).map(function (service) {
return (
<tr
key={service.id}
onClick={() => {
// changeToggle(MasterData)
}}
style={{ cursor: 'pointer' }}
>
<td style={{ textAlign: 'left', paddingLeft: '5px' }}>{service.id}</td>
<td style={{ textAlign: 'left' }}>{service.sServicio}</td>
<td>
<Button
size='sm'
variant='white'
style={{ textAlign: 'right' }}
title='De un click aqui para eliminar el servicio'
onClick={() => {
deleteService(service.id)
}}
>
<IconContext.Provider value={{ color: 'red', size: '20px' }}>
<BsXSquareFill />
</IconContext.Provider>
</Button>
</td>
</tr>
)
})
: ''}
</tbody>
</table> </table>
</div> </div>
) )

@ -19,5 +19,5 @@ export default interface DTOOpViajes {
sDestino: string, sDestino: string,
servicio: number, servicio: number,
sServicio: string, sServicio: string,
max?: boolean max: boolean
} }

@ -0,0 +1,6 @@
export default interface DTOViajesServicios {
id: number,
idViaje: number,
idServicio: number,
sServicio: string
}

@ -1,16 +1,26 @@
import http from "../../Services/Auth/config/http-common"; import http from "../../Services/Auth/config/http-common";
import DTOViajes from "../../DTOs/Operaciones/DTOViajes"; import DTOViajes from "../../DTOs/Operaciones/DTOViajes";
import IRespuesta from "../../Interfaces/Respuestas/IRespuesta"; import IRespuesta from "../../Interfaces/Respuestas/IRespuesta";
import DTOViajesServicios from "../../DTOs/Operaciones/DTOViajesServicios";
class OpViajesDataService { class OpViajesDataService {
Get() { Get() {
return http.get<DTOViajes[]>("Operaciones/OpViajes/Get"); return http.get<DTOViajes[]>("Operaciones/OpViajes/Get");
} }
GetAllServices() {
return http.get<DTOViajesServicios[]>("Operaciones/OpViajes/GetAllServices");
}
Append(data: DTOViajes) { Append(data: DTOViajes) {
return http.post<DTOViajes>(`Operaciones/OpViajes/Append`,data); return http.post<DTOViajes>(`Operaciones/OpViajes/Append`,data);
} }
AppendServices(data: DTOViajesServicios) {
return http.post<DTOViajesServicios[]>(`Operaciones/OpViajes/AppendService`,data);
}
Delete(id: number) { Delete(id: number) {
return http.delete<IRespuesta>(`Operaciones/OpViajes/Delete/${id}`); return http.delete<IRespuesta>(`Operaciones/OpViajes/Delete/${id}`);
} }
DeleteService(id: number) {
return http.delete<IRespuesta>(`Operaciones/OpViajes/DeleteService/${id}`);
}
} }
export default new OpViajesDataService(); export default new OpViajesDataService();

@ -1,5 +1,5 @@
.MDTable { .MDTable {
width: 1500px; width: 100%;
font-size: 0.6em; font-size: 0.6em;
font-family: Verdana, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif; font-family: Verdana, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
background-color: #ffffff; background-color: #ffffff;
@ -28,7 +28,7 @@
background-color: #255dde; background-color: #255dde;
color: #FFFFFF; color: #FFFFFF;
height: 25px; height: 25px;
text-align: left; text-align: left !important;
} }
.MDTable tbody tr td { .MDTable tbody tr td {
@ -53,6 +53,38 @@
overflow: auto; overflow: auto;
} }
.totalLabel {
color: #f4a005;
font-size: larger;
font-weight: bold;
background-color: #ffffff;
text-shadow: 1px 1px 1px rgb(246, 218, 6);
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif
}
.masterSelected {
/* background-color: #dbe5f3 !important; */
/* font-weight: bold; */
color: #000000;
/* border-top: solid 2px #f40505;*/
border-bottom: solid 2px #f4a005;
/* text-shadow: 1px 1px 1px #fff; */
/* background-color: #72a9a9 !important;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; */
}
.notmalSelected {
/* background-color: #6695db !important; */
/* font-weight: bold; */
color: #000000;
border-top: none;
border-bottom: none;
text-align: center;
/* text-shadow: 1px 1px 1px #fff; */
/* background-color: #72a9a9 !important;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; */
}
.zui-table { .zui-table {
border: solid 1px #DDEEEE; border: solid 1px #DDEEEE;
border-collapse: collapse; border-collapse: collapse;
@ -70,7 +102,7 @@
} }
.zui-table tbody td { .zui-table tbody td {
border: dotted 1px #DDEEEE; border: solid 1px #DDEEEE;
color: #333; color: #333;
padding: 0px; padding: 0px;
text-shadow: 1px 1px 1px #fff; text-shadow: 1px 1px 1px #fff;
@ -83,7 +115,7 @@
} }
.zui-table-rounded thead th { .zui-table-rounded thead th {
background-color: #CFAD70; background-color: #70c1cf;
border: none; border: none;
text-shadow: 1px 1px 1px #ccc; text-shadow: 1px 1px 1px #ccc;
color: #333; color: #333;
@ -99,8 +131,8 @@
.zui-table-rounded tbody tr td { .zui-table-rounded tbody tr td {
border: none; border: none;
border-top: dotted 1px #09840f; border-top: solid 1px #09840f;
background-color: #EED592; background-color: #ffffff;
border-bottom: none; border-bottom: none;
} }

@ -0,0 +1,32 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import DTOViajesServicios from '../../../DTOs/Operaciones/DTOViajesServicios'
const OpViajesServicios: DTOViajesServicios[] = []
const initialState = { OpViajesServicios }
export const OpViajesServiciosSlice = createSlice({
name: 'OpViajesServicios',
initialState: initialState,
reducers: {
resetOpViajesServicios : (state, action: PayloadAction<string>) => {
state.OpViajesServicios = []
},
populateOpViajesServicios : (state, action: PayloadAction<DTOViajesServicios[]>) => {
action.payload.forEach(element => {
const index = state.OpViajesServicios.findIndex(object => object.id === element.id)
if (index<0) state.OpViajesServicios.push(element)
})
},
updateOpViajesServicios : (state, action: PayloadAction<DTOViajesServicios>) => {
const i = state.OpViajesServicios.findIndex(_element => _element.id === action.payload.id);
if (i > -1) state.OpViajesServicios[i] = action.payload;
else state.OpViajesServicios.push(action.payload);
},
deleteOpViajesServicios : (state, action: PayloadAction<number>) => {
const newArr = state.OpViajesServicios.filter(data => data.id != action.payload);
state.OpViajesServicios=newArr
},
},
})
export const { resetOpViajesServicios, populateOpViajesServicios, updateOpViajesServicios, deleteOpViajesServicios } = OpViajesServiciosSlice.actions;
export default OpViajesServiciosSlice.reducer;

@ -8,6 +8,7 @@ import { CatServiciosSlice } from './features/Catalogos/CatServiciosSlice'
import { CatTipoUnidadesSlice } from './features/Catalogos/CatTipoUnidadesSlice' import { CatTipoUnidadesSlice } from './features/Catalogos/CatTipoUnidadesSlice'
import { CatUbicacionesSlice } from './features/Catalogos/CatUbicacionesSlice' import { CatUbicacionesSlice } from './features/Catalogos/CatUbicacionesSlice'
import { OpViajesSlice } from './features/Operaciones/OpViajesSlice' import { OpViajesSlice } from './features/Operaciones/OpViajesSlice'
import { OpViajesServiciosSlice } from './features/Operaciones/OpViajesServiciosSlice'
export const store = configureStore({ export const store = configureStore({
reducer: { reducer: {
@ -18,7 +19,8 @@ export const store = configureStore({
CatTipoUnidades: CatTipoUnidadesSlice.reducer, CatTipoUnidades: CatTipoUnidadesSlice.reducer,
CatUbicaciones: CatUbicacionesSlice.reducer, CatUbicaciones: CatUbicacionesSlice.reducer,
CatServicios: CatServiciosSlice.reducer, CatServicios: CatServiciosSlice.reducer,
OpViajes: OpViajesSlice.reducer OpViajes: OpViajesSlice.reducer,
OpViajesServicios: OpViajesServiciosSlice.reducer
} }
}) })

Loading…
Cancel
Save