Merge pull request #215 from DeimosPr4/UH-reservasInquilinoMovil

Reservación por id de inquilino
This commit is contained in:
Traym17 2022-08-31 22:11:44 -06:00 committed by GitHub
commit cc6a35fde2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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 })));
}
}

View File

@ -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"
}

View File

@ -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'

View File

@ -5,7 +5,6 @@
"requires": true,
"packages": {
"": {
"name": "servicio-reservaciones",
"version": "0.0.1",
"license": "UNLICENSED",
"dependencies": {

View File

@ -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);
}
}

View File

@ -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();
}
}