Merge pull request #215 from DeimosPr4/UH-reservasInquilinoMovil
Reservación por id de inquilino
This commit is contained in:
		
						commit
						cc6a35fde2
					
				| 
						 | 
				
			
			@ -600,4 +600,10 @@ export class AppController {
 | 
			
		|||
  html(@Body('email') email: string, @Body('name') name: string) {
 | 
			
		||||
    return this.appService.html(email, name);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Get('reservation/findReservationUser/:id')
 | 
			
		||||
  findReservationUser(@Param('id') paramComment: string) {
 | 
			
		||||
    return this.appService.findReservationUser(paramComment);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -786,4 +786,12 @@ export class AppService {
 | 
			
		|||
 | 
			
		||||
    return pass;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  findReservationUser(paramGuestId: string) {
 | 
			
		||||
    const pattern = { cmd: 'findReservationUser' };
 | 
			
		||||
    const payload = { id: paramGuestId };
 | 
			
		||||
    return this.clientReservationApp
 | 
			
		||||
      .send<string>(pattern, payload)
 | 
			
		||||
      .pipe(map((message: string) => ({ message })));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,7 +72,7 @@ export default function App() {
 | 
			
		|||
      <UserContextProvider>
 | 
			
		||||
        <NavigationContainer>
 | 
			
		||||
          <Stack.Navigator initialRouteName="LogIn">
 | 
			
		||||
            <Stack.Screen name="Inicio" component={LogIn} options={{
 | 
			
		||||
            <Stack.Screen name="Inicio" component={Reservas} options={{
 | 
			
		||||
              headerStyle: {
 | 
			
		||||
                backgroundColor: "#D7A86E"
 | 
			
		||||
              }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,8 @@ export default function Reservas({navigation}) {
 | 
			
		|||
  const { user } = useContext(UserContext)
 | 
			
		||||
  const [isRequesting, setIsRequesting] = useState(false);
 | 
			
		||||
  const [reservas, setReservas] = useState([]);
 | 
			
		||||
  const id = user._id;
 | 
			
		||||
  //const id = "6301df20dac7dcf76dcecade";
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +28,7 @@ export default function Reservas({navigation}) {
 | 
			
		|||
      setIsRequesting(true);
 | 
			
		||||
 | 
			
		||||
      try {
 | 
			
		||||
        const jsonResponse = await fetch(`${API.BASE_URL}/reservation/allReservations`, {
 | 
			
		||||
        const jsonResponse = await fetch(`${API.BASE_URL}/reservation/findReservationUser/`+`${id}`, {
 | 
			
		||||
          method: "GET",
 | 
			
		||||
          headers: {
 | 
			
		||||
            'Content-Type': 'application/json'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "servicio-reservaciones",
 | 
			
		||||
      "version": "0.0.1",
 | 
			
		||||
      "license": "UNLICENSED",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,4 +38,10 @@ export class ReservationsController {
 | 
			
		|||
    let _id = id['id'];
 | 
			
		||||
    return this.reservationsService.remove(_id);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @MessagePattern({ cmd: 'findReservationUser' })
 | 
			
		||||
  findReservationUser(@Payload() id: string) {
 | 
			
		||||
    let _id = id['id'];
 | 
			
		||||
    return this.reservationsService.findReservationUser(_id);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,4 +45,8 @@ export class ReservationsService {
 | 
			
		|||
      new: true,
 | 
			
		||||
    });  
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async findReservationUser(id: string): Promise<Reservation[]> {
 | 
			
		||||
    return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue