From 06ceecbfbf4cf4e82b7fc0977d82ed55edcd6c45 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 23 Aug 2022 11:58:35 -0600 Subject: [PATCH 01/28] time picker change and name of common area --- mobile-ui/components/AreaComun.js | 8 +++++-- mobile-ui/components/Invitados.js | 11 +++++----- mobile-ui/components/Reservas.js | 35 +++++++++++++------------------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 66855e49..b3cdb038 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -12,6 +12,7 @@ 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"; export default function AreaComun({navigation}){ const { user } = useContext(UserContext) @@ -24,6 +25,7 @@ export default function AreaComun({navigation}){ const [endSelectedHours, setEndSelectedHours] = useState(0); const [endSelectedMinutes, setEndSelectedMinutes] = useState(0); + const date = new Date(); useEffect(() => { @@ -62,11 +64,13 @@ export default function AreaComun({navigation}){ const postReserva = async() => { + //console.log(date); + const data = { - "start_time": selectedHours + ":" +selectedMinutes, + "start_time": Number.parseInt(selectedHours) + ":" +selectedMinutes, "finish_time": endSelectedHours + ":" +endSelectedMinutes, - "date_entry": "", + "date_entry": date, "user_id" : user._id, "common_area_id": service diff --git a/mobile-ui/components/Invitados.js b/mobile-ui/components/Invitados.js index 45602455..a839800c 100644 --- a/mobile-ui/components/Invitados.js +++ b/mobile-ui/components/Invitados.js @@ -4,7 +4,7 @@ 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}) { @@ -48,6 +48,9 @@ export default function Invitados({navigation}) { Lista de invitados + - {item.phone} + (506) {item.phone} @@ -82,9 +85,7 @@ export default function Invitados({navigation}) { } keyExtractor={item => item.id} /> - + diff --git a/mobile-ui/components/Reservas.js b/mobile-ui/components/Reservas.js index 1797e05a..8ac0b01b 100644 --- a/mobile-ui/components/Reservas.js +++ b/mobile-ui/components/Reservas.js @@ -3,7 +3,9 @@ import { Box, ScrollView, Fab, - Icon + Icon, + Button, + Heading } from "native-base"; import { API } from "../environment/api"; import { MaterialCommunityIcons } from '@expo/vector-icons'; @@ -16,6 +18,7 @@ export default function Reservas({navigation}) { const { user } = useContext(UserContext) const [isRequesting, setIsRequesting] = useState(false); const [reservas, setReservas] = useState([]); + useEffect(() => { @@ -35,12 +38,6 @@ export default function Reservas({navigation}) { setReservas(response.message); - try { - - - } catch (error) { - console.log("ERROR:" + error); - } } catch (error) { console.log("ERROR:" + error); @@ -55,8 +52,15 @@ export default function Reservas({navigation}) { return ( - + + + + Lista de reservas + + { reservas.map(item => ( @@ -70,17 +74,8 @@ export default function Reservas({navigation}) { )) } - - - } color="white" size="sm" />} onPress={() => navigation.navigate('area')}/> - - ); - - - + + + ); } \ No newline at end of file From d8be6c02a0c0302f7126fb2f8d0c4becbd8b8fc5 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 23 Aug 2022 14:18:49 -0600 Subject: [PATCH 02/28] agregar placa en invitados --- mobile-ui/components/AgregarInvitados.js | 4 ++++ mobile-ui/components/AreaComun.js | 4 +++- mobile-ui/components/Profile.js | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mobile-ui/components/AgregarInvitados.js b/mobile-ui/components/AgregarInvitados.js index e8c80b66..5e4a942f 100644 --- a/mobile-ui/components/AgregarInvitados.js +++ b/mobile-ui/components/AgregarInvitados.js @@ -92,6 +92,10 @@ export default function AgregarInvitados({ navigation }) { Teléfono setPhone(value)} /> + + Placa + setPhone(value)} /> + diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index b3cdb038..c419786d 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -72,7 +72,9 @@ export default function AreaComun({navigation}){ "finish_time": endSelectedHours + ":" +endSelectedMinutes, "date_entry": date, "user_id" : user._id, - "common_area_id": service + "common_area_id": service, + "common_area_name": "", + "community_id": "" } diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index dc15f209..76b45b55 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -89,10 +89,10 @@ export default function Profile({ navigation }) { DNI - + {/* Teléfono - + */} Nombre setName(value) }/> From ff1af1961387bb91b86f148e49e2d09bddb595f9 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 23 Aug 2022 18:43:50 -0600 Subject: [PATCH 03/28] post de reservas --- mobile-ui/components/AreaComun.js | 43 +++++++++++----------- mobile-ui/components/ReservasCard/index.js | 4 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index c419786d..03c6c7db 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -19,10 +19,8 @@ export default function AreaComun({navigation}){ const [service, setService] = useState(""); const [areas, setAreas] = useState([]) const [isRequesting, setIsRequesting] = useState(false); - const [selectedHours, setSelectedHours] = useState(0); const [selectedMinutes, setSelectedMinutes] = useState(0); - const [endSelectedHours, setEndSelectedHours] = useState(0); const [endSelectedMinutes, setEndSelectedMinutes] = useState(0); const date = new Date(); @@ -68,34 +66,35 @@ export default function AreaComun({navigation}){ const data = { - "start_time": Number.parseInt(selectedHours) + ":" +selectedMinutes, - "finish_time": endSelectedHours + ":" +endSelectedMinutes, + "start_time": 7 + ":" +0, + "finish_time": 10 + ":" +0, + "status": 1, "date_entry": date, "user_id" : user._id, - "common_area_id": service, - "common_area_name": "", - "community_id": "" + "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); + } } @@ -124,7 +123,7 @@ export default function AreaComun({navigation}){ }} mt={1} onValueChange={itemValue => setService(itemValue)}> {areas.map(item => ( - + ))} diff --git a/mobile-ui/components/ReservasCard/index.js b/mobile-ui/components/ReservasCard/index.js index 43a67af2..800cd75b 100644 --- a/mobile-ui/components/ReservasCard/index.js +++ b/mobile-ui/components/ReservasCard/index.js @@ -38,10 +38,10 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => { - - {status === 1 ? 'LIBRE' : 'RESERVADO'} + {status == 1 ? 'LIBRE' : 'RESERVADO'} Reserva #1 From b7ee2a20a967882d6fbb84d8a3577ca4bb3f683d Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 23 Aug 2022 20:35:11 -0600 Subject: [PATCH 04/28] modified time picker for reservas --- mobile-ui/components/AreaComun.js | 89 +++++++++++++++---------------- mobile-ui/package.json | 3 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 03c6c7db..0ad1a059 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -13,6 +13,7 @@ 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) @@ -23,6 +24,8 @@ export default function AreaComun({navigation}){ const [selectedMinutes, setSelectedMinutes] = useState(0); const [endSelectedHours, setEndSelectedHours] = useState(0); const [endSelectedMinutes, setEndSelectedMinutes] = useState(0); + const [time, setTime] = useState(new Date(1598051730000)) + const [endTime, setEndTime] = useState(new Date(1598051730000)) const date = new Date(); useEffect(() => { @@ -62,43 +65,53 @@ export default function AreaComun({navigation}){ const postReserva = async() => { - //console.log(date); + console.log(time); - const data = { + // const data = { - "start_time": 7 + ":" +0, - "finish_time": 10 + ":" +0, - "status": 1, - "date_entry": date, - "user_id" : user._id, - "common_area_id": service._id, - "common_area_name": service.name, - "community_id": service.community_id + // "start_time": 7 + ":" +0, + // "finish_time": 10 + ":" +0, + // "status": 1, + // "date_entry": date, + // "user_id" : user._id, + // "common_area_id": service._id, + // "common_area_name": service.name, + // "community_id": service.community_id - } + // } - console.log(data); - try { + // console.log(data); + // 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 jsonDataResponse.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) => { + const currentDate = selectedDate; + setShow(false); + setTime(currentDate); + }; + const onChangeEnd = (event, selectedDate) => { + const currentDate = selectedDate; + setShow(false); + setEndTime(currentDate); + }; + return (
@@ -131,36 +144,22 @@ export default function AreaComun({navigation}){ Hora de inicio - { - setSelectedHours(hours); - setSelectedMinutes(minutes); - }}/> + Hora de finalización - { - setEndSelectedHours(hours); - setEndSelectedMinutes(minutes); - }}/> + - - diff --git a/mobile-ui/package.json b/mobile-ui/package.json index ba741594..310e6a33 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -38,7 +38,8 @@ "react-native-svg": "12.1.1", "react-native-table-component": "^1.2.2", "react-native-web": "0.17.1", - "universal-cookie": "^4.0.4" + "universal-cookie": "^4.0.4", + "@react-native-community/datetimepicker": "4.0.0" }, "devDependencies": { "@babel/core": "^7.12.9" From 51cdecd388250bf6fe72f0f9b2d6ae26d31d6e3b Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Wed, 24 Aug 2022 11:15:27 -0600 Subject: [PATCH 05/28] separar vistas del guarda e inquilino --- mobile-ui/App.js | 23 ++++++++++++++++++++++ mobile-ui/components/AreaComun.js | 8 ++++---- mobile-ui/components/Reservas.js | 1 + mobile-ui/components/ReservasCard/index.js | 4 ++-- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/mobile-ui/App.js b/mobile-ui/App.js index ed2b930a..f7b25e24 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -44,6 +44,28 @@ function HomeTab({ route }) { ) } + +function HomeTabGuarda({ route }) { + const { user } = useContext(UserContext); + const [selected, setSelected] = useState(0); + + return ( + + + (} 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 ( @@ -56,6 +78,7 @@ export default function App() { } }} /> + { @@ -144,13 +144,13 @@ export default function AreaComun({navigation}){ Hora de inicio - + Hora de finalización - + diff --git a/mobile-ui/components/Reservas.js b/mobile-ui/components/Reservas.js index 8ac0b01b..90d54b0c 100644 --- a/mobile-ui/components/Reservas.js +++ b/mobile-ui/components/Reservas.js @@ -70,6 +70,7 @@ export default function Reservas({navigation}) { startTime={item.start_time} endTime={item.finish_time} status={item.status} + name={item.common_area_name} /> )) } diff --git a/mobile-ui/components/ReservasCard/index.js b/mobile-ui/components/ReservasCard/index.js index 800cd75b..c255f3de 100644 --- a/mobile-ui/components/ReservasCard/index.js +++ b/mobile-ui/components/ReservasCard/index.js @@ -11,7 +11,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -export const ReservasCard = ({ date, startTime, endTime, status}) => { +export const ReservasCard = ({ date, startTime, endTime, status, name}) => { const dateFormated = format(new Date(date), "dd LL yyyy") @@ -44,7 +44,7 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => { {status == 1 ? 'LIBRE' : 'RESERVADO'} - Reserva #1 + {name} Date: Wed, 24 Aug 2022 19:58:49 -0600 Subject: [PATCH 06/28] profile dividing user info and password --- mobile-ui/components/LogIn.js | 1 + mobile-ui/components/Profile.js | 209 +++++++++++++++++++++++--------- mobile-ui/package.json | 3 +- 3 files changed, 155 insertions(+), 58 deletions(-) diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index fdb48f9f..f549fad3 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -60,6 +60,7 @@ export default function LogIn({ navigation }) { navigation.navigate('Comunicados', {user}) }else if(user.user_type == '3'){ addUser(user); + // cambiar por ComunicadosGuarda luego navigation.navigate('Comunicados', {user}) } }) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 76b45b55..1f42b353 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -1,29 +1,168 @@ 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 { Dimensions, StyleSheet, TextInput } from "react-native"; import { UserContext } from "../context/UserContext"; +import {SceneMap, TabView} from 'react-native-pager-view'; 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 [routes] = useState([{ + key: "first", + title: 'Información' + }, { + key: "second", + title: 'Contraseña'}]) const userData = useContext(UserContext) const id = userData.user._id; console.log(userData.user); + const ProfileView = () => { + + + + Bienvenido {userData.user.name} + + + Modifique sus datos + + + + DNI + + + {/* + Teléfono + + */} + + Nombre + setName(value) }/> + + + Apellido + setApellido(value) } /> + + + Correo electrónico + setEmail(value) }/> + + + + + + + + + } + + const PasswordView = () => { + + + + + + Bienvenido {userData.user.name} + + + Modifique sus contraseña + + + + + Contraseña actual + setPassword(value) }/> + + + Nueva Contraseña + setPassword(value) }/> + + + + Confirmar nueva contraseña + setPassword(value) }/> + + + + + + + + + + + } + + const initialLayout = { + width: Dimensions.get('window').width + } + + const renderScene = SceneMap({ + first: ProfileView, + second: PasswordView + }) + + + const renderTabBar = props => { + const inputRange = props.navigationState.routes.map((x, i) => i); + return + {props.navigationState.routes.map((route, i) => { + const opacity = props.position.interpolate({ + inputRange, + outputRange: inputRange.map(inputIndex => inputIndex === i ? 1 : 0.5) + }); + const color = index === i ? useColorModeValue('#000', '#e5e5e5') : useColorModeValue('#1f2937', '#a1a1aa'); + const borderColor = index === i ? 'cyan.500' : useColorModeValue('coolGray.200', 'gray.400'); + return + { + console.log(i); + setIndex(i); + }}> + {route.title} + + ; + })} + ; + }; + + const updateInfo = async() => { const data = { @@ -65,61 +204,17 @@ export default function Profile({ navigation }) { console.log("ERROR: " + error); } } + + + return (
- - - - - Bienvenido {userData.user.name} - - - Modifique sus datos - - - - DNI - - - {/* - Teléfono - - */} - - Nombre - setName(value) }/> - - - Apellido - setApellido(value) } /> - - - Correo electrónico - setEmail(value) }/> - - - Contraseña actual - setPassword(value) }/> - - - - - - - - + ;
) diff --git a/mobile-ui/package.json b/mobile-ui/package.json index 310e6a33..9e728a9c 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -39,7 +39,8 @@ "react-native-table-component": "^1.2.2", "react-native-web": "0.17.1", "universal-cookie": "^4.0.4", - "@react-native-community/datetimepicker": "4.0.0" + "@react-native-community/datetimepicker": "4.0.0", + "react-native-pager-view": "5.4.9" }, "devDependencies": { "@babel/core": "^7.12.9" From b7f6bc70bb04e52a96dedccc6f87e404082ed9fa Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Wed, 24 Aug 2022 20:38:31 -0600 Subject: [PATCH 07/28] top bar navigation profile --- mobile-ui/components/AreaComun.js | 4 +- mobile-ui/components/Profile.js | 101 +++++++++++++++--------------- mobile-ui/package.json | 8 ++- 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 01cd3807..735b6d56 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -144,13 +144,13 @@ export default function AreaComun({navigation}){ Hora de inicio - + Hora de finalización - + diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 1f42b353..55837943 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -4,9 +4,11 @@ import { Box, Button, Center, FormControl, Heading, ScrollView, VStack } from "native-base"; -import { Dimensions, StyleSheet, TextInput } from "react-native"; +import { Dimensions, StyleSheet, TextInput, useWindowDimensions } from "react-native"; import { UserContext } from "../context/UserContext"; -import {SceneMap, TabView} from 'react-native-pager-view'; +import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; + +const { Navigator, Screen } = createMaterialTopTabNavigator(); export default function Profile({ navigation }) { @@ -16,20 +18,21 @@ export default function Profile({ navigation }) { const [email, setEmail] = useState(); const [password, setPassword] = useState(); const [index, setIndex] = useState(0); + const layout = useWindowDimensions(); - const [routes] = useState([{ - key: "first", - title: 'Información' - }, { - key: "second", - title: 'Contraseña'}]) + // const [routes] = useState([{ + // key: "first", + // title: 'Información' + // }, { + // key: "second", + // title: 'Contraseña'}]) const userData = useContext(UserContext) const id = userData.user._id; console.log(userData.user); - const ProfileView = () => { + const ProfileView = () => ( - } + ) - const PasswordView = () => { + const PasswordView = () => ( - } + ) - const initialLayout = { - width: Dimensions.get('window').width - } + // const initialLayout = { + // width: Dimensions.get('window').width + // } - const renderScene = SceneMap({ - first: ProfileView, - second: PasswordView - }) + // const renderScene = SceneMap({ + // first: ProfileView, + // second: PasswordView + // }) - const renderTabBar = props => { - const inputRange = props.navigationState.routes.map((x, i) => i); - return - {props.navigationState.routes.map((route, i) => { - const opacity = props.position.interpolate({ - inputRange, - outputRange: inputRange.map(inputIndex => inputIndex === i ? 1 : 0.5) - }); - const color = index === i ? useColorModeValue('#000', '#e5e5e5') : useColorModeValue('#1f2937', '#a1a1aa'); - const borderColor = index === i ? 'cyan.500' : useColorModeValue('coolGray.200', 'gray.400'); - return - { - console.log(i); - setIndex(i); - }}> - {route.title} - - ; - })} - ; - }; + // const renderTabBar = props => { + // const inputRange = props.navigationState.routes.map((x, i) => i); + // return + // {props.navigationState.routes.map((route, i) => { + // const opacity = props.position.interpolate({ + // inputRange, + // outputRange: inputRange.map(inputIndex => inputIndex === i ? 1 : 0.5) + // }); + // const color = index === i ? useColorModeValue('#000', '#e5e5e5') : useColorModeValue('#1f2937', '#a1a1aa'); + // const borderColor = index === i ? 'cyan.500' : useColorModeValue('coolGray.200', 'gray.400'); + // return + // { + // console.log(i); + // setIndex(i); + // }}> + // {route.title} + // + // ; + // })} + // ; + // }; const updateInfo = async() => { @@ -208,14 +211,12 @@ export default function Profile({ navigation }) { return ( -
- ; -
+ + + + + + ) diff --git a/mobile-ui/package.json b/mobile-ui/package.json index 9e728a9c..dec3d08f 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -17,8 +17,10 @@ "eject": "expo eject" }, "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,16 +33,16 @@ "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-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", - "@react-native-community/datetimepicker": "4.0.0", - "react-native-pager-view": "5.4.9" + "universal-cookie": "^4.0.4" }, "devDependencies": { "@babel/core": "^7.12.9" From 8ed2a70eeee289a0c21f832a3b8155ba8d6ee223 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:36:13 -0600 Subject: [PATCH 08/28] Eliminar invitado --- api-gateway/src/app.controller.ts | 6 ++- api-gateway/src/app.service.ts | 14 ++++- mobile-ui/App.js | 2 +- mobile-ui/components/AgregarInvitados.js | 1 + mobile-ui/components/Invitados.js | 51 +++++++++++++++---- .../src/guests/guests.controller.ts | 2 +- .../src/guests/guests.service.ts | 3 +- 7 files changed, 65 insertions(+), 14 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index e53d3fb4..821808d9 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -431,7 +431,11 @@ export class AppController { findGuestUser(@Param('id') paramGuestId: string) { return this.appService.findGuestUser(paramGuestId); } - + @Post('guest/updateGuest') + updateGuest( + @Body('_id') _id: string){ + return this.appService.updateGuest(_id); + } // #==== API Payment diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 7aa40f38..c9b1aa6a 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -322,6 +322,7 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } + //GET parameter from API findCommunityAdmin(community_id: string) { const pattern = { cmd: 'findCommunityAdmin' }; @@ -541,11 +542,22 @@ 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 }))); } + + updateGuest(_id: string + ) { + const pattern = { cmd: 'removeGuest' }; + const payload = { + _id: _id + }; + return this.clientGuestApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))) + } // ====================== PAYMENTS =============================== //POST parameter from API diff --git a/mobile-ui/App.js b/mobile-ui/App.js index f7b25e24..08c2a79d 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -72,7 +72,7 @@ export default function App() { - { @@ -42,6 +45,34 @@ 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 ( @@ -67,20 +98,22 @@ export default function Invitados({navigation}) { - {item.dni} + {"Identificación: "+item.dni} - (506) {item.phone} + {"Teléfono: "+item.phone} + + {"Número Placa: "+item.number_plate} + + - - {item.number_plate} - + {deleteInvitado(item._id)}} /> } keyExtractor={item => item.id} /> diff --git a/servicio-invitados/src/guests/guests.controller.ts b/servicio-invitados/src/guests/guests.controller.ts index 17ba36b4..3e306f6e 100644 --- a/servicio-invitados/src/guests/guests.controller.ts +++ b/servicio-invitados/src/guests/guests.controller.ts @@ -39,7 +39,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..e0ea9807 100644 --- a/servicio-invitados/src/guests/guests.service.ts +++ b/servicio-invitados/src/guests/guests.service.ts @@ -18,7 +18,8 @@ export class GuestsService { } async findGuestUser(id: string): Promise { - return this.guestModel.find({_tenant_id:id}).setOptions({ sanitizeFilter: true }).exec(); + console.log(id); + return this.guestModel.find({_tenant_id:id, status:"-0"}).setOptions({ sanitizeFilter: true }).exec(); } findOneId(id: string): Promise { From da98c3ab2621e7bbd777a2a194bd594e1fcf1ff4 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:36:55 -0600 Subject: [PATCH 09/28] Correcciones --- mobile-ui/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile-ui/App.js b/mobile-ui/App.js index 08c2a79d..f7b25e24 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -72,7 +72,7 @@ export default function App() { - Date: Thu, 25 Aug 2022 15:41:02 -0600 Subject: [PATCH 10/28] validacion log in --- mobile-ui/components/LogIn.js | 71 ++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 10 deletions(-) diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index f549fad3..9ef64fdc 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -23,18 +23,47 @@ 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", - password: "12345" + email: "", + password: "" }); 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', @@ -68,12 +97,15 @@ export default function LogIn({ navigation }) { } catch (error) { console.log("ERROR: " +error); } - + + } + + console.log(errors); } return ( -
+
@@ -107,23 +139,26 @@ export default function LogIn({ navigation }) { - - + + Correo Electrónico - + - + {'email' in errors && Debe ingresar un correo electrónico } - + Contraseña @@ -134,7 +169,12 @@ export default function LogIn({ navigation }) { value={credentials.password} placeholder='Contraseña' onChangeText={onHandleChange("password")} /> + + {'password' in errors && Debe ingresar una contraseña } Date: Fri, 26 Aug 2022 08:36:55 -0600 Subject: [PATCH 11/28] fix validacion log in --- mobile-ui/components/LogIn.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index 9ef64fdc..93af27a8 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'; @@ -83,6 +84,8 @@ export default function LogIn({ navigation }) { // inqulino 4 y guarda 3 const user = response.message + + if(user !== null){ if(user.user_type == '4'){ addUser(user); @@ -92,10 +95,17 @@ export default function LogIn({ navigation }) { // cambiar por ComunicadosGuarda luego navigation.navigate('Comunicados', {user}) } + }else{ + setErrors({ ...errors, + user: 'Debe ingresar credenciales válidos' + }); + } + }) } catch (error) { console.log("ERROR: " +error); + } } @@ -148,7 +158,7 @@ export default function LogIn({ navigation }) { @@ -158,6 +168,7 @@ export default function LogIn({ navigation }) { fontSize: 'xs' }}>Debe ingresar un correo electrónico } + Contraseña @@ -165,7 +176,7 @@ export default function LogIn({ navigation }) { @@ -196,6 +207,10 @@ export default function LogIn({ navigation }) { > Continuar + {/* {'user' in errors && Debe ingresar credenciales válidos } */} @@ -214,21 +229,22 @@ 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, - paddingBottom: 10, paddingLeft: 0, + marginTop: 50, + borderRadius: 4, + borderColor: '#be123c' }, iconStyle: { @@ -242,8 +258,7 @@ const styles = StyleSheet.create({ flexDirection: 'row', justifyContent: 'center', alignItems: 'center', - - marginBottom: 28 + marginBottom: 50 }, container: { From 0ebe59cb8065952a832dd9f76e9f987db74e0309 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Fri, 26 Aug 2022 15:01:29 -0600 Subject: [PATCH 12/28] validaciones en agregar invitados --- mobile-ui/components/AgregarInvitados.js | 140 ++++++++++++++++------- mobile-ui/components/LogIn.js | 4 +- 2 files changed, 102 insertions(+), 42 deletions(-) diff --git a/mobile-ui/components/AgregarInvitados.js b/mobile-ui/components/AgregarInvitados.js index 9a8c354e..288cd7c9 100644 --- a/mobile-ui/components/AgregarInvitados.js +++ b/mobile-ui/components/AgregarInvitados.js @@ -20,47 +20,91 @@ 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 [info, setInfo] = useState({ + name: "", + last_name: "", + dni: "", + phone: "", + number_plate:"", + status: "-0", + 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(); - const data = { - "name": name, - "last_name": apellido, - "dni": dni, - "phone": phone, - "number_plate": number_plate, - "status":"-0", - "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{ + 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 - setPhone(value)} /> + + + {/* {'password' in error && La contraseña no coincide con la actual } */} @@ -202,18 +213,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/package.json b/mobile-ui/package.json index 8576d722..b07de02d 100644 --- a/mobile-ui/package.json +++ b/mobile-ui/package.json @@ -14,7 +14,8 @@ "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", @@ -46,7 +47,8 @@ "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" From b117491db9738cb6c2171a427ed24adeed342694 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 30 Aug 2022 21:51:17 -0600 Subject: [PATCH 18/28] fix update profile --- mobile-ui/components/Profile.js | 62 ++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 59d261ac..dfe7e718 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -121,20 +121,20 @@ export default function Profile({ navigation }) { Contraseña actual - onHandleChangePassword(value) }/> + onHandleChangePassword(value) }/> Nueva Contraseña - setPassword(value) } /> + setPassword(value) } /> Confirmar nueva contraseña - setPassword(value) }/> + setPassword(value) }/> - @@ -152,22 +152,60 @@ export default function Profile({ navigation }) { 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){ + console.log('ocurrio un error '); + }else{ + return response.json(); + } + }) + + } catch (error) { + console.log("ERROR: " + error); + } } const updateInfo = async() => { const data = { - "_id": "6301df20dac7dcf76dcecade", - "dni": "1234567890", + "_id": userData.user._id, + "dni": userData.user.dni, "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, + "phone": userData.user.phone, + "password": userData.user.password, + "user_type": userData.user.user_type, + "status": userData.user.status, + "date_entry": userData.user.date_entry, + "community_id": userData.user.community_id, } try { From 8d020cf055fd61903c01d90bff105b7e166744a0 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 30 Aug 2022 22:50:25 -0600 Subject: [PATCH 19/28] valdiacion reservas --- mobile-ui/components/AreaComun.js | 2 +- mobile-ui/components/Profile.js | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 74c89b88..3f1e4ac9 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -144,7 +144,7 @@ export default function AreaComun({navigation}){ Hora de inicio - + diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index dfe7e718..6282967b 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -15,13 +15,13 @@ const { Navigator, Screen } = createMaterialTopTabNavigator(); export default function Profile({ navigation }) { const baseURL = `${API.BASE_URL}/user/updateUser/` - 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 id = userData.user._id; const decode = userData.Password; const [error, setError] = useState({}) @@ -37,6 +37,7 @@ export default function Profile({ navigation }) { console.log(userData.user.password); if (userData.user.password == dpassword) { console.log(true); + setError({}); }else{ console.log(false); setError({ ...error, @@ -79,7 +80,7 @@ export default function Profile({ navigation }) { Apellido - setApellido(value) } /> + setApellido(value) } /> Correo electrónico @@ -179,9 +180,10 @@ export default function Profile({ navigation }) { }) .then(response => { - console.log(baseURL+`${id}`); + // console.log(baseURL+`${id}`); if (response.status != 201){ console.log('ocurrio un error '); + }else{ return response.json(); } @@ -206,8 +208,11 @@ export default function Profile({ navigation }) { "status": userData.user.status, "date_entry": userData.user.date_entry, "community_id": userData.user.community_id, + "number_house": '20' } + console.log(data); + try { await fetch(baseURL+`${id}`, { @@ -221,9 +226,10 @@ export default function Profile({ navigation }) { }) .then(response => { - console.log(baseURL+`${id}`); + //console.log(baseURL+`${id}`); if (response.status != 201){ - console.log('ocurrio un error '); + // console.log('ocurrio un error '); + console.log(response.json()); }else{ return response.json(); } From d95ffb385304e26afdbba50ba4f2f1966b8fe9d9 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Tue, 30 Aug 2022 22:50:34 -0600 Subject: [PATCH 20/28] Pantallas guarda de seguridad Lista de invitados y comunicados por la comunidad a la que el guarda corresponde --- api-gateway/src/app.controller.ts | 11 ++++- api-gateway/src/app.service.ts | 16 +++++++ mobile-ui/components/CommentCard/index.js | 12 +++--- mobile-ui/components/Home.js | 39 +++++++++++------ mobile-ui/components/Invitados.js | 42 ++++++++++++------- .../post-comments/post-comments.controller.ts | 6 +++ .../post-comments/post-comments.service.ts | 5 +++ .../src/posts/posts.controller.ts | 5 +++ .../src/posts/posts.service.ts | 5 +++ .../src/guests/guests.controller.ts | 5 +++ .../src/guests/guests.service.ts | 6 ++- 11 files changed, 115 insertions(+), 37 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index eaf4e71f..f865c1fd 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -433,6 +433,12 @@ export class AppController { findGuestUser(@Param('id') paramGuestId: string) { 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){ @@ -523,7 +529,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); diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 73077be2..605c4688 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -549,6 +549,14 @@ export class AppService { .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' }; @@ -655,6 +663,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' }; 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 2fdfaf75..b43a1afc 100644 --- a/mobile-ui/components/Invitados.js +++ b/mobile-ui/components/Invitados.js @@ -15,6 +15,10 @@ export default function Invitados({navigation}) { 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(() => { @@ -23,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) { } @@ -118,13 +132,9 @@ export default function Invitados({navigation}) { - {deleteInvitado(item._id)}} /> + {user_type == 3 && {deleteInvitado(item._id)}} />} } keyExtractor={item => item.id} /> - - - - 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/src/guests/guests.controller.ts b/servicio-invitados/src/guests/guests.controller.ts index 3e306f6e..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']; diff --git a/servicio-invitados/src/guests/guests.service.ts b/servicio-invitados/src/guests/guests.service.ts index 87da8833..f2343b7e 100644 --- a/servicio-invitados/src/guests/guests.service.ts +++ b/servicio-invitados/src/guests/guests.service.ts @@ -18,10 +18,14 @@ export class GuestsService { } async findGuestUser(id: string): Promise { - console.log(id); 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 { return this.guestModel.findOne({ _id: id }).exec(); } From 094ee575c4ea725ce5ffe0529c874a3391ecbb01 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Tue, 30 Aug 2022 23:02:15 -0600 Subject: [PATCH 21/28] reservas validaciones --- mobile-ui/components/AreaComun.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 3f1e4ac9..80256919 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -144,7 +144,7 @@ export default function AreaComun({navigation}){ Hora de inicio - + From 4558b2cc64ec7d048fa757166dda352244ff5d44 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Wed, 31 Aug 2022 09:25:16 -0600 Subject: [PATCH 22/28] fix response from server --- mobile-ui/components/Profile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index 6282967b..7dcabffa 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -181,8 +181,8 @@ export default function Profile({ navigation }) { .then(response => { // console.log(baseURL+`${id}`); - if (response.status != 201){ - console.log('ocurrio un error '); + if (response.status != 201 && response.status != 200){ + console.log('ocurrio un error ' + response); }else{ return response.json(); From a6d68abda5b58432076a24bb005f98534672424a Mon Sep 17 00:00:00 2001 From: Mariela Date: Wed, 31 Aug 2022 12:27:10 -0600 Subject: [PATCH 23/28] fix api update user --- api-gateway/src/app.controller.ts | 19 ++----------------- api-gateway/src/app.service.ts | 10 ---------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 70398768..f7c857f3 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 ); } diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 5b70fffc..f9d8274d 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) From 1481cc2c4edd485cfd4332434dc223d820012e37 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Wed, 31 Aug 2022 22:11:13 -0600 Subject: [PATCH 24/28] =?UTF-8?q?Reservaci=C3=B3n=20por=20id=20de=20inquil?= =?UTF-8?q?ino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-gateway/src/app.controller.ts | 6 ++++++ api-gateway/src/app.service.ts | 8 ++++++++ mobile-ui/App.js | 2 +- mobile-ui/components/Reservas.js | 4 +++- servicio-reservaciones/package-lock.json | 1 - .../src/reservations/reservations.controller.ts | 6 ++++++ .../src/reservations/reservations.service.ts | 4 ++++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index f865c1fd..8014ab26 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -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); + } + } diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 605c4688..74c70b9b 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -786,4 +786,12 @@ export class AppService { return pass; } + + 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 f7b25e24..da04b65e 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -72,7 +72,7 @@ export default function App() { - { @@ -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' diff --git a/servicio-reservaciones/package-lock.json b/servicio-reservaciones/package-lock.json index 37e3caca..9e9de38f 100644 --- a/servicio-reservaciones/package-lock.json +++ b/servicio-reservaciones/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "servicio-reservaciones", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { diff --git a/servicio-reservaciones/src/reservations/reservations.controller.ts b/servicio-reservaciones/src/reservations/reservations.controller.ts index 49621768..038b1433 100644 --- a/servicio-reservaciones/src/reservations/reservations.controller.ts +++ b/servicio-reservaciones/src/reservations/reservations.controller.ts @@ -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); + } } diff --git a/servicio-reservaciones/src/reservations/reservations.service.ts b/servicio-reservaciones/src/reservations/reservations.service.ts index 45382f50..9c4130fa 100644 --- a/servicio-reservaciones/src/reservations/reservations.service.ts +++ b/servicio-reservaciones/src/reservations/reservations.service.ts @@ -45,4 +45,8 @@ export class ReservationsService { new: true, }); } + + async findReservationUser(id: string): Promise { + return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec(); + } } From 8b09f2812f49af81cf79f911a9bf6683ff9c87f7 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Wed, 31 Aug 2022 22:14:08 -0600 Subject: [PATCH 25/28] fix reservas --- mobile-ui/components/AreaComun.js | 21 ++++++------------- mobile-ui/components/Profile.js | 15 +++++++------ .../src/users/users.controller.ts | 4 +++- servicio-usuarios/src/users/users.service.ts | 5 ++++- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/mobile-ui/components/AreaComun.js b/mobile-ui/components/AreaComun.js index 80256919..42d0d224 100644 --- a/mobile-ui/components/AreaComun.js +++ b/mobile-ui/components/AreaComun.js @@ -20,13 +20,10 @@ export default function AreaComun({navigation}){ const [service, setService] = useState(""); const [areas, setAreas] = useState([]) const [isRequesting, setIsRequesting] = useState(false); - const [selectedHours, setSelectedHours] = useState(0); - const [selectedMinutes, setSelectedMinutes] = useState(0); - const [endSelectedHours, setEndSelectedHours] = useState(0); - const [endSelectedMinutes, setEndSelectedMinutes] = useState(0); const [time, setTime] = useState(new Date()) - const [endTime, setEndTime] = useState(new Date()) + const idComunidad = user.community_id const date = new Date(); + const [mode, setMode] = useState('time'); useEffect(() => { @@ -36,7 +33,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' @@ -44,7 +41,7 @@ export default function AreaComun({navigation}){ }) const response = await jsonResponse.json(); - console.log(response.message); + // console.log(response.message); setAreas(response.message); @@ -102,16 +99,10 @@ export default function AreaComun({navigation}){ const onChangeStart = (event, selectedDate) => { - const currentDate = selectedDate; - setShow(false); + const currentDate = selectedDate || time; + setTime(currentDate); }; - const onChangeEnd = (event, selectedDate) => { - const currentDate = selectedDate; - setShow(false); - setEndTime(currentDate); - }; - return (
diff --git a/mobile-ui/components/Profile.js b/mobile-ui/components/Profile.js index b8904eff..baeb64ad 100644 --- a/mobile-ui/components/Profile.js +++ b/mobile-ui/components/Profile.js @@ -4,7 +4,7 @@ import { Box, Button, Center, FormControl, Heading, ScrollView, VStack } from "native-base"; -import { Dimensions, StyleSheet, TextInput, useWindowDimensions } 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'; @@ -14,7 +14,7 @@ const { Navigator, Screen } = createMaterialTopTabNavigator(); export default function Profile({ navigation }) { - const baseURL = `${API.BASE_URL}/user/updateGuarda/` + const baseURL = `${API.BASE_URL}/user/updateUser/` const [index, setIndex] = useState(0); const layout = useWindowDimensions(); const userData = useContext(UserContext) @@ -22,6 +22,7 @@ export default function Profile({ navigation }) { 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({}) @@ -132,7 +133,7 @@ export default function Profile({ navigation }) { Confirmar nueva contraseña - setPassword(value) }/> + setConfirmPassword(value) }/>