Merge pull request #216 from DeimosPr4/movil

Movil
This commit is contained in:
Eduardo Quiros 2022-09-01 05:44:02 +00:00 committed by GitHub
commit f37627f662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 779 additions and 334 deletions

View File

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

View File

@ -149,12 +149,7 @@ export class AppController {
@Body('last_name') last_name: string,
@Body('email') email: string,
@Body('phone') phone: number,
@Body('password') password: string,
@Body('user_type') user_type: string,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
@Body('community_id') community_id: string,
@Body('number_house') number_house: string,
) {
return this.appService.updateUser(
id,
@ -163,12 +158,7 @@ export class AppController {
last_name,
email,
phone,
password,
user_type,
status,
date_entry,
community_id,
number_house,
community_id
);
}
@ -255,12 +245,7 @@ export class AppController {
last_name,
email,
phone,
password,
user_type,
status,
date_entry,
community_id,
number_house,
password
);
}
@ -481,6 +466,7 @@ export class AppController {
@Body('tenant_id') tenant_id: string,
@Body('community_id') community_id: string,
@Body('date_entry') date_entry: Date,
@Body('type_guest') type_guest: string,
) {
return this.appService.createGuest(
name,
@ -492,6 +478,7 @@ export class AppController {
tenant_id,
community_id,
date_entry,
type_guest,
);
}
@ -510,6 +497,16 @@ export class AppController {
return this.appService.findGuestUser(paramGuestId);
}
@Get('guest/findGuestCommunity/:id')
findGuestCommunityr(@Param('id') paramGuestId: string) {
return this.appService.findGuestCommunityr(paramGuestId);
}
@Post('guest/updateGuest')
updateGuest(
@Body('_id') _id: string){
return this.appService.updateGuest(_id);
}
@ -586,7 +583,10 @@ export class AppController {
allPosts() {
return this.appService.allPosts();
}
@Get('post/findPostCommunity/:id')
findPostCommunity(@Param('id') paramPost: string) {
return this.appService.findPostCommunity(paramPost);
}
@Get('post/find/:id')
findPost(@Param('id') paramPost: string) {
return this.appService.findPost(paramPost);
@ -654,4 +654,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

@ -94,12 +94,7 @@ export class AppService {
last_name: string,
email: string,
phone: number,
password: string,
user_type: string,
status: string,
date_entry: Date,
community_id: string,
number_house: string,
) {
const pattern = { cmd: 'updateUser' };
const payload = {
@ -109,12 +104,7 @@ export class AppService {
last_name: last_name,
email: email,
phone: phone,
password: password,
user_type: user_type,
status: status,
date_entry: date_entry,
community_id: community_id,
number_house: number_house,
};
return this.clientUserApp
.send<string>(pattern, payload)
@ -368,6 +358,7 @@ export class AppService {
.pipe(map((message: string) => ({ message })));
}
//GET parameter from API
findCommunityAdmin(community_id: string) {
const pattern = { cmd: 'findCommunityAdmin' };
@ -586,11 +577,13 @@ export class AppService {
tenant_id: string,
community_id: string,
date_entry: Date,
type_guest: string,
) {
const pattern = { cmd: 'createGuest' };
const payload = {
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
status: status, tenant_id: tenant_id, community_id: community_id, date_entry: date_entry
status: status,tenant_id:tenant_id, community_id:community_id,date_entry: date_entry,type_guest:type_guest
};
return this.clientGuestApp
.send<string>(pattern, payload)
@ -616,12 +609,30 @@ export class AppService {
//GET parameter from API
findGuestUser(paramGuestId: string) {
const pattern = { cmd: 'findGuestUser' };
const payload = { di: paramGuestId };
const payload = { id: paramGuestId };
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
findGuestCommunityr(paramGuestId: string) {
const pattern = { cmd: 'findGuestCommunity' };
const payload = { id: paramGuestId };
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
updateGuest(_id: string
) {
const pattern = { cmd: 'removeGuest' };
const payload = {
_id: _id
};
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })))
}
// ====================== RESERVATIONS ===============================
//POST parameter from API
@ -706,6 +717,14 @@ export class AppService {
.pipe(map((message: string) => ({ message })));
}
findPostCommunity(paramGuestId: string) {
const pattern = { cmd: 'findPostCommunity' };
const payload = { id: paramGuestId };
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
//GET parameter from API
findPost(paramPostId: string) {
const pattern = { cmd: 'findOnePost' };
@ -804,8 +823,6 @@ export class AppService {
.pipe(map((message: string) => ({ message })));
}
/* Function to generate combination of password */
generatePassword() {
var pass = '';
@ -822,8 +839,6 @@ export class AppService {
return pass;
}
async saveTenantNumHouse(community_id: string, number_house: string, tenant_id: string) {
const pattern = { cmd: 'saveTenantNumHouse' }
@ -836,4 +851,13 @@ export class AppService {
)
}
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

@ -27,14 +27,14 @@ function HomeTab({ route }) {
return (
<Tab.Navigator initialParams={user} initialRouteName="Comunicados" >
<Tab.Screen name="Comunicados" component={Home} initialParams={user} options={{headerStyle: {
<Tab.Screen name="Mis Comunicados" component={Home} initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}
/>
<Tab.Screen name="Reservas" component={Reservas } initialParams={user} options={{headerStyle: {
<Tab.Screen name="Mis Reservas" component={Reservas } initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
<Tab.Screen name="Invitados" component={Invitados} initialParams={user} options={{headerStyle: {
<Tab.Screen name="Mis Invitados" component={Invitados} initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'contacts' : 'contacts-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
<Tab.Screen name="Perfil" component={Profile} initialParams={user} options={{headerStyle: {
@ -44,25 +44,53 @@ function HomeTab({ route }) {
)
}
function HomeTabGuarda({ route }) {
const { user } = useContext(UserContext);
const [selected, setSelected] = useState(0);
return (
<Tab.Navigator initialParams={user} initialRouteName="Comunicados" >
<Tab.Screen name="Mis Comunicados Guarda" component={Home} initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}
/>
<Tab.Screen name="Mis Invitados" component={Invitados} initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'contacts' : 'contacts-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
<Tab.Screen name="Mi Perfil" component={Profile} initialParams={user} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 2 ? 'account' : 'account-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(2)} />
</Tab.Navigator>
)
}
export default function App() {
return (
<NativeBaseProvider>
<UserContextProvider>
<NavigationContainer>
<Stack.Navigator initialRouteName="LogIn">
<Stack.Screen name="Inicio" component={LogIn} options={{
<Stack.Navigator initialRouteName="Iniciar Sesión">
{/* <Stack.Screen name="Mis Reservas" component={Reservas} options={{
headerStyle: {
backgroundColor: "#D7A86E"
}
}} />
}} /> */}
<Stack.Screen name="Comunicados" component={HomeTab} options={{ headerShown: false }} />
<Stack.Screen name="Password" component={RecoverPassword} />
<Stack.Screen name="area" component={AreaComun} options={{
<Stack.Screen name="Comunicados Guarda" component={HomeTabGuarda} options={{ headerShown: false }} />
<Stack.Screen name="Reservar" component={AreaComun} options={{
headerStyle: {
backgroundColor: "#D7A86E"
}
}} />
<Stack.Screen name="invitado" component={AgregarInvitados} options={{
<Stack.Screen name="Agregar Invitado" component={AgregarInvitados} options={{
headerStyle: {
backgroundColor: "#D7A86E"
}
}} />
<Stack.Screen name="Iniciar Sesión" component={LogIn} options={{
headerStyle: {
backgroundColor: "#D7A86E"
}

View File

@ -1,9 +1,9 @@
import React, { useContext, useState } from "react";
import { API } from "../environment/api";
import { MaterialCommunityIcons } from '@expo/vector-icons';
import {
Box, Button,
Center, FormControl, Heading, ScrollView, VStack
Center, FormControl, Heading, ScrollView, VStack,Select
} from "native-base";
import { StyleSheet, TextInput } from "react-native";
@ -20,26 +20,72 @@ export default function AgregarInvitados({ navigation }) {
const [tenant_id, setTenant_id] = useState();
const [community_id, setCommunity_id] = useState();
const { user } = useContext(UserContext);
const [errors, setErrors] = useState({});
const [categoria, setCategoria] = React.useState("");
const saveInvitado = async() => {
const [info, setInfo] = useState({
name: "",
last_name: "",
dni: "",
phone: "",
number_plate:"",
status: "1",
tenant_id: user._id,
//tenant_id: "6301df20dac7dcf76dcecade",
community_id: user.community_id,
//community_id: "62be68215692582bbfd77134",
type_guest:""
});
const data = {
"name": name,
"last_name": apellido,
"dni": dni,
"phone": phone,
"number_plate": number_plate,
"tenant_id": user.id,
"community_id": user.community_id
const onHandleChange = (name) => (value) => setInfo(prev => ({...prev, [name]: value}))
const validate = async() => {
if( info.name === "" && info.last_name === "" && info.dni === "" && info.phone === ""){
setErrors({ ...errors,
name: 'Debe ingresar un nombre',
last_name: 'Debe ingresar un apellido',
dni: 'Debe ingresar un número de identificación',
phone: 'Debe ingresar un número de teléfono'
});
return false;
}else if (info.name === "" ) {
setErrors({ ...errors,
name: 'Debe ingresar un nombre'
});
return false;
} else if(info.last_name === ""){
setErrors({ ...errors,
last_name: 'Debe ingresar un apellido'
});
return false;
}else if (info.dni === "") {
setErrors({ ...errors,
dni: 'Debe ingresar un número de identificación'
});
return false;
}else if (info.phone === "") {
setErrors({ ...errors,
phone: 'Debe ingresar un número de teléfono'
});
return false;
}
return true;
}
const saveInvitado = async() => {
const error = await validate();
if (error) {
try {
await fetch(baseURL, {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
body: JSON.stringify(info),
headers: {
'Content-Type': 'application/json'
}
@ -48,6 +94,7 @@ export default function AgregarInvitados({ navigation }) {
if (response.status != 201){
console.log('ocurrio un error ');
}else{
navigation.navigate('Inicio');
return response.json();
}
})
@ -56,10 +103,13 @@ export default function AgregarInvitados({ navigation }) {
console.log("ERROR: " + error);
}
}
}
return (
<Center>
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
<ScrollView width='100%' h='570' ml='36' _contentContainerStyle={{
px: "20px",
mb: "4",
minW: "72"
@ -75,22 +125,41 @@ export default function AgregarInvitados({ navigation }) {
}} fontWeight="medium" size="xs">
Registre el invitado que desee
</Heading>
<VStack space={3} mt="5">
<VStack space={5} mt="5">
<FormControl isRequired>
<FormControl.Label>Nombre</FormControl.Label>
<TextInput style={styles.input} type="text" onChangeText={(value) => setName(value)}/>
<TextInput style={'name' in errors ? styles.errorMessage : styles.input} type="text" onChangeText={onHandleChange("name")}/>
{'name' in errors && <FormControl.ErrorMessage _text={{
fontSize: 'xs'
}}>Debe ingresar un correo electrónico</FormControl.ErrorMessage> }
</FormControl>
<FormControl isRequired>
<FormControl.Label>Apellido</FormControl.Label>
<TextInput style={styles.input} type="text" onChangeText={(value) => setApellido(value)}/>
<TextInput style={'last_name' in errors ? styles.errorMessage : styles.input} type="text" onChangeText={onHandleChange("last_name")}/>
</FormControl>
<FormControl isRequired>
<FormControl.Label>Identificación</FormControl.Label>
<TextInput style={styles.input} type="text" onChangeText={(value) => setDNI(value)}/>
<TextInput style={'dni' in errors ? styles.errorMessage : styles.input}type="text" onChangeText={onHandleChange("dni")}/>
</FormControl>
<FormControl isRequired>
<FormControl.Label>Teléfono</FormControl.Label>
<TextInput style={styles.input} type="text" onChangeText={(value) => setPhone(value)} />
<TextInput style={'phone' in errors ? styles.errorMessage : styles.input}type="text" onChangeText={onHandleChange("phone")} />
</FormControl>
<FormControl >
<FormControl.Label>Placa</FormControl.Label>
<TextInput style={styles.input} type="text" onChangeText={onHandleChange("number_plate")} />
</FormControl>
<FormControl >
<FormControl.Label>Tipo de invitado</FormControl.Label>
<Select onChangeText={onHandleChange("type_guest")} selectedValue={categoria} minWidth="200" accessibilityLabel="Choose Service" placeholder="Elija el tipo de invitado" _selectedItem={{
bg: "teal.600"
}} mt={1} onValueChange={onHandleChange("type_guest")}>
<Select.Item label="Invitado Frecuente" value="Frecuente" />
<Select.Item label="Invitado de acceso rápido" value="Rapido" />
</Select>
</FormControl>
<Button mt="2" backgroundColor='tertiary.600' onPress={() => saveInvitado()}>
Guardar
@ -108,7 +177,7 @@ export default function AgregarInvitados({ navigation }) {
const styles = StyleSheet.create({
input: {
height: 10,
height: 35,
margin: 3,
borderWidth: 0.5,
padding: 5,
@ -120,6 +189,19 @@ const styles = StyleSheet.create({
marginTop: 6,
marginBottom: 6,
borderRadius: 4
},
errorMessage: {
height: 35,
margin: 3,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 9,
paddingRight: 19,
paddingLeft: 0,
marginTop: 6,
borderRadius: 4,
borderColor: '#be123c'
}
})

View File

@ -12,18 +12,21 @@ import { UserContext } from "../context/UserContext";
import { API } from "../environment/api";
import {TimePicker} from 'react-native-simple-time-picker';
import { View, StyleSheet } from "react-native";
import { number } from "prop-types";
import DateTimePicker from '@react-native-community/datetimepicker';
export default function AreaComun({navigation}){
const { user } = useContext(UserContext)
const [service, setService] = useState("");
const [areas, setAreas] = useState([])
const [isRequesting, setIsRequesting] = useState(false);
const [time, setTime] = useState(new Date())
const idComunidad = user.community_id
const date = new Date();
const [mode, setMode] = useState('time');
const [selectedHours, setSelectedHours] = useState(0);
const [selectedMinutes, setSelectedMinutes] = useState(0);
const [endSelectedHours, setEndSelectedHours] = useState(0);
const [endSelectedMinutes, setEndSelectedMinutes] = useState(0);
const [startDate, setStartDate] = useState();
const [startTime, setStartTime] = useState()
useEffect(() => {
@ -33,7 +36,7 @@ export default function AreaComun({navigation}){
try {
const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/allCommonAreas`, {
const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/findByCommunity/` + `${idComunidad}`, {
method: "GET",
headers: {
'Content-Type': 'application/json'
@ -41,7 +44,7 @@ export default function AreaComun({navigation}){
})
const response = await jsonResponse.json();
console.log(response.message);
// console.log(response.message);
setAreas(response.message);
@ -62,38 +65,58 @@ export default function AreaComun({navigation}){
const postReserva = async() => {
// console.log(startDate.split('"')[1]);
// console.log(startTime.split('.')[0]);
const data = {
"start_time": selectedHours + ":" +selectedMinutes,
"finish_time": endSelectedHours + ":" +endSelectedMinutes,
"date_entry": "",
"time": startTime.split('.')[0],
"date": startDate.split('"')[1],
"user_id" : user._id,
"common_area_id": service
"common_area_id": service._id,
"common_area_name": service.name,
"community_id": service.community_id
}
console.log(data);
// try {
try {
// const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, {
// cache: 'no-cache',
// method: 'POST',
// body: JSON.stringify(data),
// headers: {
// 'Content-Type': 'application/json'
// }
// })
const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
// const response = await jsonResponse.json();
// console.log(response.message);
const response = await jsonDataResponse.json();
console.log(response.message);
// } catch (error) {
// console.log("ERROR:" + error);
// }
} catch (error) {
console.log("ERROR:" + error);
}
}
const onChangeStart = (event, selectedDate) => {
// console.log(selectedDate);
const dateString = JSON.stringify(selectedDate).toString().split("T")
setStartDate(dateString[0])
setStartTime(dateString[1])
console.log(dateString);
// console.log(Date.toString(selectedDate));
const currentDate = selectedDate || time;
setTime(currentDate);
};
return (
<Center>
@ -118,7 +141,7 @@ export default function AreaComun({navigation}){
}} mt={1} onValueChange={itemValue => setService(itemValue)}>
{areas.map(item => (
<Select.Item label={item.name} value={item.community_id} />
<Select.Item key={item._id} label={item.name} value={item} />
))}
</Select>
@ -126,36 +149,15 @@ export default function AreaComun({navigation}){
<FormControl isRequired>
<FormControl.Label>Hora de inicio</FormControl.Label>
<View >
<TimePicker
selectedHours={selectedHours}
selectedMinutes={selectedMinutes}
onChange={(hours, minutes) => {
setSelectedHours(hours);
setSelectedMinutes(minutes);
}}/>
<DateTimePicker minimumDate={date} mode="datetime" is24Hour value={time} onChange={onChangeStart}/>
</View>
</FormControl>
<FormControl isRequired>
<FormControl.Label>Hora de finalización</FormControl.Label>
<View >
<TimePicker
selectedHours={selectedHours}
//initial Hourse value
selectedMinutes={selectedMinutes}
//initial Minutes value
onChange={(hours, minutes) => {
setEndSelectedHours(hours);
setEndSelectedMinutes(minutes);
}}/>
</View>
</FormControl>
<Button mt="2" backgroundColor="tertiary.600" onPress={()=> postReserva()}>
<Button mt="10" backgroundColor="tertiary.600" onPress={()=> postReserva()}>
Reservar
</Button>
<Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Comunicados')}>
<Button mt="3" colorScheme="error" onPress={() => navigation.navigate('Mis Reservas')}>
Cancelar
</Button>
</VStack>

View File

@ -8,8 +8,8 @@ import PropTypes from 'prop-types';
import React from 'react';
export const CommentCard = ({ date, comment }) => {
const dateFormated = format(new Date(date), "dd LL yyyy")
export const CommentCard = ({ post }) => {
//const dateFormated = format(new Date(date), "dd LL yyyy")
return (
<Pressable
rounded="8"
@ -31,14 +31,14 @@ export const CommentCard = ({ date, comment }) => {
</Badge>
<Spacer />
<Text fontSize={10} color="coolGray.800">
{dateFormated}
</Text>
</HStack>
<Text color="coolGray.800" mt="3" fontWeight="medium" fontSize="xl">
Administrador de Comunidad
</Text>
<Text mt="2" fontSize="sm" color="coolGray.700">
{comment}
{post}
</Text>
</Box>
</Pressable>
@ -46,6 +46,6 @@ export const CommentCard = ({ date, comment }) => {
}
CommentCard.propTypes = {
date: PropTypes.string.isRequired,
comment: PropTypes.string.isRequired,
// date: PropTypes.string.isRequired,
post: PropTypes.string.isRequired,
}

View File

@ -8,7 +8,10 @@ export default function Home() {
const { user } = useContext(UserContext)
const [isRequesting, setIsRequesting] = useState(false);
const [comments, setComments] = useState([]);
const user_type=user.user_type;
//const user_type="4";
const community_id=user.community_id;
//const community_id="1";
useEffect(() => {
console.log(user);
@ -17,7 +20,18 @@ export default function Home() {
setIsRequesting(true);
try {
const jsonResponse = await fetch(`${API.BASE_URL}/post/allComments`, {
if(user_type=="4"){
const jsonResponse = await fetch(`${API.BASE_URL}/post/findPostCommunity/`+`${community_id}`, {
method: "GET",
headers: {
'Content-Type': 'application/json'
}
})
const response = await jsonResponse.json();
setComments(response.message);
}else{
const jsonResponse = await fetch(`${API.BASE_URL}/post/allPosts`, {
method: "GET",
headers: {
'Content-Type': 'application/json'
@ -25,9 +39,8 @@ export default function Home() {
})
const response = await jsonResponse.json();
// console.log(response);
setComments(response.message);
}
} catch (error) {
@ -55,8 +68,8 @@ export default function Home() {
comments.map(item => (
<CommentCard
key={item._id}
comment={item.comment}
date={item.date_entry}
post={item.post}
//date={date}
/>
))
}

View File

@ -4,15 +4,22 @@ import { UserContext } from "../context/UserContext";
import { API } from "../environment/api";
import {
Box, Button,
Center, FormControl, Heading, ScrollView, VStack,FlatList, HStack,Avatar,Spacer,Text
Center, FormControl, Heading, ScrollView, VStack,FlatList, HStack,Avatar,Spacer,Text, Icon
} from "native-base";
export default function Invitados({navigation}) {
const [isRequesting, setIsRequesting] = useState(false);
const [invitados, setInvitados] = useState([]);
const { user } = useContext(UserContext);
const id = user._id;
//const id = "6301df20dac7dcf76dcecade";
const user_type=user.user_type;
//const user_type="4";
//const community_id="1";
const community_id=user.community_id;
const [invitado, setInvitado] = useState([]);
useEffect(() => {
@ -20,6 +27,17 @@ export default function Invitados({navigation}) {
setIsRequesting(true);
try {
if(user_type=="4"){
const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestCommunity/`+`${community_id}`, {
method: "GET",
headers: {
'Content-Type': 'application/json'
}
})
const response = await jsonResponse.json();
setInvitados(response.message);
}else{
const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestUser/`+`${id}`, {
method: "GET",
headers: {
@ -28,9 +46,8 @@ export default function Invitados({navigation}) {
})
const response = await jsonResponse.json();
//console.log(response);
setInvitados(response.message);
}
} catch (error) {
}
@ -42,12 +59,43 @@ export default function Invitados({navigation}) {
})
const deleteInvitado = async(pid) => {
const data = {
"_id": pid
}
try {
await fetch("http://localhost:4000/guest/updateGuest", {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
if (response.status != 201){
console.log('ocurrio un error ');
}else{
return response.json();
}
})
} catch (error) {
console.log("ERROR: " + error);
}
}
return (
<Box>
<Heading fontSize="xl" p="4" pb="3">
Lista de invitados
</Heading>
<Button width='200' mb="4" mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('Agregar Invitado')} icon={<Icon mb="0.5" as={<MaterialCommunityIcons name={'plus'} />} color="white" size="sm" />}>
Agregar invitado
</Button>
<FlatList data={invitados} renderItem={({
item
}) => <Box key={item._id} borderBottomWidth="1" _dark={{
@ -64,28 +112,29 @@ export default function Invitados({navigation}) {
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{item.dni}
{"Identificación: "+item.dni}
</Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{item.phone}
{"Teléfono: "+item.phone}
</Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{"Número Placa: "+item.number_plate}
</Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{"Tipo de acceso: "+item.type_guest}
</Text>
</VStack>
<Spacer />
<Text fontSize="xs" _dark={{
color: "warmGray.50"
}} color="coolGray.800" alignSelf="flex-start">
{item.number_plate}
</Text>
{user_type == 3 && <MaterialCommunityIcons name="delete" size={28} color="#7C0808" onPress={() =>{deleteInvitado(item._id)}} />}
</HStack>
</Box>} keyExtractor={item => item.id} />
<Button width='200' mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('invitado')}>
Agregar invitado
</Button>
</Box>

View File

@ -9,7 +9,8 @@ import {
Box,
FormControl,
Button,
Image
Image,
ErrorMessage
} from "native-base";
import logo from "../assets/logo-katoikia.png";
import { Entypo } from '@expo/vector-icons';
@ -23,6 +24,7 @@ const baseURL = `${API.BASE_URL}/user/loginUser`;
export default function LogIn({ navigation }) {
const { addUser } = useContext(UserContext);
const [errors, setErrors] = useState({});
const [credentials, setCredentials] = useState({
email: "lalo@lalo.com",
@ -31,10 +33,38 @@ export default function LogIn({ navigation }) {
const onHandleChange = (name) => (value) => setCredentials(prev => ({ ...prev, [name]: value }))
const validate = async() => {
if( credentials.email === "" && credentials.password === ""){
setErrors({ ...errors,
email: 'Debe ingresar un correo electrónico',
password: 'Debe ingresar una contraseña'
});
return false;
}else if (credentials.password === "") {
setErrors({ ...errors,
password: 'Debe ingresar una contraseña'
});
return false;
} else if(credentials.email === ""){
setErrors({ ...errors,
email: 'Debe ingresar un correo electrónico'
});
return false;
}
return true;
}
const iniciarSesion = async () => {
const error = await validate();
console.log(error);
if (error) {
try {
console.log(baseURL);
await fetch(baseURL, {
cache: 'no-cache',
method: 'POST',
@ -54,25 +84,38 @@ export default function LogIn({ navigation }) {
// inqulino 4 y guarda 3
const user = response.message
if(user !== null){
if(user.user_type == '4'){
addUser(user);
navigation.navigate('Comunicados', {user})
}else if(user.user_type == '3'){
addUser(user);
// cambiar por ComunicadosGuarda luego
navigation.navigate('Comunicados', {user})
}
}else{
setErrors({ ...errors,
user: 'Debe ingresar credenciales válidos'
});
}
})
} catch (error) {
console.log("ERROR: " +error);
}
}
console.log(errors);
}
return (
<Center w="100%">
<Center w="100%" flex={1}>
<Box safeArea p="2" py="8" w="90%" maxW="290">
<Center>
@ -106,8 +149,8 @@ export default function LogIn({ navigation }) {
</Heading>
<View style={styles.container}>
<VStack space={3} mt="5">
<FormControl isRequired >
<VStack width="90%" mx="3" maxW="300px" mb={10}>
<FormControl isRequired isInvalid={'email' in errors}>
<FormControl.Label Text='bold'> Correo Electrónico </FormControl.Label>
<View style={styles.viewSection}>
@ -115,46 +158,44 @@ export default function LogIn({ navigation }) {
<TextInput
name='email'
type="text"
style={styles.input}
style={'email' in errors ? styles.errorMessage : styles.input}
value={credentials.email}
placeholder='Correo electrónico'
onChangeText={onHandleChange("email")} />
</View>
</View>
{'email' in errors && <FormControl.ErrorMessage _text={{
fontSize: 'xs'
}}>Debe ingresar un correo electrónico</FormControl.ErrorMessage> }
</FormControl>
<FormControl isRequired>
<FormControl isRequired isInvalid={'password' in errors}>
<FormControl.Label Text='bold'> Contraseña </FormControl.Label>
<View style={styles.viewSection}>
<MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" style={styles.iconStyle} />
<TextInput
name='password'
type="password"
style={styles.input}
style={'password' in errors ? styles.errorMessage : styles.input}
value={credentials.password}
placeholder='Contraseña'
onChangeText={onHandleChange("password")} />
</View>
<Link
_text={{
fontSize: "xs",
fontWeight: "500",
color: "indigo.500",
marginTop: "10"
{'password' in errors && <FormControl.ErrorMessage _text={{
fontSize: 'xs'
}}
alignSelf="flex-end"
mt="1"
onPress={() => navigation.navigate('Password')}
>Debe ingresar una contraseña</FormControl.ErrorMessage> }
>
Recuperar contraseña
</Link>
</FormControl>
<Button mt="2" backgroundColor="#D7A86E" onPress={iniciarSesion}
>
<Text>Continuar</Text>
</Button>
{/* {'user' in errors && <ErrorMessage _text={{
fontSize: 'xs'
}}
>Debe ingresar credenciales válidos</ErrorMessage> } */}
</VStack></View>
@ -173,12 +214,23 @@ const styles = StyleSheet.create({
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 0,
marginTop: 50,
marginBottom: 10,
borderRadius: 4
},
errorMessage: {
height: 40,
margin: 10,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingLeft: 0,
marginTop: 50,
borderRadius: 4,
borderColor: '#be123c'
},
iconStyle: {
paddingBottom: 20,
@ -191,11 +243,11 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 28
marginBottom: 50
},
container: {
marginBottom: 6
}
})

View File

@ -1,72 +1,54 @@
import React, { useContext, useState } from "react";
import { API } from "../environment/api";
import {
Box, Button,
Center, FormControl, Heading, ScrollView, VStack
} from "native-base";
import { StyleSheet, TextInput } from "react-native";
import { StyleSheet, TextInput, useWindowDimensions } from "react-native";
import { UserContext } from "../context/UserContext";
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import { stringMd5 } from 'react-native-quick-md5';
const { Navigator, Screen } = createMaterialTopTabNavigator();
export default function Profile({ navigation }) {
const baseURL = `${API.BASE_URL}/user/updateUser/`
//const userData = JSON.parse(JSON.stringify(route.params));
const [name, setName] = useState();
const [apellido, setApellido] =useState();
const [email, setEmail] = useState();
const [password, setPassword] = useState();
const [index, setIndex] = useState(0);
const layout = useWindowDimensions();
const userData = useContext(UserContext)
const [name, setName] = useState(userData.user.name);
const [apellido, setApellido] =useState(userData.user.last_name);
const [email, setEmail] = useState(userData.user.email);
const [password, setPassword] = useState();
const [confirmPassword, setConfirmPassword] = useState()
const id = userData.user._id;
const decode = userData.Password;
const [error, setError] = useState({})
console.log(userData.user);
const onHandleChangePassword = (value) => {
//console.log(value);
const dpassword = stringMd5(value)
console.log(dpassword);
const updateInfo = async() => {
const data = {
"_id": "6301df20dac7dcf76dcecade",
"dni": "1234567890",
"name": name,
"last_name": apellido,
"email": email,
"phone": 12121212,
"password": "827ccb0eea8a706c4c34a16891f84e7b",
"user_type": "3",
"status": "1",
"date_entry": "2022-08-21T07:30:09.929Z",
"community_id": null,
}
try {
await fetch(baseURL+`${id}`, {
cache: 'no-cache',
method: 'PUT',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(baseURL+`${id}`);
if (response.status != 201){
console.log('ocurrio un error ');
console.log(userData.user.password);
if (userData.user.password == dpassword) {
console.log(true);
setError({});
}else{
return response.json();
}
})
console.log(false);
setError({ ...error,
} catch (error) {
console.log("ERROR: " + error);
password: 'La contraseña no coincide con la actual'
});
}
}
return (
<Center>
const ProfileView = () => (
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
px: "20px",
@ -89,27 +71,22 @@ export default function Profile({ navigation }) {
<FormControl.Label>DNI</FormControl.Label>
<TextInput type="text" defaultValue={userData.user.dni} editable={false} />
</FormControl>
<FormControl>
{/* <FormControl>
<FormControl.Label>Teléfono</FormControl.Label>
<TextInput type="text" defaultValue={userData.user.phone} editable={false} />
</FormControl>
</FormControl> */}
<FormControl>
<FormControl.Label>Nombre</FormControl.Label>
<TextInput style={styles.input} type="text" defaultValue={userData.user.name} onChangeText={(value) => setName(value) }/>
</FormControl>
<FormControl>
<FormControl.Label>Apellido</FormControl.Label>
<TextInput style={styles.input} type="text"defaultValue={userData.user.last_name} onChangeText={(value) => setApellido(value) } />
<TextInput style={styles.input} type="text" defaultValue={userData.user.last_name} onChangeText={(value) => setApellido(value) } />
</FormControl>
<FormControl>
<FormControl.Label>Correo electrónico</FormControl.Label>
<TextInput style={styles.input} type="text" defaultValue={userData.user.email} onChangeText={(value) => setEmail(value) }/>
</FormControl>
<FormControl>
<FormControl.Label>Contraseña actual</FormControl.Label>
<TextInput style={styles.input} type="password" defaultValue="" onChangeText={(value) => setPassword(value) }/>
</FormControl>
<Button mt="2" backgroundColor="orange.300" onPress={() => updateInfo()}>
Actualizar
</Button>
@ -120,7 +97,156 @@ export default function Profile({ navigation }) {
</Box>
</ScrollView>
</Center>
)
const PasswordView = () => (
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
px: "20px",
mb: "4",
minW: "72"
}}>
<Box safeArea p="2" w="90%" maxW="290" py="8">
<Heading size="lg" color="coolGray.800" _dark={{
color: "warmGray.50"
}} fontWeight="semibold">
Bienvenido {userData.user.name}
</Heading>
<Heading mt="1" color="coolGray.600" _dark={{
color: "warmGray.200"
}} fontWeight="medium" size="xs">
Modifique sus contraseña
</Heading>
<VStack space={3} mt="5">
<FormControl>
<FormControl.Label>Contraseña actual</FormControl.Label>
<TextInput style={'password' in error ? styles.errorMessage : styles.input} type="password" onChangeText={(value) => onHandleChangePassword(value) }/>
</FormControl>
<FormControl>
<FormControl.Label>Nueva Contraseña</FormControl.Label>
<TextInput editable={!error} style={styles.input} type="password" onChangeText={(value) => setPassword(value) } />
</FormControl>
<FormControl>
<FormControl.Label>Confirmar nueva contraseña</FormControl.Label>
<TextInput editable={!error} style={styles.input} type="password" onChangeText={(value) => setConfirmPassword(value) }/>
</FormControl>
<Button mt="2" backgroundColor="orange.300" onPress={() => updatePassword()} disabled={error}>
Actualizar contraseña
</Button>
{/* {'password' in error && <FormControl.ErrorMessage _text={{
fontSize: 'xs'
}}>La contraseña no coincide con la actual</FormControl.ErrorMessage> } */}
</VStack>
</Box>
</ScrollView>
)
const updatePassword = async() =>{
const dataPassword = {
"_id": userData.user._id,
"dni": userData.user.dni,
"name": userData.user.name,
"last_name": userData.user.last_name,
"email": userData.user.email,
"phone": userData.user.phone,
"password": password,
"user_type": userData.user.user_type,
"status": userData.user.status,
"date_entry": userData.user.date_entry,
"community_id": userData.user.community_id,
}
try {
await fetch(baseURL+`${id}`, {
cache: 'no-cache',
method: 'PUT',
body: JSON.stringify(dataPassword),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
// console.log(baseURL+`${id}`);
if (response.status != 201 && response.status != 200){
console.log('ocurrio un error ' + response);
}else{
return response.json();
}
})
} catch (error) {
console.log("ERROR: " + error);
}
}
const updateInfo = async() => {
const data = {
"_id": userData.user._id,
"dni": userData.user.dni,
"name": name,
"last_name": apellido,
"email": email,
"community_id": userData.user.community_id
}
console.log(data);
try {
await fetch(baseURL+`${id}`, {
cache: 'no-cache',
method: 'PUT',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response);
//console.log(baseURL+`${id}`);
if (response.status != 201){
console.log('ocurrio un error ');
}else{
return response.json();
}
})
} catch (error) {
console.log("ERROR: " + error);
}
}
return (
<Navigator>
<Screen name="Datos Personales" component={ProfileView} />
<Screen name="Contraseña" component={PasswordView} />
</Navigator>
)
@ -129,18 +255,29 @@ export default function Profile({ navigation }) {
const styles = StyleSheet.create({
input: {
height: 10,
height: 35,
margin: 3,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 9,
paddingRight: 19,
paddingBottom: 20,
paddingLeft: 0,
marginTop: 6,
marginBottom: 6,
borderRadius: 4
},
errorMessage: {
height: 35,
margin: 3,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 9,
paddingRight: 19,
paddingLeft: 0,
marginTop: 6,
borderRadius: 4,
borderColor: '#be123c'
}
})

View File

@ -2,8 +2,10 @@ import React, {useContext, useEffect, useState} from "react";
import {
Box,
ScrollView,
Fab,
Icon
Text,
Icon,
Button,
Heading
} from "native-base";
import { API } from "../environment/api";
import { MaterialCommunityIcons } from '@expo/vector-icons';
@ -16,14 +18,20 @@ 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";
console.log(user);
useEffect(() => {
const onRequestReservasData = async () => {
setIsRequesting(true);
console.log(user);
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'
@ -35,12 +43,6 @@ export default function Reservas({navigation}) {
setReservas(response.message);
try {
} catch (error) {
console.log("ERROR:" + error);
}
} catch (error) {
console.log("ERROR:" + error);
@ -53,34 +55,35 @@ export default function Reservas({navigation}) {
}, [user])
console.log(reservas);
return (
<Box>
<Heading fontSize="xl" p="4" pb="3">
Lista de reservas
</Heading>
<ScrollView showsVerticalScrollIndicator={false}>
<Button width='200' mb="4" mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('Reservar')} icon={<Icon mb="0.5" as={<MaterialCommunityIcons name={'plus'} />} color="white" size="sm" />}>
Reservar
</Button>
{ reservas == [] ? <Text mt="9" ml='10'> No hay reservas relacionados a su usuario</Text> :
{
reservas.map(item => (
<ReservasCard
key={item._id}
date={item.date_entry}
startTime={item.start_time}
endTime={item.finish_time}
date={item.date}
startTime={item.time}
status={item.status}
name={item.common_area_name}
/>
))
}
<Box height="200" w="300" shadow="2" rounded="lg" m='5' ml='9' _dark={{
bg: "coolGray.200:alpha.20"
}} _light={{
bg: "coolGray.200:alpha.20"
}}>
<Fab renderInPortal={false} shadow={2} size="sm" icon={<Icon mb="0.5" as={<MaterialCommunityIcons name={'plus'} />} color="white" size="sm" />} onPress={() => navigation.navigate('area')}/>
</Box>
</ScrollView>
</Box>
);
}

View File

@ -1,6 +1,6 @@
import { format } from "date-fns";
import {
Box, HStack,
Box,
ScrollView,
Text,
Stack,
@ -11,15 +11,14 @@ import PropTypes from 'prop-types';
import React from 'react';
export const ReservasCard = ({ date, startTime, endTime, status}) => {
const dateFormated = format(new Date(date), "dd LL yyyy")
export const ReservasCard = ({ date, startTime, name}) => {
try {
const dateFormated = date.toString().split("T")[0]
} catch (error) {
}
console.log(dateFormated);
return (
<ScrollView showsVerticalScrollIndicator={false}>
@ -38,39 +37,34 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => {
<Stack p="4" space={3}>
<Stack space={2}>
<Badge backgroundColor={status === 1 ? 'tertiary.500' : 'danger.600'} _text={{
color: "white"
}} variant="solid" rounded="4">
<Text bold={true} color='danger.50'> {status === 1 ? 'LIBRE' : 'RESERVADO'}</Text>
</Badge>
<Heading size="md" ml="-1">
Reserva #1
<Heading size="lg" ml="-1">
{name}
</Heading>
<Text fontSize="xs" _light={{
color: "violet.500"
<Text fontSize="md" _light={{
color: "amber.600"
}} _dark={{
color: "violet.400"
}} fontWeight="500" ml="-0.5" mt="-1">
{dateFormated}
</Text>
</Stack>
<Text fontWeight="400">
<Text fontSize="md" fontWeight="400">
Hora de inicio: {startTime}
</Text>
<Text fontWeight="400">
Hora de finalización: {endTime}
</Text>
</Stack>
</Box>
</Box>
</ScrollView>
)
}
ReservasCard.propTypes = {
date: PropTypes.string.isRequired,
startTime: PropTypes.string.isRequired,
endTime: PropTypes.string.isRequired,
status: PropTypes.string.isRequired
}
// ReservasCard.propTypes = {
// date: PropTypes.string.isRequired,
// startTime: PropTypes.string.isRequired,
// status: PropTypes.string.isRequired
// }

View File

@ -14,11 +14,14 @@
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
"eject": "expo eject",
"test" : "jest"
},
"dependencies": {
"@react-native-community/datetimepicker": "4.0.0",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/bottom-tabs": "^6.3.2",
"@react-navigation/material-top-tabs": "^6.2.3",
"@react-navigation/native": "^6.0.11",
"@react-navigation/native-stack": "^6.7.0",
"@react-navigation/stack": "^6.2.2",
@ -31,17 +34,21 @@
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "~2.1.0",
"react-native-pager-view": "5.4.9",
"react-native-quick-md5": "^3.0.4",
"react-native-reanimated": "~2.3.1",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-simple-time-picker": "^1.3.11",
"react-native-svg": "12.1.1",
"react-native-tab-view": "^3.1.1",
"react-native-table-component": "^1.2.2",
"react-native-web": "0.17.1",
"universal-cookie": "^4.0.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
"@babel/core": "^7.12.9",
"jest": "^29.0.1"
},
"bugs": {
"url": "https://github.com/GeekyAnts/nativebase-templates/issues"

View File

@ -33,4 +33,10 @@ export class PostCommentsController {
let _id = id['id'];
return this.postCommentsService.remove(_id);
}
@MessagePattern({ cmd: 'findCommentCommunity' })
findPostCommunity(@Payload() id: string) {
let _id = id['id'];
return this.postCommentsService.findPostCommunity(_id);
}
}

View File

@ -37,4 +37,9 @@ export class PostCommentsService {
new: true,
});
}
async findPostCommunity(id: string): Promise<Comment[]> {
console.log(id);
return this.commentModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec();
}
}

View File

@ -33,4 +33,9 @@ export class PostsController {
let _id = id['id'];
return this.postsService.remove(_id);
}
@MessagePattern({ cmd: 'findPostCommunity' })
findPostCommunity(@Payload() id: string) {
let _id = id['id'];
return this.postsService.findPostCommunity(_id);
}
}

View File

@ -30,4 +30,9 @@ export class PostsService {
async remove(id: string) {
return this.postModel.findByIdAndRemove({ _id: id }).exec();
}
async findPostCommunity(id: string): Promise<Post[]> {
console.log(id);
return this.postModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec();
}
}

View File

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

View File

@ -20,6 +20,11 @@ export class GuestsController {
findGuestUser(@Payload() id: string) {
return this.guestsService.findGuestUser(id);
}
@MessagePattern({ cmd: 'findGuestCommunity' })
findGuestCommunity(@Payload() id: string) {
let _id = id['id'];
return this.guestsService.findGuestCommunity(_id);
}
@MessagePattern({ cmd: 'findOneGuest' })
findOneById(@Payload() id: string) {
let _id = id['_id'];
@ -39,7 +44,7 @@ export class GuestsController {
@MessagePattern({ cmd: 'removeGuest' })
remove(@Payload() id: string) {
let dni = id['dni'];
let dni = id['_id'];
return this.guestsService.remove(dni);
}
}

View File

@ -18,7 +18,12 @@ export class GuestsService {
}
async findGuestUser(id: string): Promise<Guest[]> {
return this.guestModel.find({_tenant_id:id}).setOptions({ sanitizeFilter: true }).exec();
return this.guestModel.find({_tenant_id:id, status:"1"}).setOptions({ sanitizeFilter: true }).exec();
}
async findGuestCommunity(id: string): Promise<Guest[]> {
console.log(id);
return this.guestModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec();
}
findOneId(id: string): Promise<Guest> {

View File

@ -32,6 +32,9 @@ export class Guest {
@Prop()
community_id: string; ///creo que se debe de agregar para facilitar al guarda ver
// ver los invitados de x comunidad
@Prop()
type_guest: string;
}
export const GuestSchema = SchemaFactory.createForClass(Guest);

View File

@ -50,4 +50,11 @@ export class ReservationsController {
let community_id = reservation['community_id'];
return this.reservationsService.removeIdCommunity(community_id);
}
@MessagePattern({ cmd: 'findReservationUser' })
findReservationUser(@Payload() id: string) {
let _id = id['id'];
return this.reservationsService.findReservationUser(_id);
}
}

View File

@ -52,4 +52,9 @@ export class ReservationsService {
async findReservationsByCommunity(community_id: string){
return this.reservationModel.find({ community_id: community_id }).exec();
}
async findReservationUser(id: string): Promise<Reservation[]> {
return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec();
}
}

View File

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

View File

@ -72,7 +72,9 @@ export class UsersController {
@MessagePattern({ cmd: 'updateUser' })
update(@Payload() user: UserDocument) {
return this.userService.update(user._id, user);
console.log(user);
return this.userService.update(user['id'], user);
}
@MessagePattern({ cmd: 'updateGuard' })

View File

@ -120,7 +120,10 @@ export class UsersService {
console.log(id)
console.log(user)
return this.userModel.findOneAndUpdate({ _id: id }, user, {
return this.userModel.findOneAndUpdate({ _id: id }, {
name: user['name'], last_name: user['last_name'],
dni: user['dni'], email: user['email'], phone: user['phone']
}, {
new: true,
});
}