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) {
|
html(@Body('email') email: string, @Body('name') name: string) {
|
||||||
return this.appService.html(email, name);
|
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;
|
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>
|
<UserContextProvider>
|
||||||
<NavigationContainer>
|
<NavigationContainer>
|
||||||
<Stack.Navigator initialRouteName="LogIn">
|
<Stack.Navigator initialRouteName="LogIn">
|
||||||
<Stack.Screen name="Inicio" component={LogIn} options={{
|
<Stack.Screen name="Inicio" component={Reservas} options={{
|
||||||
headerStyle: {
|
headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ export default function Reservas({navigation}) {
|
||||||
const { user } = useContext(UserContext)
|
const { user } = useContext(UserContext)
|
||||||
const [isRequesting, setIsRequesting] = useState(false);
|
const [isRequesting, setIsRequesting] = useState(false);
|
||||||
const [reservas, setReservas] = useState([]);
|
const [reservas, setReservas] = useState([]);
|
||||||
|
const id = user._id;
|
||||||
|
//const id = "6301df20dac7dcf76dcecade";
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -26,7 +28,7 @@ export default function Reservas({navigation}) {
|
||||||
setIsRequesting(true);
|
setIsRequesting(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonResponse = await fetch(`${API.BASE_URL}/reservation/allReservations`, {
|
const jsonResponse = await fetch(`${API.BASE_URL}/reservation/findReservationUser/`+`${id}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "servicio-reservaciones",
|
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -38,4 +38,10 @@ export class ReservationsController {
|
||||||
let _id = id['id'];
|
let _id = id['id'];
|
||||||
return this.reservationsService.remove(_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,
|
new: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findReservationUser(id: string): Promise<Reservation[]> {
|
||||||
|
return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue