diff --git a/api-gateway/package-lock.json b/api-gateway/package-lock.json index 157219f0..ffffe99e 100644 --- a/api-gateway/package-lock.json +++ b/api-gateway/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "api-gateway", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 2b5fa6e3..e8c51c72 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -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); + } + } diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 1334ab7d..0213a277 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -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(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(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(pattern, payload) .pipe(map((message: string) => ({ message }))); } + findGuestCommunityr(paramGuestId: string) { + const pattern = { cmd: 'findGuestCommunity' }; + const payload = { id: paramGuestId }; + return this.clientGuestApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } + + updateGuest(_id: string + ) { + const pattern = { cmd: 'removeGuest' }; + const payload = { + _id: _id + }; + return this.clientGuestApp + .send(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(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(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } + } diff --git a/mobile-ui/App.js b/mobile-ui/App.js index ed2b930a..ada8f74b 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -27,14 +27,14 @@ function HomeTab({ route }) { return ( - (} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)} /> - (} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} /> - (} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} /> + (} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)} + /> + (} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} /> + (} color="#D7A86E" size="md" />)}} onclick={() => setSelected(2)} /> + + + ) +} export default function App() { return ( - - + {/* + }} /> */} - - + + - + (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(); - const data = { - "name": name, - "last_name": apellido, - "dni": dni, - "phone": phone, - "number_plate": number_plate, - "tenant_id": user.id, - "community_id": user.community_id - } - - try { - - await fetch(baseURL, { - - 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); + if (error) { + try { + + await fetch(baseURL, { + + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(info), + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + if (response.status != 201){ + console.log('ocurrio un error '); + }else{ + navigation.navigate('Inicio'); + return response.json(); + } + }) + + } catch (error) { + console.log("ERROR: " + error); + } } + + } return (
- Registre el invitado que desee - + Nombre - setName(value)}/> + + {'name' in errors && Debe ingresar un correo electrónico } Apellido - setApellido(value)}/> + Identificación - setDNI(value)}/> + Teléfono - setPhone(value)} /> + + + + Placa + + + + Tipo de invitado + + + + - diff --git a/mobile-ui/components/CommentCard/index.js b/mobile-ui/components/CommentCard/index.js index 15b9143d..32e2f0a2 100644 --- a/mobile-ui/components/CommentCard/index.js +++ b/mobile-ui/components/CommentCard/index.js @@ -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 ( { - {dateFormated} + Administrador de Comunidad - {comment} + {post} @@ -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, } diff --git a/mobile-ui/components/Home.js b/mobile-ui/components/Home.js index 52df0632..b4577071 100644 --- a/mobile-ui/components/Home.js +++ b/mobile-ui/components/Home.js @@ -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,17 +20,27 @@ export default function Home() { setIsRequesting(true); try { - const jsonResponse = await fetch(`${API.BASE_URL}/post/allComments`, { - method: "GET", - headers: { - 'Content-Type': 'application/json' - } - }) + 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); - const response = await jsonResponse.json(); - // console.log(response); - - setComments(response.message); + }else{ + const jsonResponse = await fetch(`${API.BASE_URL}/post/allPosts`, { + method: "GET", + headers: { + 'Content-Type': 'application/json' + } + }) + + const response = await jsonResponse.json(); + setComments(response.message); + } } catch (error) { @@ -55,8 +68,8 @@ export default function Home() { comments.map(item => ( )) } diff --git a/mobile-ui/components/Invitados.js b/mobile-ui/components/Invitados.js index 45602455..4815b5a1 100644 --- a/mobile-ui/components/Invitados.js +++ b/mobile-ui/components/Invitados.js @@ -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,17 +27,27 @@ export default function Invitados({navigation}) { setIsRequesting(true); try { - const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestUser/`+`${id}`, { - method: "GET", - headers: { - 'Content-Type': 'application/json' - } - }) - - const response = await jsonResponse.json(); - //console.log(response); - setInvitados(response.message); - + 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: { + 'Content-Type': 'application/json' + } + }) + + const response = await jsonResponse.json(); + 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 ( Lista de invitados + - {item.dni} + {"Identificación: "+item.dni} - {item.phone} + {"Teléfono: "+item.phone} + + {"Número Placa: "+item.number_plate} + + + {"Tipo de acceso: "+item.type_guest} + + - - {item.number_plate} - + {user_type == 3 && {deleteInvitado(item._id)}} />} } keyExtractor={item => item.id} /> - - - - diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index fdb48f9f..7a66cf33 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -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 ( -
+
@@ -106,55 +149,53 @@ export default function LogIn({ navigation }) { - - + + Correo Electrónico - + - + {'email' in errors && Debe ingresar un correo electrónico } - + + Contraseña + - navigation.navigate('Password')} - - > - - Recuperar contraseña - - + {'password' in errors && Debe ingresar una contraseña } + + {/* {'user' in errors && Debe ingresar credenciales válidos } */} @@ -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 } }) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index dc15f209..8b656a59 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -1,74 +1,56 @@ 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 '); - }else{ - return response.json(); - } - }) - - } catch (error) { - console.log("ERROR: " + error); + console.log(userData.user.password); + if (userData.user.password == dpassword) { + console.log(true); + setError({}); + }else{ + console.log(false); + setError({ ...error, + + password: 'La contraseña no coincide con la actual' + }); } } - return ( -
- ( + + DNI - + {/* Teléfono - + */} Nombre setName(value) }/> Apellido - setApellido(value) } /> + setApellido(value) } /> Correo electrónico setEmail(value) }/> - - Contraseña actual - setPassword(value) }/> - - @@ -120,7 +97,156 @@ export default function Profile({ navigation }) { -
+ + ) + + const PasswordView = () => ( + + + + + + Bienvenido {userData.user.name} + + + Modifique sus contraseña + + + + + Contraseña actual + onHandleChangePassword(value) }/> + + + + Nueva Contraseña + setPassword(value) } /> + + + + Confirmar nueva contraseña + setConfirmPassword(value) }/> + + + + + {/* {'password' in error && La contraseña no coincide con la actual } */} + + + + + + + + ) + + 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 ( + + + + + + ) @@ -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' } }) diff --git a/mobile-ui/components/Reservas.js b/mobile-ui/components/Reservas.js index 1797e05a..e5cab394 100644 --- a/mobile-ui/components/Reservas.js +++ b/mobile-ui/components/Reservas.js @@ -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 ( - + + + + Lista de reservas + + + + { reservas == [] ? No hay reservas relacionados a su usuario : - { reservas.map(item => ( )) } - - - } color="white" size="sm" />} onPress={() => navigation.navigate('area')}/> - - ); - - - + + + ); } \ No newline at end of file diff --git a/mobile-ui/components/ReservasCard/index.js b/mobile-ui/components/ReservasCard/index.js index 43a67af2..d244c4ad 100644 --- a/mobile-ui/components/ReservasCard/index.js +++ b/mobile-ui/components/ReservasCard/index.js @@ -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}) => { + + + const dateFormated = date.toString().split("T")[0] - try { - - } catch (error) { - - } + + console.log(dateFormated); return ( @@ -38,39 +37,34 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => { - - {status === 1 ? 'LIBRE' : 'RESERVADO'} - - - Reserva #1 + + + {name} - {dateFormated} - + Hora de inicio: {startTime} - - Hora de finalización: {endTime} - + + + ) } -ReservasCard.propTypes = { - date: PropTypes.string.isRequired, - startTime: PropTypes.string.isRequired, - endTime: PropTypes.string.isRequired, - status: PropTypes.string.isRequired -} \ No newline at end of file +// ReservasCard.propTypes = { +// date: PropTypes.string.isRequired, +// startTime: PropTypes.string.isRequired, +// status: PropTypes.string.isRequired +// } \ No newline at end of file diff --git a/mobile-ui/package.json b/mobile-ui/package.json index ba741594..b07de02d 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -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" diff --git a/servicio-foro-comunicaciones/src/post-comments/post-comments.controller.ts b/servicio-foro-comunicaciones/src/post-comments/post-comments.controller.ts index 14113432..3df3c1c4 100644 --- a/servicio-foro-comunicaciones/src/post-comments/post-comments.controller.ts +++ b/servicio-foro-comunicaciones/src/post-comments/post-comments.controller.ts @@ -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); + } } diff --git a/servicio-foro-comunicaciones/src/post-comments/post-comments.service.ts b/servicio-foro-comunicaciones/src/post-comments/post-comments.service.ts index f82b71fa..9351aa7f 100644 --- a/servicio-foro-comunicaciones/src/post-comments/post-comments.service.ts +++ b/servicio-foro-comunicaciones/src/post-comments/post-comments.service.ts @@ -37,4 +37,9 @@ export class PostCommentsService { new: true, }); } + + async findPostCommunity(id: string): Promise { + console.log(id); + return this.commentModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec(); + } } diff --git a/servicio-foro-comunicaciones/src/posts/posts.controller.ts b/servicio-foro-comunicaciones/src/posts/posts.controller.ts index 9872892c..90706065 100644 --- a/servicio-foro-comunicaciones/src/posts/posts.controller.ts +++ b/servicio-foro-comunicaciones/src/posts/posts.controller.ts @@ -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); + } } diff --git a/servicio-foro-comunicaciones/src/posts/posts.service.ts b/servicio-foro-comunicaciones/src/posts/posts.service.ts index 7423aec2..30fe438e 100644 --- a/servicio-foro-comunicaciones/src/posts/posts.service.ts +++ b/servicio-foro-comunicaciones/src/posts/posts.service.ts @@ -30,4 +30,9 @@ export class PostsService { async remove(id: string) { return this.postModel.findByIdAndRemove({ _id: id }).exec(); } + + async findPostCommunity(id: string): Promise { + console.log(id); + return this.postModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec(); + } } diff --git a/servicio-invitados/package-lock.json b/servicio-invitados/package-lock.json index 833d2234..dbcca575 100644 --- a/servicio-invitados/package-lock.json +++ b/servicio-invitados/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "servicio-invitados", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { diff --git a/servicio-invitados/src/guests/guests.controller.ts b/servicio-invitados/src/guests/guests.controller.ts index 17ba36b4..2b750ba9 100644 --- a/servicio-invitados/src/guests/guests.controller.ts +++ b/servicio-invitados/src/guests/guests.controller.ts @@ -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); } } diff --git a/servicio-invitados/src/guests/guests.service.ts b/servicio-invitados/src/guests/guests.service.ts index fcd898df..f2343b7e 100644 --- a/servicio-invitados/src/guests/guests.service.ts +++ b/servicio-invitados/src/guests/guests.service.ts @@ -18,7 +18,12 @@ export class GuestsService { } async findGuestUser(id: string): Promise { - 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 { + console.log(id); + return this.guestModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec(); } findOneId(id: string): Promise { diff --git a/servicio-invitados/src/schemas/guest.schema.ts b/servicio-invitados/src/schemas/guest.schema.ts index c381254a..2918cf46 100644 --- a/servicio-invitados/src/schemas/guest.schema.ts +++ b/servicio-invitados/src/schemas/guest.schema.ts @@ -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); diff --git a/servicio-reservaciones/src/reservations/reservations.controller.ts b/servicio-reservaciones/src/reservations/reservations.controller.ts index 5089ba2b..0195631d 100644 --- a/servicio-reservaciones/src/reservations/reservations.controller.ts +++ b/servicio-reservaciones/src/reservations/reservations.controller.ts @@ -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); + + } } diff --git a/servicio-reservaciones/src/reservations/reservations.service.ts b/servicio-reservaciones/src/reservations/reservations.service.ts index a7ab73d2..20b288bf 100644 --- a/servicio-reservaciones/src/reservations/reservations.service.ts +++ b/servicio-reservaciones/src/reservations/reservations.service.ts @@ -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 { + return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec(); + + } } diff --git a/servicio-usuarios/package-lock.json b/servicio-usuarios/package-lock.json index fa0c98cb..77c2e842 100644 --- a/servicio-usuarios/package-lock.json +++ b/servicio-usuarios/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "servicio-usuarios", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index 81a296b6..314f192b 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -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' }) diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index f074c01d..e1840769 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -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, }); }