Merge branch 'dev' into US-24-EditarinformacióncomoAdministradordeComunidaddeViviendas
This commit is contained in:
commit
32966d8334
|
@ -5,7 +5,6 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "api-gateway",
|
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -149,12 +149,7 @@ export class AppController {
|
||||||
@Body('last_name') last_name: string,
|
@Body('last_name') last_name: string,
|
||||||
@Body('email') email: string,
|
@Body('email') email: string,
|
||||||
@Body('phone') phone: number,
|
@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('community_id') community_id: string,
|
||||||
@Body('number_house') number_house: string,
|
|
||||||
) {
|
) {
|
||||||
return this.appService.updateUser(
|
return this.appService.updateUser(
|
||||||
id,
|
id,
|
||||||
|
@ -163,12 +158,7 @@ export class AppController {
|
||||||
last_name,
|
last_name,
|
||||||
email,
|
email,
|
||||||
phone,
|
phone,
|
||||||
password,
|
community_id
|
||||||
user_type,
|
|
||||||
status,
|
|
||||||
date_entry,
|
|
||||||
community_id,
|
|
||||||
number_house,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,12 +245,7 @@ export class AppController {
|
||||||
last_name,
|
last_name,
|
||||||
email,
|
email,
|
||||||
phone,
|
phone,
|
||||||
password,
|
password
|
||||||
user_type,
|
|
||||||
status,
|
|
||||||
date_entry,
|
|
||||||
community_id,
|
|
||||||
number_house,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,6 +478,7 @@ export class AppController {
|
||||||
@Body('tenant_id') tenant_id: string,
|
@Body('tenant_id') tenant_id: string,
|
||||||
@Body('community_id') community_id: string,
|
@Body('community_id') community_id: string,
|
||||||
@Body('date_entry') date_entry: Date,
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('type_guest') type_guest: string,
|
||||||
) {
|
) {
|
||||||
return this.appService.createGuest(
|
return this.appService.createGuest(
|
||||||
name,
|
name,
|
||||||
|
@ -504,6 +490,7 @@ export class AppController {
|
||||||
tenant_id,
|
tenant_id,
|
||||||
community_id,
|
community_id,
|
||||||
date_entry,
|
date_entry,
|
||||||
|
type_guest,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,6 +509,16 @@ export class AppController {
|
||||||
return this.appService.findGuestUser(paramGuestId);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -598,7 +595,10 @@ export class AppController {
|
||||||
allPosts() {
|
allPosts() {
|
||||||
return this.appService.allPosts();
|
return this.appService.allPosts();
|
||||||
}
|
}
|
||||||
|
@Get('post/findPostCommunity/:id')
|
||||||
|
findPostCommunity(@Param('id') paramPost: string) {
|
||||||
|
return this.appService.findPostCommunity(paramPost);
|
||||||
|
}
|
||||||
@Get('post/find/:id')
|
@Get('post/find/:id')
|
||||||
findPost(@Param('id') paramPost: string) {
|
findPost(@Param('id') paramPost: string) {
|
||||||
return this.appService.findPost(paramPost);
|
return this.appService.findPost(paramPost);
|
||||||
|
@ -666,4 +666,10 @@ export class AppController {
|
||||||
html(@Body('email') email: string, @Body('name') name: string) {
|
html(@Body('email') email: string, @Body('name') name: string) {
|
||||||
return this.appService.html(email, name);
|
return this.appService.html(email, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('reservation/findReservationUser/:id')
|
||||||
|
findReservationUser(@Param('id') paramComment: string) {
|
||||||
|
return this.appService.findReservationUser(paramComment);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,12 +94,7 @@ export class AppService {
|
||||||
last_name: string,
|
last_name: string,
|
||||||
email: string,
|
email: string,
|
||||||
phone: number,
|
phone: number,
|
||||||
password: string,
|
|
||||||
user_type: string,
|
|
||||||
status: string,
|
|
||||||
date_entry: Date,
|
|
||||||
community_id: string,
|
community_id: string,
|
||||||
number_house: string,
|
|
||||||
) {
|
) {
|
||||||
const pattern = { cmd: 'updateUser' };
|
const pattern = { cmd: 'updateUser' };
|
||||||
const payload = {
|
const payload = {
|
||||||
|
@ -109,12 +104,7 @@ export class AppService {
|
||||||
last_name: last_name,
|
last_name: last_name,
|
||||||
email: email,
|
email: email,
|
||||||
phone: phone,
|
phone: phone,
|
||||||
password: password,
|
|
||||||
user_type: user_type,
|
|
||||||
status: status,
|
|
||||||
date_entry: date_entry,
|
|
||||||
community_id: community_id,
|
community_id: community_id,
|
||||||
number_house: number_house,
|
|
||||||
};
|
};
|
||||||
return this.clientUserApp
|
return this.clientUserApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
|
@ -368,6 +358,7 @@ export class AppService {
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//GET parameter from API
|
//GET parameter from API
|
||||||
findCommunityAdmin(community_id: string) {
|
findCommunityAdmin(community_id: string) {
|
||||||
const pattern = { cmd: 'findCommunityAdmin' };
|
const pattern = { cmd: 'findCommunityAdmin' };
|
||||||
|
@ -596,11 +587,13 @@ export class AppService {
|
||||||
tenant_id: string,
|
tenant_id: string,
|
||||||
community_id: string,
|
community_id: string,
|
||||||
date_entry: Date,
|
date_entry: Date,
|
||||||
|
type_guest: string,
|
||||||
) {
|
) {
|
||||||
const pattern = { cmd: 'createGuest' };
|
const pattern = { cmd: 'createGuest' };
|
||||||
const payload = {
|
const payload = {
|
||||||
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
|
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
|
return this.clientGuestApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
|
@ -626,12 +619,30 @@ export class AppService {
|
||||||
//GET parameter from API
|
//GET parameter from API
|
||||||
findGuestUser(paramGuestId: string) {
|
findGuestUser(paramGuestId: string) {
|
||||||
const pattern = { cmd: 'findGuestUser' };
|
const pattern = { cmd: 'findGuestUser' };
|
||||||
const payload = { di: paramGuestId };
|
const payload = { id: paramGuestId };
|
||||||
return this.clientGuestApp
|
return this.clientGuestApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findGuestCommunityr(paramGuestId: string) {
|
||||||
|
const pattern = { cmd: 'findGuestCommunity' };
|
||||||
|
const payload = { id: paramGuestId };
|
||||||
|
return this.clientGuestApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((message: string) => ({ message })));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGuest(_id: string
|
||||||
|
) {
|
||||||
|
const pattern = { cmd: 'removeGuest' };
|
||||||
|
const payload = {
|
||||||
|
_id: _id
|
||||||
|
};
|
||||||
|
return this.clientGuestApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((message: string) => ({ message })))
|
||||||
|
}
|
||||||
// ====================== RESERVATIONS ===============================
|
// ====================== RESERVATIONS ===============================
|
||||||
|
|
||||||
//POST parameter from API
|
//POST parameter from API
|
||||||
|
@ -716,6 +727,14 @@ export class AppService {
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findPostCommunity(paramGuestId: string) {
|
||||||
|
const pattern = { cmd: 'findPostCommunity' };
|
||||||
|
const payload = { id: paramGuestId };
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((message: string) => ({ message })));
|
||||||
|
}
|
||||||
|
|
||||||
//GET parameter from API
|
//GET parameter from API
|
||||||
findPost(paramPostId: string) {
|
findPost(paramPostId: string) {
|
||||||
const pattern = { cmd: 'findOnePost' };
|
const pattern = { cmd: 'findOnePost' };
|
||||||
|
@ -814,8 +833,6 @@ export class AppService {
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Function to generate combination of password */
|
/* Function to generate combination of password */
|
||||||
generatePassword() {
|
generatePassword() {
|
||||||
var pass = '';
|
var pass = '';
|
||||||
|
@ -832,8 +849,6 @@ export class AppService {
|
||||||
return pass;
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async saveTenantNumHouse(community_id: string, number_house: string, tenant_id: string) {
|
async saveTenantNumHouse(community_id: string, number_house: string, tenant_id: string) {
|
||||||
|
|
||||||
const pattern = { cmd: 'saveTenantNumHouse' }
|
const pattern = { cmd: 'saveTenantNumHouse' }
|
||||||
|
@ -846,4 +861,13 @@ export class AppService {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
findReservationUser(paramGuestId: string) {
|
||||||
|
const pattern = { cmd: 'findReservationUser' };
|
||||||
|
const payload = { id: paramGuestId };
|
||||||
|
return this.clientReservationApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((message: string) => ({ message })));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,14 +27,14 @@ function HomeTab({ route }) {
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<Tab.Navigator initialParams={user} initialRouteName="Comunicados" >
|
<Tab.Navigator initialParams={user} initialRouteName="Comunicados" >
|
||||||
<Tab.Screen name="Comunicados" component={Home} initialParams={user} options={{headerStyle: {
|
<Tab.Screen name="Mis Comunicados" component={Home} initialParams={user} options={{headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}
|
||||||
/>
|
/>
|
||||||
<Tab.Screen name="Reservas" component={Reservas } initialParams={user} options={{headerStyle: {
|
<Tab.Screen name="Mis Reservas" component={Reservas } initialParams={user} options={{headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
||||||
<Tab.Screen name="Invitados" component={Invitados} initialParams={user} options={{headerStyle: {
|
<Tab.Screen name="Mis Invitados" component={Invitados} initialParams={user} options={{headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'contacts' : 'contacts-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'contacts' : 'contacts-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
||||||
<Tab.Screen name="Perfil" component={Profile} initialParams={user} options={{headerStyle: {
|
<Tab.Screen name="Perfil" component={Profile} initialParams={user} options={{headerStyle: {
|
||||||
|
@ -44,25 +44,53 @@ function HomeTab({ route }) {
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function HomeTabGuarda({ route }) {
|
||||||
|
const { user } = useContext(UserContext);
|
||||||
|
const [selected, setSelected] = useState(0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<Tab.Navigator initialParams={user} initialRouteName="Comunicados" >
|
||||||
|
<Tab.Screen name="Mis Comunicados Guarda" component={Home} initialParams={user} options={{headerStyle: {
|
||||||
|
backgroundColor: "#D7A86E"
|
||||||
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)}
|
||||||
|
/>
|
||||||
|
<Tab.Screen name="Mis Invitados" component={Invitados} initialParams={user} options={{headerStyle: {
|
||||||
|
backgroundColor: "#D7A86E"
|
||||||
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'contacts' : 'contacts-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
|
||||||
|
<Tab.Screen name="Mi Perfil" component={Profile} initialParams={user} options={{headerStyle: {
|
||||||
|
backgroundColor: "#D7A86E"
|
||||||
|
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 2 ? 'account' : 'account-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(2)} />
|
||||||
|
</Tab.Navigator>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
<NativeBaseProvider>
|
<NativeBaseProvider>
|
||||||
<UserContextProvider>
|
<UserContextProvider>
|
||||||
<NavigationContainer>
|
<NavigationContainer>
|
||||||
<Stack.Navigator initialRouteName="LogIn">
|
<Stack.Navigator initialRouteName="Iniciar Sesión">
|
||||||
<Stack.Screen name="Inicio" component={LogIn} options={{
|
{/* <Stack.Screen name="Mis Reservas" component={Reservas} options={{
|
||||||
headerStyle: {
|
headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}
|
}
|
||||||
}} />
|
}} /> */}
|
||||||
<Stack.Screen name="Comunicados" component={HomeTab} options={{ headerShown: false }} />
|
<Stack.Screen name="Comunicados" component={HomeTab} options={{ headerShown: false }} />
|
||||||
<Stack.Screen name="Password" component={RecoverPassword} />
|
<Stack.Screen name="Comunicados Guarda" component={HomeTabGuarda} options={{ headerShown: false }} />
|
||||||
<Stack.Screen name="area" component={AreaComun} options={{
|
|
||||||
|
<Stack.Screen name="Reservar" component={AreaComun} options={{
|
||||||
headerStyle: {
|
headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}
|
}
|
||||||
}} />
|
}} />
|
||||||
<Stack.Screen name="invitado" component={AgregarInvitados} options={{
|
<Stack.Screen name="Agregar Invitado" component={AgregarInvitados} options={{
|
||||||
|
headerStyle: {
|
||||||
|
backgroundColor: "#D7A86E"
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
<Stack.Screen name="Iniciar Sesión" component={LogIn} options={{
|
||||||
headerStyle: {
|
headerStyle: {
|
||||||
backgroundColor: "#D7A86E"
|
backgroundColor: "#D7A86E"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { API } from "../environment/api";
|
import { API } from "../environment/api";
|
||||||
|
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
||||||
import {
|
import {
|
||||||
Box, Button,
|
Box, Button,
|
||||||
Center, FormControl, Heading, ScrollView, VStack
|
Center, FormControl, Heading, ScrollView, VStack,Select
|
||||||
} from "native-base";
|
} from "native-base";
|
||||||
|
|
||||||
import { StyleSheet, TextInput } from "react-native";
|
import { StyleSheet, TextInput } from "react-native";
|
||||||
|
@ -20,46 +20,96 @@ export default function AgregarInvitados({ navigation }) {
|
||||||
const [tenant_id, setTenant_id] = useState();
|
const [tenant_id, setTenant_id] = useState();
|
||||||
const [community_id, setCommunity_id] = useState();
|
const [community_id, setCommunity_id] = useState();
|
||||||
const { user } = useContext(UserContext);
|
const { user } = useContext(UserContext);
|
||||||
|
const [errors, setErrors] = useState({});
|
||||||
|
const [categoria, setCategoria] = React.useState("");
|
||||||
|
|
||||||
|
const [info, setInfo] = useState({
|
||||||
|
name: "",
|
||||||
|
last_name: "",
|
||||||
|
dni: "",
|
||||||
|
phone: "",
|
||||||
|
number_plate:"",
|
||||||
|
status: "1",
|
||||||
|
tenant_id: user._id,
|
||||||
|
//tenant_id: "6301df20dac7dcf76dcecade",
|
||||||
|
community_id: user.community_id,
|
||||||
|
//community_id: "62be68215692582bbfd77134",
|
||||||
|
type_guest:""
|
||||||
|
});
|
||||||
|
|
||||||
|
const 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 saveInvitado = async() => {
|
||||||
|
const error = await validate();
|
||||||
|
|
||||||
const data = {
|
if (error) {
|
||||||
"name": name,
|
try {
|
||||||
"last_name": apellido,
|
|
||||||
"dni": dni,
|
await fetch(baseURL, {
|
||||||
"phone": phone,
|
|
||||||
"number_plate": number_plate,
|
cache: 'no-cache',
|
||||||
"tenant_id": user.id,
|
method: 'POST',
|
||||||
"community_id": user.community_id
|
body: JSON.stringify(info),
|
||||||
}
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
try {
|
}
|
||||||
|
})
|
||||||
await fetch(baseURL, {
|
.then(response => {
|
||||||
|
if (response.status != 201){
|
||||||
cache: 'no-cache',
|
console.log('ocurrio un error ');
|
||||||
method: 'POST',
|
}else{
|
||||||
body: JSON.stringify(data),
|
navigation.navigate('Inicio');
|
||||||
headers: {
|
return response.json();
|
||||||
'Content-Type': 'application/json'
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
.then(response => {
|
} catch (error) {
|
||||||
if (response.status != 201){
|
console.log("ERROR: " + error);
|
||||||
console.log('ocurrio un error ');
|
}
|
||||||
}else{
|
|
||||||
return response.json();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log("ERROR: " + error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Center>
|
<Center>
|
||||||
|
|
||||||
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
|
<ScrollView width='100%' h='570' ml='36' _contentContainerStyle={{
|
||||||
px: "20px",
|
px: "20px",
|
||||||
mb: "4",
|
mb: "4",
|
||||||
minW: "72"
|
minW: "72"
|
||||||
|
@ -75,22 +125,41 @@ export default function AgregarInvitados({ navigation }) {
|
||||||
}} fontWeight="medium" size="xs">
|
}} fontWeight="medium" size="xs">
|
||||||
Registre el invitado que desee
|
Registre el invitado que desee
|
||||||
</Heading>
|
</Heading>
|
||||||
<VStack space={3} mt="5">
|
<VStack space={5} mt="5">
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormControl.Label>Nombre</FormControl.Label>
|
<FormControl.Label>Nombre</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text" onChangeText={(value) => setName(value)}/>
|
<TextInput style={'name' in errors ? styles.errorMessage : styles.input} type="text" onChangeText={onHandleChange("name")}/>
|
||||||
|
{'name' in errors && <FormControl.ErrorMessage _text={{
|
||||||
|
fontSize: 'xs'
|
||||||
|
}}>Debe ingresar un correo electrónico</FormControl.ErrorMessage> }
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormControl.Label>Apellido</FormControl.Label>
|
<FormControl.Label>Apellido</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text" onChangeText={(value) => setApellido(value)}/>
|
<TextInput style={'last_name' in errors ? styles.errorMessage : styles.input} type="text" onChangeText={onHandleChange("last_name")}/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormControl.Label>Identificación</FormControl.Label>
|
<FormControl.Label>Identificación</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text" onChangeText={(value) => setDNI(value)}/>
|
<TextInput style={'dni' in errors ? styles.errorMessage : styles.input}type="text" onChangeText={onHandleChange("dni")}/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormControl.Label>Teléfono</FormControl.Label>
|
<FormControl.Label>Teléfono</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text" onChangeText={(value) => setPhone(value)} />
|
<TextInput style={'phone' in errors ? styles.errorMessage : styles.input}type="text" onChangeText={onHandleChange("phone")} />
|
||||||
|
</FormControl>
|
||||||
|
<FormControl >
|
||||||
|
<FormControl.Label>Placa</FormControl.Label>
|
||||||
|
<TextInput style={styles.input} type="text" onChangeText={onHandleChange("number_plate")} />
|
||||||
|
</FormControl>
|
||||||
|
<FormControl >
|
||||||
|
<FormControl.Label>Tipo de invitado</FormControl.Label>
|
||||||
|
|
||||||
|
<Select onChangeText={onHandleChange("type_guest")} selectedValue={categoria} minWidth="200" accessibilityLabel="Choose Service" placeholder="Elija el tipo de invitado" _selectedItem={{
|
||||||
|
bg: "teal.600"
|
||||||
|
}} mt={1} onValueChange={onHandleChange("type_guest")}>
|
||||||
|
<Select.Item label="Invitado Frecuente" value="Frecuente" />
|
||||||
|
<Select.Item label="Invitado de acceso rápido" value="Rapido" />
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<Button mt="2" backgroundColor='tertiary.600' onPress={() => saveInvitado()}>
|
<Button mt="2" backgroundColor='tertiary.600' onPress={() => saveInvitado()}>
|
||||||
Guardar
|
Guardar
|
||||||
|
@ -108,7 +177,7 @@ export default function AgregarInvitados({ navigation }) {
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
input: {
|
input: {
|
||||||
height: 10,
|
height: 35,
|
||||||
margin: 3,
|
margin: 3,
|
||||||
borderWidth: 0.5,
|
borderWidth: 0.5,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
|
@ -120,6 +189,19 @@ const styles = StyleSheet.create({
|
||||||
marginTop: 6,
|
marginTop: 6,
|
||||||
marginBottom: 6,
|
marginBottom: 6,
|
||||||
borderRadius: 4
|
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'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,21 @@ import { UserContext } from "../context/UserContext";
|
||||||
import { API } from "../environment/api";
|
import { API } from "../environment/api";
|
||||||
import {TimePicker} from 'react-native-simple-time-picker';
|
import {TimePicker} from 'react-native-simple-time-picker';
|
||||||
import { View, StyleSheet } from "react-native";
|
import { View, StyleSheet } from "react-native";
|
||||||
|
import { number } from "prop-types";
|
||||||
|
import DateTimePicker from '@react-native-community/datetimepicker';
|
||||||
export default function AreaComun({navigation}){
|
export default function AreaComun({navigation}){
|
||||||
|
|
||||||
const { user } = useContext(UserContext)
|
const { user } = useContext(UserContext)
|
||||||
const [service, setService] = useState("");
|
const [service, setService] = useState("");
|
||||||
const [areas, setAreas] = useState([])
|
const [areas, setAreas] = useState([])
|
||||||
const [isRequesting, setIsRequesting] = useState(false);
|
const [isRequesting, setIsRequesting] = useState(false);
|
||||||
|
const [time, setTime] = useState(new Date())
|
||||||
|
const idComunidad = user.community_id
|
||||||
|
const date = new Date();
|
||||||
|
const [mode, setMode] = useState('time');
|
||||||
|
|
||||||
const [selectedHours, setSelectedHours] = useState(0);
|
const [startDate, setStartDate] = useState();
|
||||||
const [selectedMinutes, setSelectedMinutes] = useState(0);
|
const [startTime, setStartTime] = useState()
|
||||||
|
|
||||||
const [endSelectedHours, setEndSelectedHours] = useState(0);
|
|
||||||
const [endSelectedMinutes, setEndSelectedMinutes] = useState(0);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
|
@ -33,7 +36,7 @@ export default function AreaComun({navigation}){
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/allCommonAreas`, {
|
const jsonResponse = await fetch(`${API.BASE_URL}/commonArea/findByCommunity/` + `${idComunidad}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
@ -41,7 +44,7 @@ export default function AreaComun({navigation}){
|
||||||
})
|
})
|
||||||
|
|
||||||
const response = await jsonResponse.json();
|
const response = await jsonResponse.json();
|
||||||
console.log(response.message);
|
// console.log(response.message);
|
||||||
|
|
||||||
setAreas(response.message);
|
setAreas(response.message);
|
||||||
|
|
||||||
|
@ -62,38 +65,58 @@ export default function AreaComun({navigation}){
|
||||||
|
|
||||||
const postReserva = async() => {
|
const postReserva = async() => {
|
||||||
|
|
||||||
|
// console.log(startDate.split('"')[1]);
|
||||||
|
// console.log(startTime.split('.')[0]);
|
||||||
|
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
|
||||||
"start_time": selectedHours + ":" +selectedMinutes,
|
"time": startTime.split('.')[0],
|
||||||
"finish_time": endSelectedHours + ":" +endSelectedMinutes,
|
"date": startDate.split('"')[1],
|
||||||
"date_entry": "",
|
|
||||||
"user_id" : user._id,
|
"user_id" : user._id,
|
||||||
"common_area_id": service
|
"common_area_id": service._id,
|
||||||
|
"common_area_name": service.name,
|
||||||
|
"community_id": service.community_id
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// try {
|
try {
|
||||||
|
|
||||||
// const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, {
|
const jsonDataResponse = await fetch(`${API.BASE_URL}/reservation/createReservation`, {
|
||||||
// cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
// method: 'POST',
|
method: 'POST',
|
||||||
// body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
// headers: {
|
headers: {
|
||||||
// 'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
|
|
||||||
// const response = await jsonResponse.json();
|
const response = await jsonDataResponse.json();
|
||||||
// console.log(response.message);
|
console.log(response.message);
|
||||||
|
|
||||||
// } catch (error) {
|
} catch (error) {
|
||||||
// console.log("ERROR:" + error);
|
console.log("ERROR:" + error);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const onChangeStart = (event, selectedDate) => {
|
||||||
|
|
||||||
|
// console.log(selectedDate);
|
||||||
|
|
||||||
|
const dateString = JSON.stringify(selectedDate).toString().split("T")
|
||||||
|
|
||||||
|
setStartDate(dateString[0])
|
||||||
|
setStartTime(dateString[1])
|
||||||
|
|
||||||
|
console.log(dateString);
|
||||||
|
|
||||||
|
// console.log(Date.toString(selectedDate));
|
||||||
|
const currentDate = selectedDate || time;
|
||||||
|
|
||||||
|
setTime(currentDate);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Center>
|
<Center>
|
||||||
|
@ -118,7 +141,7 @@ export default function AreaComun({navigation}){
|
||||||
}} mt={1} onValueChange={itemValue => setService(itemValue)}>
|
}} mt={1} onValueChange={itemValue => setService(itemValue)}>
|
||||||
|
|
||||||
{areas.map(item => (
|
{areas.map(item => (
|
||||||
<Select.Item label={item.name} value={item.community_id} />
|
<Select.Item key={item._id} label={item.name} value={item} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
</Select>
|
</Select>
|
||||||
|
@ -126,36 +149,15 @@ export default function AreaComun({navigation}){
|
||||||
<FormControl isRequired>
|
<FormControl isRequired>
|
||||||
<FormControl.Label>Hora de inicio</FormControl.Label>
|
<FormControl.Label>Hora de inicio</FormControl.Label>
|
||||||
<View >
|
<View >
|
||||||
<TimePicker
|
<DateTimePicker minimumDate={date} mode="datetime" is24Hour value={time} onChange={onChangeStart}/>
|
||||||
selectedHours={selectedHours}
|
|
||||||
selectedMinutes={selectedMinutes}
|
|
||||||
onChange={(hours, minutes) => {
|
|
||||||
setSelectedHours(hours);
|
|
||||||
setSelectedMinutes(minutes);
|
|
||||||
}}/>
|
|
||||||
</View>
|
</View>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl isRequired>
|
|
||||||
<FormControl.Label>Hora de finalización</FormControl.Label>
|
|
||||||
<View >
|
|
||||||
<TimePicker
|
|
||||||
selectedHours={selectedHours}
|
|
||||||
//initial Hourse value
|
|
||||||
selectedMinutes={selectedMinutes}
|
|
||||||
//initial Minutes value
|
|
||||||
onChange={(hours, minutes) => {
|
|
||||||
setEndSelectedHours(hours);
|
|
||||||
setEndSelectedMinutes(minutes);
|
|
||||||
}}/>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
|
|
||||||
<Button mt="2" backgroundColor="tertiary.600" onPress={()=> postReserva()}>
|
<Button mt="10" backgroundColor="tertiary.600" onPress={()=> postReserva()}>
|
||||||
Reservar
|
Reservar
|
||||||
</Button>
|
</Button>
|
||||||
<Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Comunicados')}>
|
<Button mt="3" colorScheme="error" onPress={() => navigation.navigate('Mis Reservas')}>
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
</VStack>
|
</VStack>
|
||||||
|
|
|
@ -8,8 +8,8 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const CommentCard = ({ date, comment }) => {
|
export const CommentCard = ({ post }) => {
|
||||||
const dateFormated = format(new Date(date), "dd LL yyyy")
|
//const dateFormated = format(new Date(date), "dd LL yyyy")
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
rounded="8"
|
rounded="8"
|
||||||
|
@ -31,14 +31,14 @@ export const CommentCard = ({ date, comment }) => {
|
||||||
</Badge>
|
</Badge>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Text fontSize={10} color="coolGray.800">
|
<Text fontSize={10} color="coolGray.800">
|
||||||
{dateFormated}
|
|
||||||
</Text>
|
</Text>
|
||||||
</HStack>
|
</HStack>
|
||||||
<Text color="coolGray.800" mt="3" fontWeight="medium" fontSize="xl">
|
<Text color="coolGray.800" mt="3" fontWeight="medium" fontSize="xl">
|
||||||
Administrador de Comunidad
|
Administrador de Comunidad
|
||||||
</Text>
|
</Text>
|
||||||
<Text mt="2" fontSize="sm" color="coolGray.700">
|
<Text mt="2" fontSize="sm" color="coolGray.700">
|
||||||
{comment}
|
{post}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
@ -46,6 +46,6 @@ export const CommentCard = ({ date, comment }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentCard.propTypes = {
|
CommentCard.propTypes = {
|
||||||
date: PropTypes.string.isRequired,
|
// date: PropTypes.string.isRequired,
|
||||||
comment: PropTypes.string.isRequired,
|
post: PropTypes.string.isRequired,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,10 @@ export default function Home() {
|
||||||
const { user } = useContext(UserContext)
|
const { user } = useContext(UserContext)
|
||||||
const [isRequesting, setIsRequesting] = useState(false);
|
const [isRequesting, setIsRequesting] = useState(false);
|
||||||
const [comments, setComments] = useState([]);
|
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(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
console.log(user);
|
console.log(user);
|
||||||
|
@ -17,17 +20,27 @@ export default function Home() {
|
||||||
setIsRequesting(true);
|
setIsRequesting(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonResponse = await fetch(`${API.BASE_URL}/post/allComments`, {
|
if(user_type=="4"){
|
||||||
method: "GET",
|
const jsonResponse = await fetch(`${API.BASE_URL}/post/findPostCommunity/`+`${community_id}`, {
|
||||||
headers: {
|
method: "GET",
|
||||||
'Content-Type': 'application/json'
|
headers: {
|
||||||
}
|
'Content-Type': 'application/json'
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
const response = await jsonResponse.json();
|
||||||
|
setComments(response.message);
|
||||||
|
|
||||||
const response = await jsonResponse.json();
|
}else{
|
||||||
// console.log(response);
|
const jsonResponse = await fetch(`${API.BASE_URL}/post/allPosts`, {
|
||||||
|
method: "GET",
|
||||||
setComments(response.message);
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await jsonResponse.json();
|
||||||
|
setComments(response.message);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
|
@ -55,8 +68,8 @@ export default function Home() {
|
||||||
comments.map(item => (
|
comments.map(item => (
|
||||||
<CommentCard
|
<CommentCard
|
||||||
key={item._id}
|
key={item._id}
|
||||||
comment={item.comment}
|
post={item.post}
|
||||||
date={item.date_entry}
|
//date={date}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,22 @@ import { UserContext } from "../context/UserContext";
|
||||||
import { API } from "../environment/api";
|
import { API } from "../environment/api";
|
||||||
import {
|
import {
|
||||||
Box, Button,
|
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";
|
} from "native-base";
|
||||||
|
|
||||||
export default function Invitados({navigation}) {
|
export default function Invitados({navigation}) {
|
||||||
|
|
||||||
|
|
||||||
const [isRequesting, setIsRequesting] = useState(false);
|
const [isRequesting, setIsRequesting] = useState(false);
|
||||||
const [invitados, setInvitados] = useState([]);
|
const [invitados, setInvitados] = useState([]);
|
||||||
const { user } = useContext(UserContext);
|
const { user } = useContext(UserContext);
|
||||||
const id = user._id;
|
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(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
|
@ -20,17 +27,27 @@ export default function Invitados({navigation}) {
|
||||||
setIsRequesting(true);
|
setIsRequesting(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestUser/`+`${id}`, {
|
if(user_type=="4"){
|
||||||
method: "GET",
|
const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestCommunity/`+`${community_id}`, {
|
||||||
headers: {
|
method: "GET",
|
||||||
'Content-Type': 'application/json'
|
headers: {
|
||||||
}
|
'Content-Type': 'application/json'
|
||||||
})
|
}
|
||||||
|
})
|
||||||
const response = await jsonResponse.json();
|
|
||||||
//console.log(response);
|
const response = await jsonResponse.json();
|
||||||
setInvitados(response.message);
|
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) {
|
} 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 (
|
return (
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<Heading fontSize="xl" p="4" pb="3">
|
<Heading fontSize="xl" p="4" pb="3">
|
||||||
Lista de invitados
|
Lista de invitados
|
||||||
</Heading>
|
</Heading>
|
||||||
|
<Button width='200' mb="4" mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('Agregar Invitado')} icon={<Icon mb="0.5" as={<MaterialCommunityIcons name={'plus'} />} color="white" size="sm" />}>
|
||||||
|
Agregar invitado
|
||||||
|
</Button>
|
||||||
<FlatList data={invitados} renderItem={({
|
<FlatList data={invitados} renderItem={({
|
||||||
item
|
item
|
||||||
}) => <Box key={item._id} borderBottomWidth="1" _dark={{
|
}) => <Box key={item._id} borderBottomWidth="1" _dark={{
|
||||||
|
@ -64,28 +112,29 @@ export default function Invitados({navigation}) {
|
||||||
<Text color="coolGray.600" _dark={{
|
<Text color="coolGray.600" _dark={{
|
||||||
color: "warmGray.200"
|
color: "warmGray.200"
|
||||||
}}>
|
}}>
|
||||||
{item.dni}
|
{"Identificación: "+item.dni}
|
||||||
</Text>
|
</Text>
|
||||||
<Text color="coolGray.600" _dark={{
|
<Text color="coolGray.600" _dark={{
|
||||||
color: "warmGray.200"
|
color: "warmGray.200"
|
||||||
}}>
|
}}>
|
||||||
{item.phone}
|
{"Teléfono: "+item.phone}
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text color="coolGray.600" _dark={{
|
||||||
|
color: "warmGray.200"
|
||||||
|
}}>
|
||||||
|
{"Número Placa: "+item.number_plate}
|
||||||
|
</Text>
|
||||||
|
<Text color="coolGray.600" _dark={{
|
||||||
|
color: "warmGray.200"
|
||||||
|
}}>
|
||||||
|
{"Tipo de acceso: "+item.type_guest}
|
||||||
|
</Text>
|
||||||
|
|
||||||
</VStack>
|
</VStack>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Text fontSize="xs" _dark={{
|
{user_type == 3 && <MaterialCommunityIcons name="delete" size={28} color="#7C0808" onPress={() =>{deleteInvitado(item._id)}} />}
|
||||||
color: "warmGray.50"
|
|
||||||
}} color="coolGray.800" alignSelf="flex-start">
|
|
||||||
{item.number_plate}
|
|
||||||
</Text>
|
|
||||||
</HStack>
|
</HStack>
|
||||||
</Box>} keyExtractor={item => item.id} />
|
</Box>} keyExtractor={item => item.id} />
|
||||||
|
|
||||||
|
|
||||||
<Button width='200' mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('invitado')}>
|
|
||||||
Agregar invitado
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ import {
|
||||||
Box,
|
Box,
|
||||||
FormControl,
|
FormControl,
|
||||||
Button,
|
Button,
|
||||||
Image
|
Image,
|
||||||
|
ErrorMessage
|
||||||
} from "native-base";
|
} from "native-base";
|
||||||
import logo from "../assets/logo-katoikia.png";
|
import logo from "../assets/logo-katoikia.png";
|
||||||
import { Entypo } from '@expo/vector-icons';
|
import { Entypo } from '@expo/vector-icons';
|
||||||
|
@ -23,6 +24,7 @@ const baseURL = `${API.BASE_URL}/user/loginUser`;
|
||||||
export default function LogIn({ navigation }) {
|
export default function LogIn({ navigation }) {
|
||||||
|
|
||||||
const { addUser } = useContext(UserContext);
|
const { addUser } = useContext(UserContext);
|
||||||
|
const [errors, setErrors] = useState({});
|
||||||
|
|
||||||
const [credentials, setCredentials] = useState({
|
const [credentials, setCredentials] = useState({
|
||||||
email: "lalo@lalo.com",
|
email: "lalo@lalo.com",
|
||||||
|
@ -31,10 +33,38 @@ export default function LogIn({ navigation }) {
|
||||||
|
|
||||||
const onHandleChange = (name) => (value) => setCredentials(prev => ({ ...prev, [name]: value }))
|
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 iniciarSesion = async () => {
|
||||||
|
|
||||||
|
const error = await validate();
|
||||||
|
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
console.log(baseURL);
|
|
||||||
await fetch(baseURL, {
|
await fetch(baseURL, {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -54,25 +84,38 @@ export default function LogIn({ navigation }) {
|
||||||
|
|
||||||
// inqulino 4 y guarda 3
|
// inqulino 4 y guarda 3
|
||||||
const user = response.message
|
const user = response.message
|
||||||
|
|
||||||
|
if(user !== null){
|
||||||
if(user.user_type == '4'){
|
if(user.user_type == '4'){
|
||||||
addUser(user);
|
addUser(user);
|
||||||
|
|
||||||
navigation.navigate('Comunicados', {user})
|
navigation.navigate('Comunicados', {user})
|
||||||
}else if(user.user_type == '3'){
|
}else if(user.user_type == '3'){
|
||||||
addUser(user);
|
addUser(user);
|
||||||
|
// cambiar por ComunicadosGuarda luego
|
||||||
navigation.navigate('Comunicados', {user})
|
navigation.navigate('Comunicados', {user})
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
setErrors({ ...errors,
|
||||||
|
user: 'Debe ingresar credenciales válidos'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("ERROR: " +error);
|
console.log("ERROR: " +error);
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<Center w="100%">
|
<Center w="100%" flex={1}>
|
||||||
<Box safeArea p="2" py="8" w="90%" maxW="290">
|
<Box safeArea p="2" py="8" w="90%" maxW="290">
|
||||||
|
|
||||||
<Center>
|
<Center>
|
||||||
|
@ -106,55 +149,53 @@ export default function LogIn({ navigation }) {
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<VStack space={3} mt="5">
|
<VStack width="90%" mx="3" maxW="300px" mb={10}>
|
||||||
<FormControl isRequired >
|
<FormControl isRequired isInvalid={'email' in errors}>
|
||||||
<FormControl.Label Text='bold'> Correo Electrónico </FormControl.Label>
|
<FormControl.Label Text='bold'> Correo Electrónico </FormControl.Label>
|
||||||
|
|
||||||
<View style={styles.viewSection}>
|
<View style={styles.viewSection}>
|
||||||
<Entypo name="email" size={20} color="grey" style={styles.iconStyle} />
|
<Entypo name="email" size={20} color="grey" style={styles.iconStyle} />
|
||||||
<TextInput
|
<TextInput
|
||||||
name='email'
|
name='email'
|
||||||
type="text"
|
type="text"
|
||||||
style={styles.input}
|
style={'email' in errors ? styles.errorMessage : styles.input}
|
||||||
value={credentials.email}
|
value={credentials.email}
|
||||||
placeholder='Correo electrónico'
|
placeholder='Correo electrónico'
|
||||||
onChangeText={onHandleChange("email")} />
|
onChangeText={onHandleChange("email")} />
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
|
{'email' in errors && <FormControl.ErrorMessage _text={{
|
||||||
|
fontSize: 'xs'
|
||||||
|
}}>Debe ingresar un correo electrónico</FormControl.ErrorMessage> }
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl isRequired>
|
|
||||||
|
<FormControl isRequired isInvalid={'password' in errors}>
|
||||||
<FormControl.Label Text='bold'> Contraseña </FormControl.Label>
|
<FormControl.Label Text='bold'> Contraseña </FormControl.Label>
|
||||||
<View style={styles.viewSection}>
|
<View style={styles.viewSection}>
|
||||||
<MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" style={styles.iconStyle} />
|
<MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" style={styles.iconStyle} />
|
||||||
<TextInput
|
<TextInput
|
||||||
name='password'
|
name='password'
|
||||||
type="password"
|
type="password"
|
||||||
style={styles.input}
|
style={'password' in errors ? styles.errorMessage : styles.input}
|
||||||
value={credentials.password}
|
value={credentials.password}
|
||||||
placeholder='Contraseña'
|
placeholder='Contraseña'
|
||||||
onChangeText={onHandleChange("password")} />
|
onChangeText={onHandleChange("password")} />
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
<Link
|
{'password' in errors && <FormControl.ErrorMessage _text={{
|
||||||
_text={{
|
fontSize: 'xs'
|
||||||
fontSize: "xs",
|
}}
|
||||||
fontWeight: "500",
|
>Debe ingresar una contraseña</FormControl.ErrorMessage> }
|
||||||
color: "indigo.500",
|
|
||||||
marginTop: "10"
|
|
||||||
}}
|
|
||||||
alignSelf="flex-end"
|
|
||||||
mt="1"
|
|
||||||
onPress={() => navigation.navigate('Password')}
|
|
||||||
|
|
||||||
>
|
|
||||||
|
|
||||||
Recuperar contraseña
|
|
||||||
|
|
||||||
</Link>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<Button mt="2" backgroundColor="#D7A86E" onPress={iniciarSesion}
|
<Button mt="2" backgroundColor="#D7A86E" onPress={iniciarSesion}
|
||||||
>
|
>
|
||||||
<Text>Continuar</Text>
|
<Text>Continuar</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
{/* {'user' in errors && <ErrorMessage _text={{
|
||||||
|
fontSize: 'xs'
|
||||||
|
}}
|
||||||
|
>Debe ingresar credenciales válidos</ErrorMessage> } */}
|
||||||
|
|
||||||
</VStack></View>
|
</VStack></View>
|
||||||
|
|
||||||
|
@ -173,12 +214,23 @@ const styles = StyleSheet.create({
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingTop: 10,
|
paddingTop: 10,
|
||||||
paddingRight: 10,
|
paddingRight: 10,
|
||||||
paddingBottom: 10,
|
|
||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
marginTop: 50,
|
marginTop: 50,
|
||||||
marginBottom: 10,
|
|
||||||
borderRadius: 4
|
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: {
|
iconStyle: {
|
||||||
paddingBottom: 20,
|
paddingBottom: 20,
|
||||||
|
@ -191,11 +243,11 @@ const styles = StyleSheet.create({
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
marginBottom: 50
|
||||||
marginBottom: 28
|
|
||||||
},
|
},
|
||||||
|
|
||||||
container: {
|
container: {
|
||||||
|
marginBottom: 6
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,74 +1,56 @@
|
||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { API } from "../environment/api";
|
import { API } from "../environment/api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Box, Button,
|
Box, Button,
|
||||||
Center, FormControl, Heading, ScrollView, VStack
|
Center, FormControl, Heading, ScrollView, VStack
|
||||||
} from "native-base";
|
} from "native-base";
|
||||||
|
import { StyleSheet, TextInput, useWindowDimensions } from "react-native";
|
||||||
import { StyleSheet, TextInput } from "react-native";
|
|
||||||
import { UserContext } from "../context/UserContext";
|
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 }) {
|
export default function Profile({ navigation }) {
|
||||||
|
|
||||||
const baseURL = `${API.BASE_URL}/user/updateUser/`
|
const baseURL = `${API.BASE_URL}/user/updateUser/`
|
||||||
//const userData = JSON.parse(JSON.stringify(route.params));
|
const [index, setIndex] = useState(0);
|
||||||
const [name, setName] = useState();
|
const layout = useWindowDimensions();
|
||||||
const [apellido, setApellido] =useState();
|
|
||||||
const [email, setEmail] = useState();
|
|
||||||
const [password, setPassword] = useState();
|
|
||||||
|
|
||||||
const userData = useContext(UserContext)
|
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 id = userData.user._id;
|
||||||
|
const decode = userData.Password;
|
||||||
|
const [error, setError] = useState({})
|
||||||
|
|
||||||
console.log(userData.user);
|
console.log(userData.user);
|
||||||
|
|
||||||
|
const onHandleChangePassword = (value) => {
|
||||||
|
//console.log(value);
|
||||||
|
const dpassword = stringMd5(value)
|
||||||
|
console.log(dpassword);
|
||||||
|
|
||||||
const updateInfo = async() => {
|
|
||||||
|
|
||||||
const data = {
|
console.log(userData.user.password);
|
||||||
"_id": "6301df20dac7dcf76dcecade",
|
if (userData.user.password == dpassword) {
|
||||||
"dni": "1234567890",
|
console.log(true);
|
||||||
"name": name,
|
setError({});
|
||||||
"last_name": apellido,
|
}else{
|
||||||
"email": email,
|
console.log(false);
|
||||||
"phone": 12121212,
|
setError({ ...error,
|
||||||
"password": "827ccb0eea8a706c4c34a16891f84e7b",
|
|
||||||
"user_type": "3",
|
password: 'La contraseña no coincide con la actual'
|
||||||
"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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
<Center>
|
|
||||||
|
|
||||||
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
|
const ProfileView = () => (
|
||||||
|
|
||||||
|
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
|
||||||
px: "20px",
|
px: "20px",
|
||||||
mb: "4",
|
mb: "4",
|
||||||
minW: "72"
|
minW: "72"
|
||||||
|
@ -89,27 +71,22 @@ export default function Profile({ navigation }) {
|
||||||
<FormControl.Label>DNI</FormControl.Label>
|
<FormControl.Label>DNI</FormControl.Label>
|
||||||
<TextInput type="text" defaultValue={userData.user.dni} editable={false} />
|
<TextInput type="text" defaultValue={userData.user.dni} editable={false} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
{/* <FormControl>
|
||||||
<FormControl.Label>Teléfono</FormControl.Label>
|
<FormControl.Label>Teléfono</FormControl.Label>
|
||||||
<TextInput type="text" defaultValue={userData.user.phone} editable={false} />
|
<TextInput type="text" defaultValue={userData.user.phone} editable={false} />
|
||||||
</FormControl>
|
</FormControl> */}
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<FormControl.Label>Nombre</FormControl.Label>
|
<FormControl.Label>Nombre</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text" defaultValue={userData.user.name} onChangeText={(value) => setName(value) }/>
|
<TextInput style={styles.input} type="text" defaultValue={userData.user.name} onChangeText={(value) => setName(value) }/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<FormControl.Label>Apellido</FormControl.Label>
|
<FormControl.Label>Apellido</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text"defaultValue={userData.user.last_name} onChangeText={(value) => setApellido(value) } />
|
<TextInput style={styles.input} type="text" defaultValue={userData.user.last_name} onChangeText={(value) => setApellido(value) } />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<FormControl.Label>Correo electrónico</FormControl.Label>
|
<FormControl.Label>Correo electrónico</FormControl.Label>
|
||||||
<TextInput style={styles.input} type="text" defaultValue={userData.user.email} onChangeText={(value) => setEmail(value) }/>
|
<TextInput style={styles.input} type="text" defaultValue={userData.user.email} onChangeText={(value) => setEmail(value) }/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormControl>
|
|
||||||
<FormControl.Label>Contraseña actual</FormControl.Label>
|
|
||||||
<TextInput style={styles.input} type="password" defaultValue="" onChangeText={(value) => setPassword(value) }/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<Button mt="2" backgroundColor="orange.300" onPress={() => updateInfo()}>
|
<Button mt="2" backgroundColor="orange.300" onPress={() => updateInfo()}>
|
||||||
Actualizar
|
Actualizar
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -120,7 +97,156 @@ export default function Profile({ navigation }) {
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</Center>
|
|
||||||
|
)
|
||||||
|
|
||||||
|
const PasswordView = () => (
|
||||||
|
|
||||||
|
<ScrollView width='100%' h='550' ml='36' _contentContainerStyle={{
|
||||||
|
px: "20px",
|
||||||
|
mb: "4",
|
||||||
|
minW: "72"
|
||||||
|
}}>
|
||||||
|
|
||||||
|
<Box safeArea p="2" w="90%" maxW="290" py="8">
|
||||||
|
<Heading size="lg" color="coolGray.800" _dark={{
|
||||||
|
color: "warmGray.50"
|
||||||
|
}} fontWeight="semibold">
|
||||||
|
Bienvenido {userData.user.name}
|
||||||
|
</Heading>
|
||||||
|
<Heading mt="1" color="coolGray.600" _dark={{
|
||||||
|
color: "warmGray.200"
|
||||||
|
}} fontWeight="medium" size="xs">
|
||||||
|
Modifique sus contraseña
|
||||||
|
</Heading>
|
||||||
|
|
||||||
|
<VStack space={3} mt="5">
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Contraseña actual</FormControl.Label>
|
||||||
|
<TextInput style={'password' in error ? styles.errorMessage : styles.input} type="password" onChangeText={(value) => onHandleChangePassword(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Nueva Contraseña</FormControl.Label>
|
||||||
|
<TextInput editable={!error} style={styles.input} type="password" onChangeText={(value) => setPassword(value) } />
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
|
<FormControl>
|
||||||
|
<FormControl.Label>Confirmar nueva contraseña</FormControl.Label>
|
||||||
|
<TextInput editable={!error} style={styles.input} type="password" onChangeText={(value) => setConfirmPassword(value) }/>
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
|
<Button mt="2" backgroundColor="orange.300" onPress={() => updatePassword()} disabled={error}>
|
||||||
|
Actualizar contraseña
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* {'password' in error && <FormControl.ErrorMessage _text={{
|
||||||
|
fontSize: 'xs'
|
||||||
|
}}>La contraseña no coincide con la actual</FormControl.ErrorMessage> } */}
|
||||||
|
|
||||||
|
</VStack>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
const updatePassword = async() =>{
|
||||||
|
|
||||||
|
const dataPassword = {
|
||||||
|
"_id": userData.user._id,
|
||||||
|
"dni": userData.user.dni,
|
||||||
|
"name": userData.user.name,
|
||||||
|
"last_name": userData.user.last_name,
|
||||||
|
"email": userData.user.email,
|
||||||
|
"phone": userData.user.phone,
|
||||||
|
"password": password,
|
||||||
|
"user_type": userData.user.user_type,
|
||||||
|
"status": userData.user.status,
|
||||||
|
"date_entry": userData.user.date_entry,
|
||||||
|
"community_id": userData.user.community_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
await fetch(baseURL+`${id}`, {
|
||||||
|
|
||||||
|
cache: 'no-cache',
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(dataPassword),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
|
||||||
|
// console.log(baseURL+`${id}`);
|
||||||
|
if (response.status != 201 && response.status != 200){
|
||||||
|
console.log('ocurrio un error ' + response);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log("ERROR: " + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateInfo = async() => {
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
"_id": userData.user._id,
|
||||||
|
"dni": userData.user.dni,
|
||||||
|
"name": name,
|
||||||
|
"last_name": apellido,
|
||||||
|
"email": email,
|
||||||
|
"community_id": userData.user.community_id
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
await fetch(baseURL+`${id}`, {
|
||||||
|
|
||||||
|
cache: 'no-cache',
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
|
//console.log(baseURL+`${id}`);
|
||||||
|
if (response.status != 201){
|
||||||
|
console.log('ocurrio un error ');
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log("ERROR: " + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<Navigator>
|
||||||
|
<Screen name="Datos Personales" component={ProfileView} />
|
||||||
|
<Screen name="Contraseña" component={PasswordView} />
|
||||||
|
|
||||||
|
</Navigator>
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -129,18 +255,29 @@ export default function Profile({ navigation }) {
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
input: {
|
input: {
|
||||||
height: 10,
|
height: 35,
|
||||||
margin: 3,
|
margin: 3,
|
||||||
borderWidth: 0.5,
|
borderWidth: 0.5,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
paddingTop: 9,
|
paddingTop: 9,
|
||||||
paddingRight: 19,
|
paddingRight: 19,
|
||||||
paddingBottom: 20,
|
|
||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
marginTop: 6,
|
marginTop: 6,
|
||||||
marginBottom: 6,
|
|
||||||
borderRadius: 4
|
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'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@ import React, {useContext, useEffect, useState} from "react";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Fab,
|
Text,
|
||||||
Icon
|
Icon,
|
||||||
|
Button,
|
||||||
|
Heading
|
||||||
} from "native-base";
|
} from "native-base";
|
||||||
import { API } from "../environment/api";
|
import { API } from "../environment/api";
|
||||||
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
||||||
|
@ -16,14 +18,20 @@ export default function Reservas({navigation}) {
|
||||||
const { user } = useContext(UserContext)
|
const { user } = useContext(UserContext)
|
||||||
const [isRequesting, setIsRequesting] = useState(false);
|
const [isRequesting, setIsRequesting] = useState(false);
|
||||||
const [reservas, setReservas] = useState([]);
|
const [reservas, setReservas] = useState([]);
|
||||||
|
const id = user._id;
|
||||||
|
// const id = "6301df20dac7dcf76dcecade";
|
||||||
|
|
||||||
|
console.log(user);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
const onRequestReservasData = async () => {
|
const onRequestReservasData = async () => {
|
||||||
setIsRequesting(true);
|
setIsRequesting(true);
|
||||||
|
|
||||||
|
console.log(user);
|
||||||
try {
|
try {
|
||||||
const jsonResponse = await fetch(`${API.BASE_URL}/reservation/allReservations`, {
|
const jsonResponse = await fetch(`${API.BASE_URL}/reservation/findReservationUser/`+`${id}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
@ -35,12 +43,6 @@ export default function Reservas({navigation}) {
|
||||||
|
|
||||||
setReservas(response.message);
|
setReservas(response.message);
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log("ERROR:" + error);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("ERROR:" + error);
|
console.log("ERROR:" + error);
|
||||||
|
@ -53,34 +55,35 @@ export default function Reservas({navigation}) {
|
||||||
|
|
||||||
}, [user])
|
}, [user])
|
||||||
|
|
||||||
|
console.log(reservas);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
<Box>
|
||||||
|
<Heading fontSize="xl" p="4" pb="3">
|
||||||
|
Lista de reservas
|
||||||
|
</Heading>
|
||||||
<ScrollView showsVerticalScrollIndicator={false}>
|
<ScrollView showsVerticalScrollIndicator={false}>
|
||||||
|
<Button width='200' mb="4" mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('Reservar')} icon={<Icon mb="0.5" as={<MaterialCommunityIcons name={'plus'} />} color="white" size="sm" />}>
|
||||||
|
Reservar
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{ reservas == [] ? <Text mt="9" ml='10'> No hay reservas relacionados a su usuario</Text> :
|
||||||
|
|
||||||
{
|
|
||||||
reservas.map(item => (
|
reservas.map(item => (
|
||||||
<ReservasCard
|
<ReservasCard
|
||||||
key={item._id}
|
key={item._id}
|
||||||
date={item.date_entry}
|
date={item.date}
|
||||||
startTime={item.start_time}
|
startTime={item.time}
|
||||||
endTime={item.finish_time}
|
|
||||||
status={item.status}
|
status={item.status}
|
||||||
|
name={item.common_area_name}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<Box height="200" w="300" shadow="2" rounded="lg" m='5' ml='9' _dark={{
|
|
||||||
bg: "coolGray.200:alpha.20"
|
|
||||||
}} _light={{
|
|
||||||
bg: "coolGray.200:alpha.20"
|
|
||||||
}}>
|
|
||||||
<Fab renderInPortal={false} shadow={2} size="sm" icon={<Icon mb="0.5" as={<MaterialCommunityIcons name={'plus'} />} color="white" size="sm" />} onPress={() => navigation.navigate('area')}/>
|
|
||||||
</Box>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
);
|
</Box>
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import {
|
import {
|
||||||
Box, HStack,
|
Box,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Text,
|
Text,
|
||||||
Stack,
|
Stack,
|
||||||
|
@ -11,15 +11,14 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const ReservasCard = ({ date, startTime, endTime, status}) => {
|
export const ReservasCard = ({ date, startTime, name}) => {
|
||||||
const dateFormated = format(new Date(date), "dd LL yyyy")
|
|
||||||
|
|
||||||
|
const dateFormated = date.toString().split("T")[0]
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
console.log(dateFormated);
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView showsVerticalScrollIndicator={false}>
|
<ScrollView showsVerticalScrollIndicator={false}>
|
||||||
|
@ -38,39 +37,34 @@ export const ReservasCard = ({ date, startTime, endTime, status}) => {
|
||||||
<Stack p="4" space={3}>
|
<Stack p="4" space={3}>
|
||||||
<Stack space={2}>
|
<Stack space={2}>
|
||||||
|
|
||||||
<Badge backgroundColor={status === 1 ? 'tertiary.500' : 'danger.600'} _text={{
|
|
||||||
color: "white"
|
<Heading size="lg" ml="-1">
|
||||||
}} variant="solid" rounded="4">
|
{name}
|
||||||
<Text bold={true} color='danger.50'> {status === 1 ? 'LIBRE' : 'RESERVADO'}</Text>
|
|
||||||
</Badge>
|
|
||||||
<Heading size="md" ml="-1">
|
|
||||||
Reserva #1
|
|
||||||
</Heading>
|
</Heading>
|
||||||
<Text fontSize="xs" _light={{
|
<Text fontSize="md" _light={{
|
||||||
color: "violet.500"
|
color: "amber.600"
|
||||||
}} _dark={{
|
}} _dark={{
|
||||||
color: "violet.400"
|
color: "violet.400"
|
||||||
}} fontWeight="500" ml="-0.5" mt="-1">
|
}} fontWeight="500" ml="-0.5" mt="-1">
|
||||||
{dateFormated}
|
{dateFormated}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Text fontWeight="400">
|
<Text fontSize="md" fontWeight="400">
|
||||||
Hora de inicio: {startTime}
|
Hora de inicio: {startTime}
|
||||||
</Text>
|
</Text>
|
||||||
<Text fontWeight="400">
|
|
||||||
Hora de finalización: {endTime}
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
ReservasCard.propTypes = {
|
// ReservasCard.propTypes = {
|
||||||
date: PropTypes.string.isRequired,
|
// date: PropTypes.string.isRequired,
|
||||||
startTime: PropTypes.string.isRequired,
|
// startTime: PropTypes.string.isRequired,
|
||||||
endTime: PropTypes.string.isRequired,
|
// status: PropTypes.string.isRequired
|
||||||
status: PropTypes.string.isRequired
|
// }
|
||||||
}
|
|
|
@ -14,11 +14,14 @@
|
||||||
"android": "expo start --android",
|
"android": "expo start --android",
|
||||||
"ios": "expo start --ios",
|
"ios": "expo start --ios",
|
||||||
"web": "expo start --web",
|
"web": "expo start --web",
|
||||||
"eject": "expo eject"
|
"eject": "expo eject",
|
||||||
|
"test" : "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@react-native-community/datetimepicker": "4.0.0",
|
||||||
"@react-native-community/masked-view": "^0.1.11",
|
"@react-native-community/masked-view": "^0.1.11",
|
||||||
"@react-navigation/bottom-tabs": "^6.3.2",
|
"@react-navigation/bottom-tabs": "^6.3.2",
|
||||||
|
"@react-navigation/material-top-tabs": "^6.2.3",
|
||||||
"@react-navigation/native": "^6.0.11",
|
"@react-navigation/native": "^6.0.11",
|
||||||
"@react-navigation/native-stack": "^6.7.0",
|
"@react-navigation/native-stack": "^6.7.0",
|
||||||
"@react-navigation/stack": "^6.2.2",
|
"@react-navigation/stack": "^6.2.2",
|
||||||
|
@ -31,17 +34,21 @@
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
"react-native": "0.64.3",
|
"react-native": "0.64.3",
|
||||||
"react-native-gesture-handler": "~2.1.0",
|
"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-reanimated": "~2.3.1",
|
||||||
"react-native-safe-area-context": "3.3.2",
|
"react-native-safe-area-context": "3.3.2",
|
||||||
"react-native-screens": "~3.10.1",
|
"react-native-screens": "~3.10.1",
|
||||||
"react-native-simple-time-picker": "^1.3.11",
|
"react-native-simple-time-picker": "^1.3.11",
|
||||||
"react-native-svg": "12.1.1",
|
"react-native-svg": "12.1.1",
|
||||||
|
"react-native-tab-view": "^3.1.1",
|
||||||
"react-native-table-component": "^1.2.2",
|
"react-native-table-component": "^1.2.2",
|
||||||
"react-native-web": "0.17.1",
|
"react-native-web": "0.17.1",
|
||||||
"universal-cookie": "^4.0.4"
|
"universal-cookie": "^4.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.12.9"
|
"@babel/core": "^7.12.9",
|
||||||
|
"jest": "^29.0.1"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/GeekyAnts/nativebase-templates/issues"
|
"url": "https://github.com/GeekyAnts/nativebase-templates/issues"
|
||||||
|
|
|
@ -33,4 +33,10 @@ export class PostCommentsController {
|
||||||
let _id = id['id'];
|
let _id = id['id'];
|
||||||
return this.postCommentsService.remove(_id);
|
return this.postCommentsService.remove(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'findCommentCommunity' })
|
||||||
|
findPostCommunity(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.postCommentsService.findPostCommunity(_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,4 +37,9 @@ export class PostCommentsService {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findPostCommunity(id: string): Promise<Comment[]> {
|
||||||
|
console.log(id);
|
||||||
|
return this.commentModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,4 +33,9 @@ export class PostsController {
|
||||||
let _id = id['id'];
|
let _id = id['id'];
|
||||||
return this.postsService.remove(_id);
|
return this.postsService.remove(_id);
|
||||||
}
|
}
|
||||||
|
@MessagePattern({ cmd: 'findPostCommunity' })
|
||||||
|
findPostCommunity(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.postsService.findPostCommunity(_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,9 @@ export class PostsService {
|
||||||
async remove(id: string) {
|
async remove(id: string) {
|
||||||
return this.postModel.findByIdAndRemove({ _id: id }).exec();
|
return this.postModel.findByIdAndRemove({ _id: id }).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findPostCommunity(id: string): Promise<Post[]> {
|
||||||
|
console.log(id);
|
||||||
|
return this.postModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "servicio-invitados",
|
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -20,6 +20,11 @@ export class GuestsController {
|
||||||
findGuestUser(@Payload() id: string) {
|
findGuestUser(@Payload() id: string) {
|
||||||
return this.guestsService.findGuestUser(id);
|
return this.guestsService.findGuestUser(id);
|
||||||
}
|
}
|
||||||
|
@MessagePattern({ cmd: 'findGuestCommunity' })
|
||||||
|
findGuestCommunity(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.guestsService.findGuestCommunity(_id);
|
||||||
|
}
|
||||||
@MessagePattern({ cmd: 'findOneGuest' })
|
@MessagePattern({ cmd: 'findOneGuest' })
|
||||||
findOneById(@Payload() id: string) {
|
findOneById(@Payload() id: string) {
|
||||||
let _id = id['_id'];
|
let _id = id['_id'];
|
||||||
|
@ -39,7 +44,7 @@ export class GuestsController {
|
||||||
|
|
||||||
@MessagePattern({ cmd: 'removeGuest' })
|
@MessagePattern({ cmd: 'removeGuest' })
|
||||||
remove(@Payload() id: string) {
|
remove(@Payload() id: string) {
|
||||||
let dni = id['dni'];
|
let dni = id['_id'];
|
||||||
return this.guestsService.remove(dni);
|
return this.guestsService.remove(dni);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,12 @@ export class GuestsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findGuestUser(id: string): Promise<Guest[]> {
|
async findGuestUser(id: string): Promise<Guest[]> {
|
||||||
return this.guestModel.find({_tenant_id:id}).setOptions({ sanitizeFilter: true }).exec();
|
return this.guestModel.find({_tenant_id:id, status:"1"}).setOptions({ sanitizeFilter: true }).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findGuestCommunity(id: string): Promise<Guest[]> {
|
||||||
|
console.log(id);
|
||||||
|
return this.guestModel.find({community_id:id}).setOptions({ sanitizeFilter: true }).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
findOneId(id: string): Promise<Guest> {
|
findOneId(id: string): Promise<Guest> {
|
||||||
|
|
|
@ -32,6 +32,9 @@ export class Guest {
|
||||||
@Prop()
|
@Prop()
|
||||||
community_id: string; ///creo que se debe de agregar para facilitar al guarda ver
|
community_id: string; ///creo que se debe de agregar para facilitar al guarda ver
|
||||||
// ver los invitados de x comunidad
|
// ver los invitados de x comunidad
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
type_guest: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GuestSchema = SchemaFactory.createForClass(Guest);
|
export const GuestSchema = SchemaFactory.createForClass(Guest);
|
||||||
|
|
|
@ -50,4 +50,11 @@ export class ReservationsController {
|
||||||
let community_id = reservation['community_id'];
|
let community_id = reservation['community_id'];
|
||||||
return this.reservationsService.removeIdCommunity(community_id);
|
return this.reservationsService.removeIdCommunity(community_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'findReservationUser' })
|
||||||
|
findReservationUser(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.reservationsService.findReservationUser(_id);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,9 @@ export class ReservationsService {
|
||||||
async findReservationsByCommunity(community_id: string){
|
async findReservationsByCommunity(community_id: string){
|
||||||
return this.reservationModel.find({ community_id: community_id }).exec();
|
return this.reservationModel.find({ community_id: community_id }).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findReservationUser(id: string): Promise<Reservation[]> {
|
||||||
|
return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "servicio-usuarios",
|
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
Loading…
Reference in New Issue