Merge branch 'dev' of github.com:DeimosPr4/katoikia-app into 51-us-54-ver-información-inquilino

This commit is contained in:
Eduardo Quiros 2022-08-21 08:54:16 -06:00
commit cf2fbfcd9c
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
25 changed files with 1344 additions and 342 deletions

View File

@ -155,6 +155,16 @@ export class AppController {
return this.appService.deleteAdminSystem(id); return this.appService.deleteAdminSystem(id);
} }
@Delete('user/deleteAdminCommunity/:id')
deleteAdminCommunity(@Param('id') id: string) {
return this.appService.deleteAdminCommunity(id);
}
@Delete('user/deleteTenant/:id')
deleteTenant(@Param('id') id: string) {
return this.appService.deleteTenant(id);
}
@Post('user/changeStatus') @Post('user/changeStatus')
changeStatusUser( changeStatusUser(
@Body('id') pId: string, @Body('id') pId: string,
@ -215,6 +225,8 @@ export class AppController {
) { ) {
return this.appService.changeStatusCommunity(pId, pStatus); return this.appService.changeStatusCommunity(pId, pStatus);
} }
// #==== API Common Areas // #==== API Common Areas
@Post('commonArea/createCommonArea') @Post('commonArea/createCommonArea')
createCommonArea( createCommonArea(
@ -254,6 +266,14 @@ export class AppController {
return this.appService.deleteCommonArea(id); return this.appService.deleteCommonArea(id);
} }
@Post('commonArea/changeStatus')
changeStatusCommonArea(
@Body('id') pId: string,
@Body('status') pStatus: string,
) {
return this.appService.changeStatusCommonArea(pId, pStatus);
}
// #==== API GUEST // #==== API GUEST
//#API userService - create user //#API userService - create user
@Post('guest/createGuest') @Post('guest/createGuest')

View File

@ -193,6 +193,22 @@ export class AppService {
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
deleteAdminCommunity(id: string) {
const pattern = { cmd: 'deleteAdminCommunity' };
const payload = { id: id };
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
deleteTenant(id: string) {
const pattern = { cmd: 'deleteTenant' };
const payload = { id: id };
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
inicioSesion(pEmail: string, pPassword: string) { inicioSesion(pEmail: string, pPassword: string) {
const pattern = { cmd: 'loginUser' }; const pattern = { cmd: 'loginUser' };
const payload = { email: pEmail, password: pPassword }; const payload = { email: pEmail, password: pPassword };
@ -343,6 +359,15 @@ export class AppService {
.pipe(map((message: string) => ({ message }))); .pipe(map((message: string) => ({ message })));
} }
changeStatusCommonArea(pId: string, pStatus: string) {
const pattern = { cmd: 'changeStatus' };
const payload = { id: pId, status: pStatus };
return this.clientCommonAreaApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
// ====================== GUESTS =============================== // ====================== GUESTS ===============================
//POST parameter from API //POST parameter from API

View File

@ -1,27 +1,60 @@
import React from "react"; import React,{useState} from "react";
import { import {
NativeBaseProvider NativeBaseProvider,
Icon
} from "native-base"; } from "native-base";
import { NavigationContainer } from '@react-navigation/native'; import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import LogIn from "./components/LogIn"; import LogIn from "./components/LogIn";
import Home from "./components/Home"; import Home from "./components/Home";
import RecoverPassword from "./components/RecoverPassword"; import RecoverPassword from "./components/RecoverPassword";
import Reservas from "./components/Reservas";
import Profile from "./components/Profile";
import { MaterialCommunityIcons } from '@expo/vector-icons';
import AreaComun from "./components/AreaComun";
const Stack = createNativeStackNavigator(); const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
function HomeTab() {
const [selected, setSelected] = useState(0);
return (
<Tab.Navigator initialRouteName="Comunicados" >
<Tab.Screen name="Comunicados" component={Home} options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="#D7A86E" size="md" />)}} onclick={() => setSelected(0)} />
<Tab.Screen name="Reservas" component={Reservas } options={{headerStyle: {
backgroundColor: "#D7A86E"
}, tabBarIcon: () => (<Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="#D7A86E" size="md" />)} } onclick={() => setSelected(1)} />
<Tab.Screen name="Perfil" component={Profile} 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>
<NavigationContainer> <NavigationContainer>
<Stack.Navigator initialRouteName="LogIn"> <Stack.Navigator initialRouteName="LogIn">
<Stack.Screen name="Inicio" component={LogIn} /> <Stack.Screen name="Inicio" component={LogIn} options={{headerStyle: {
<Stack.Screen name="Home" component={Home} /> backgroundColor: "#D7A86E"
<Stack.Screen name="Password" component={RecoverPassword} /> }}} />
<Stack.Screen name="Comunicados" component={HomeTab} options={{headerShown: false}} />
<Stack.Screen name="Password" component={RecoverPassword} />
<Stack.Screen name="area" component={AreaComun} options={{headerStyle: {
backgroundColor: "#D7A86E"
}}} />
</Stack.Navigator> </Stack.Navigator>
</NavigationContainer>
</NavigationContainer>
</NativeBaseProvider> </NativeBaseProvider>
); );
} }

View File

@ -0,0 +1,53 @@
import React from "react";
import {
Box,
Heading,
VStack,
FormControl,
Input,
Button,
Center
} from "native-base";
export default function AreaComun({navigation}){
return (
<Center>
<Box safeArea p="2" w="90%" maxW="290" py="8">
<Heading size="lg" color="coolGray.800" _dark={{
color: "warmGray.50"
}} fontWeight="semibold">
Katoikia
</Heading>
<Heading mt="1" color="coolGray.600" _dark={{
color: "warmGray.200"
}} fontWeight="medium" size="xs">
Reserve su área común
</Heading>
<VStack space={3} mt="5">
<FormControl>
<FormControl.Label>Hora de inicio</FormControl.Label>
<Input type="text"/>
</FormControl>
<FormControl>
<FormControl.Label>Hora de finalización</FormControl.Label>
<Input type="text" />
</FormControl>
<FormControl>
<FormControl.Label>Lugar</FormControl.Label>
<Input type="text" />
</FormControl>
<Button mt="2" backgroundColor="orange.300">
Reservar
</Button>
<Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Comunicados')}>
Cancelar
</Button>
</VStack>
</Box>
</Center>
)
}

View File

@ -2,34 +2,100 @@ import React from "react";
import { import {
Text, Text,
HStack, HStack,
IconButton, Badge,
Box, Box,
StatusBar, Pressable,
Icon, Spacer,
MaterialIcons,
Center
} from "native-base"; } from "native-base";
import { MaterialCommunityIcons } from '@expo/vector-icons';
export default function Home(){ export default function Home(){
const [selected, setSelected] = React.useState(0);
return ( return (
<Center width={"100%"} marginTop={"auto"}>
<StatusBar bg="#D7A86E" barStyle="light-content" /> <Box alignItems="center">
<Box safeAreaTop bg="#D7A86E" /> <Pressable onPress={() => console.log("I'm Pressed")} rounded="8" overflow="hidden" borderWidth="1" borderColor="coolGray.300" maxW="96" shadow="3" bg="coolGray.100" p="5" marginTop="4">
<HStack bg="#D7A86E" px="2" py="4" justifyContent="space-between" alignItems="center" w="100%" maxW="100%"> <Box>
<HStack alignItems="center"> <HStack alignItems="center">
<IconButton icon={<Icon size="sm" as={MaterialIcons} name="menu" color="white" />} /> <Badge colorScheme="darkBlue" _text={{
<Text color="white" fontSize="20" fontWeight="bold"> color: "white"
Home }} variant="solid" rounded="4">
Comunicado
</Badge>
<Spacer />
<Text fontSize={10} color="coolGray.800">
1 month ago
</Text>
</HStack>
<Text color="coolGray.800" mt="3" fontWeight="medium" fontSize="xl">
Administrador de Comunidad
</Text> </Text>
</HStack> <Text mt="2" fontSize="sm" color="coolGray.700">
<HStack> Notificacion sobre la aplicacion
<IconButton icon={<Icon as={MaterialIcons} name="favorite" size="sm" color="white" />} /> </Text>
<IconButton icon={<Icon as={MaterialIcons} name="search" size="sm" color="white" />} />
<IconButton icon={<Icon as={MaterialIcons} name="more-vert" size="sm" color="white" />} /> </Box>
</HStack> </Pressable>
</HStack> <Pressable onPress={() => console.log("I'm Pressed")} rounded="8" overflow="hidden" borderWidth="1" borderColor="coolGray.300" maxW="96" shadow="3" bg="coolGray.100" p="5" marginTop="4">
</Center> <Box>
<HStack alignItems="center">
<Badge colorScheme="darkBlue" _text={{
color: "white"
}} variant="solid" rounded="4">
Comunicado
</Badge>
<Spacer />
<Text fontSize={10} color="coolGray.800">
1 month ago
</Text>
</HStack>
<Text color="coolGray.800" mt="3" fontWeight="medium" fontSize="xl">
Administrador General
</Text>
<Text mt="2" fontSize="sm" color="coolGray.700">
Notificacion sobre la aplicacion
</Text>
</Box>
</Pressable>
</Box>
// <Center width={"100%"} marginTop={"auto"}>
// <Box safeAreaTop bg="#D7A86E" flex={1} />
// <HStack bg="#D7A86E" px="2" py="4" justifyContent="space-between" alignItems="center" w="100%" maxW="100%">
// <Pressable opacity={selected === 0 ? 1 : 0.5} py="3" flex={1} onPress={() => setSelected(0) && navigation.navigate('Home')}>
// <Center>
// <Icon mb="2" as={<MaterialCommunityIcons name={selected === 0 ? 'home' : 'home-outline'} />} color="white" size="md" />
// <Text color="white" fontSize="15">
// Inicio
// </Text>
// </Center>
// </Pressable>
// <Pressable opacity={selected === 1 ? 1 : 0.5} py="3" flex={1} onPress={() => setSelected(1) && ( () => navigation.navigate('Reservas'))}>
// <Center>
// <Icon mb="2" as={<MaterialCommunityIcons name={selected === 1 ? 'tree' : 'tree-outline'} />} color="white" size="md" />
// <Text color="white" fontSize="15">
// Reservas
// </Text>
// </Center>
// </Pressable>
// <Pressable opacity={selected === 2 ? 1 : 0.5} py="3" flex={1} onPress={() => setSelected(2)}>
// <Center>
// <Icon mb="2" as={<MaterialCommunityIcons name={selected === 2 ? 'account' : 'account-outline'} />} color="white" size="md" />
// <Text color="white" fontSize="15">
// Perfil
// </Text>
// </Center>
// </Pressable>
// </HStack>
// </Center>
) )
} }

View File

@ -1,21 +1,92 @@
import React from "react"; import React from "react";
import Cookies from 'universal-cookie';
import { import {
Text, Text,
Link, Link,
View,
Center, Center,
Heading, Heading,
VStack, VStack,
Box, Box,
FormControl, FormControl,
Input,
Button, Button,
Image, Image
TextInput
} 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';
import { MaterialCommunityIcons } from '@expo/vector-icons'; import { MaterialCommunityIcons } from '@expo/vector-icons';
import { View, TextInput, StyleSheet } from "react-native";
const baseURL = "http://localhost:4000/user/loginUser";
const cookies = new Cookies();
const styles = StyleSheet.create({
input: {
height: 40,
margin: 10,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 0,
marginTop: 50,
marginBottom: 10
},
iconStyle: {
padding: 10,
},
viewSection: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
margin: 10
},
container: {
}
})
const iniciarSesion = async() => {
try {
await fetch(baseURL, {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
if (response.status != 201){
console.log('ocurrio un error ');
}else{
return response.json();
}
})
.then( response => {
const user = response.message
if(user.user_type == '3'){
cookies.set('id',user._id, {path: "/"} )
cookies.set('name',user.name, {path: "/"} )
cookies.set('email',user.email, {path: "/"} )
cookies.set('type',user.user_type, {path: "/"} )
}
})
} catch (error) {
}
}
export default function LogIn({navigation}) { export default function LogIn({navigation}) {
return ( return (
@ -23,11 +94,15 @@ export default function LogIn({navigation}) {
<Center w="100%"> <Center w="100%">
<Box safeArea p="2" py="8" w="90%" maxW="290"> <Box safeArea p="2" py="8" w="90%" maxW="290">
<Image source={
<Center>
<Image source={
logo logo
} width={500} height={550} } width={500} height={550} m='2'
alt="Katoikia logo" size="xl" justifyContent="center" /> alt="Katoikia logo" size="xl" justifyContent="center" />
</Center>
<Heading <Heading
size="lg" size="lg"
fontWeight="600" fontWeight="600"
@ -50,27 +125,29 @@ export default function LogIn({navigation}) {
Su app de comunidad de confianza Su app de comunidad de confianza
</Heading> </Heading>
<VStack space={3} mt="5"> <View style={styles.container}>
<VStack space={3} mt="5">
<FormControl> <FormControl>
<FormControl.Label> Correo Electrónico </FormControl.Label> <FormControl.Label> Correo Electrónico </FormControl.Label>
<View> <View style={styles.viewSection}>
<Entypo name="email" size={20} color="grey" /> <Entypo name="email" size={20} color="grey" style={styles.iconStyle} />
<Input type="text" /> <TextInput type="text" style={styles.input} />
</View> </View>
</FormControl> </FormControl>
<FormControl> <FormControl>
<FormControl.Label> Contraseña </FormControl.Label> <FormControl.Label> Contraseña </FormControl.Label>
<View> <View style={styles.viewSection}>
<MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" /> <MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" style={styles.iconStyle}/>
<Input type="password" /> <TextInput type="password" style={styles.input} />
</View> </View>
<Link <Link
_text={{ _text={{
fontSize: "xs", fontSize: "xs",
fontWeight: "500", fontWeight: "500",
color: "indigo.500", color: "indigo.500",
marginTop: "10"
}} }}
alignSelf="flex-end" alignSelf="flex-end"
mt="1" mt="1"
@ -82,13 +159,17 @@ export default function LogIn({navigation}) {
</Link> </Link>
</FormControl> </FormControl>
<Button mt="2" colorScheme="primary" onPress={() => navigation.navigate('Home')} <Button mt="2" backgroundColor="#D7A86E" onPress={() => navigation.navigate('Comunicados')}
> >
<Text>Continuar</Text> <Text>Continuar</Text>
</Button> </Button>
</VStack> </VStack></View>
</Box> </Box>
</Center> </Center>
); );
} }

View File

@ -0,0 +1,57 @@
import React from "react";
import {
Box,
Heading,
VStack,
FormControl,
Input,
Button,
Center
} from "native-base";
export default function Profile({navigation}){
return (
<Center>
<Box safeArea p="2" w="90%" maxW="290" py="8">
<Heading size="lg" color="coolGray.800" _dark={{
color: "warmGray.50"
}} fontWeight="semibold">
Katoikia
</Heading>
<Heading mt="1" color="coolGray.600" _dark={{
color: "warmGray.200"
}} fontWeight="medium" size="xs">
Modifique sus datos
</Heading>
<VStack space={3} mt="5">
<FormControl>
<FormControl.Label>Nombre</FormControl.Label>
<Input type="text"/>
</FormControl>
<FormControl>
<FormControl.Label>Correo Electrónico</FormControl.Label>
<Input type="text" />
</FormControl>
<FormControl>
<FormControl.Label>Teléfono</FormControl.Label>
<Input type="text" />
</FormControl>
<FormControl>
<FormControl.Label>Contraseña actual</FormControl.Label>
<Input type="password" />
</FormControl>
<Button mt="2" backgroundColor="orange.300">
Actualizar
</Button>
<Button mt="6" colorScheme="error" onPress={() => navigation.navigate('Inicio')}>
Cerrar sesión
</Button>
</VStack>
</Box>
</Center>
)
}

View File

@ -0,0 +1,148 @@
import React from "react";
import {
Text,
HStack,
AntDesign,
Heading,
Stack,
Box,
ScrollView,
Fab,
Icon
} from "native-base";
import logo from "../assets/logo-katoikia.png";
import { Entypo } from '@expo/vector-icons';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { View, TextInput, StyleSheet } from "react-native";
const styles = StyleSheet.create({
input: {
height: 40,
margin: 10,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 0,
marginTop: 50,
marginBottom: 10
},
iconStyle: {
padding: 10,
},
viewSection: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
margin: 10
},
container: {
}
})
export default function Reservas({navigation}) {
return (
<ScrollView showsVerticalScrollIndicator={false}>
<Box alignItems="center">
<Box width="80" rounded="lg" overflow="hidden" borderColor="coolGray.200" borderWidth="1" _dark={{
borderColor: "coolGray.600",
backgroundColor: "gray.700"
}} _web={{
shadow: 2,
borderWidth: 0
}} _light={{
backgroundColor: "gray.50"
}}>
<Stack p="4" space={3}>
<Stack space={2}>
<Heading size="md" ml="-1">
Reserva #1
</Heading>
<Text fontSize="xs" _light={{
color: "violet.500"
}} _dark={{
color: "violet.400"
}} fontWeight="500" ml="-0.5" mt="-1">
horario de Reserva
</Text>
</Stack>
<Text fontWeight="400">
Descripcion
</Text>
<HStack alignItems="center" space={4} justifyContent="space-between">
<HStack alignItems="center">
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}} fontWeight="400">
6 mins ago
</Text>
</HStack>
</HStack>
</Stack>
</Box>
</Box>
<Box alignItems="center" width={"100%"}>
<Box width="80" rounded="lg" overflow="hidden" borderColor="coolGray.200" borderWidth="1" _dark={{
borderColor: "coolGray.600",
backgroundColor: "gray.700"
}} _web={{
shadow: 2,
borderWidth: 0
}} _light={{
backgroundColor: "gray.50"
}}>
<Stack p="4" space={3}>
<Stack space={2}>
<Heading size="md" ml="-1">
Reserva #1
</Heading>
<Text fontSize="xs" _light={{
color: "violet.500"
}} _dark={{
color: "violet.400"
}} fontWeight="500" ml="-0.5" mt="-1">
horario de Reserva
</Text>
</Stack>
<Text fontWeight="400">
Descripcion
</Text>
<HStack alignItems="center" space={4} justifyContent="space-between">
<HStack alignItems="center">
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}} fontWeight="400">
6 mins ago
</Text>
</HStack>
</HStack>
</Stack>
</Box>
</Box>
<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>
);
}

View File

@ -10,6 +10,7 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@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/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",
@ -24,7 +25,8 @@
"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-svg": "12.1.1", "react-native-svg": "12.1.1",
"react-native-web": "0.17.1" "react-native-web": "0.17.1",
"universal-cookie": "^4.0.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9" "@babel/core": "^7.12.9"
@ -3533,6 +3535,23 @@
"resolved": "https://registry.npmjs.org/@react-native/polyfills/-/polyfills-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@react-native/polyfills/-/polyfills-1.0.0.tgz",
"integrity": "sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w==" "integrity": "sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w=="
}, },
"node_modules/@react-navigation/bottom-tabs": {
"version": "6.3.2",
"resolved": "https://registry.npmjs.org/@react-navigation/bottom-tabs/-/bottom-tabs-6.3.2.tgz",
"integrity": "sha512-uS0XV2aH7bAW54Zuf5ks2V60riarbMALyMz3cB3204l4aGhx41UPUIr/K72pGAVdIPizpjz8Fk8qwczAwex9eg==",
"dependencies": {
"@react-navigation/elements": "^1.3.4",
"color": "^4.2.3",
"warn-once": "^0.1.0"
},
"peerDependencies": {
"@react-navigation/native": "^6.0.0",
"react": "*",
"react-native": "*",
"react-native-safe-area-context": ">= 3.0.0",
"react-native-screens": ">= 3.0.0"
}
},
"node_modules/@react-navigation/core": { "node_modules/@react-navigation/core": {
"version": "6.2.2", "version": "6.2.2",
"resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.2.2.tgz", "resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.2.2.tgz",
@ -4077,6 +4096,11 @@
"resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz",
"integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==" "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ=="
}, },
"node_modules/@types/cookie": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
"integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
},
"node_modules/@types/graceful-fs": { "node_modules/@types/graceful-fs": {
"version": "4.1.5", "version": "4.1.5",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz",
@ -5163,6 +5187,14 @@
"safe-buffer": "~5.1.1" "safe-buffer": "~5.1.1"
} }
}, },
"node_modules/cookie": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/copy-descriptor": { "node_modules/copy-descriptor": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
@ -10806,6 +10838,15 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/universal-cookie": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz",
"integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==",
"dependencies": {
"@types/cookie": "^0.3.3",
"cookie": "^0.4.0"
}
},
"node_modules/universalify": { "node_modules/universalify": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",
@ -13852,6 +13893,16 @@
"resolved": "https://registry.npmjs.org/@react-native/polyfills/-/polyfills-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@react-native/polyfills/-/polyfills-1.0.0.tgz",
"integrity": "sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w==" "integrity": "sha512-0jbp4RxjYopTsIdLl+/Fy2TiwVYHy4mgeu07DG4b/LyM0OS/+lPP5c9sbnt/AMlnF6qz2JRZpPpGw1eMNS6A4w=="
}, },
"@react-navigation/bottom-tabs": {
"version": "6.3.2",
"resolved": "https://registry.npmjs.org/@react-navigation/bottom-tabs/-/bottom-tabs-6.3.2.tgz",
"integrity": "sha512-uS0XV2aH7bAW54Zuf5ks2V60riarbMALyMz3cB3204l4aGhx41UPUIr/K72pGAVdIPizpjz8Fk8qwczAwex9eg==",
"requires": {
"@react-navigation/elements": "^1.3.4",
"color": "^4.2.3",
"warn-once": "^0.1.0"
}
},
"@react-navigation/core": { "@react-navigation/core": {
"version": "6.2.2", "version": "6.2.2",
"resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.2.2.tgz", "resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.2.2.tgz",
@ -14265,6 +14316,11 @@
"resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz",
"integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==" "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ=="
}, },
"@types/cookie": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
"integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
},
"@types/graceful-fs": { "@types/graceful-fs": {
"version": "4.1.5", "version": "4.1.5",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz",
@ -15145,6 +15201,11 @@
"safe-buffer": "~5.1.1" "safe-buffer": "~5.1.1"
} }
}, },
"cookie": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA=="
},
"copy-descriptor": { "copy-descriptor": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
@ -19577,6 +19638,15 @@
} }
} }
}, },
"universal-cookie": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz",
"integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==",
"requires": {
"@types/cookie": "^0.3.3",
"cookie": "^0.4.0"
}
},
"universalify": { "universalify": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",

View File

@ -18,6 +18,7 @@
}, },
"dependencies": { "dependencies": {
"@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/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",
@ -32,7 +33,8 @@
"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-svg": "12.1.1", "react-native-svg": "12.1.1",
"react-native-web": "0.17.1" "react-native-web": "0.17.1",
"universal-cookie": "^4.0.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9" "@babel/core": "^7.12.9"

View File

@ -39,4 +39,12 @@ export class CommonAreasController {
let _community_id = id['community_id']; let _community_id = id['community_id'];
return this.commonAreasService.findByCommunity(_community_id); return this.commonAreasService.findByCommunity(_community_id);
} }
//cambiar de estado
@MessagePattern({ cmd: 'changeStatus' })
changeStatus(@Payload() body: string) {
let pid = body['id'];
let pstatus = body['status'];
return this.commonAreasService.changeStatus(pid,pstatus);
}
} }

View File

@ -41,4 +41,10 @@ export class CommonAreasService {
return this.commonAreaModel.find({ community_id: community_id }).exec(); return this.commonAreaModel.find({ community_id: community_id }).exec();
} }
async changeStatus(id: string, status: string) {
return this.commonAreaModel.findOneAndUpdate({ _id: id }, {status: status}, {
new: true,
});
}
} }

View File

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

View File

@ -112,11 +112,18 @@ export class UsersController {
@MessagePattern({ cmd: 'deleteAdminSystem' }) @MessagePattern({ cmd: 'deleteAdminSystem' })
deleteAdminSystem(@Payload() user: any) { deleteAdminSystem(@Payload() user: any) {
console.log('entró');
return this.userService.deleteAdminSystem(user['id']); return this.userService.deleteAdminSystem(user['id']);
} }
@MessagePattern({ cmd: 'deleteAdminCommunity' })
deleteAdminCommunity(@Payload() user: any) {
return this.userService.deleteAdminCommunity(user['id']);
}
@MessagePattern({ cmd: 'deleteTenant' })
deleteTenant(@Payload() user: any) {
return this.userService.deleteTenant(user['id']);
}
@MessagePattern({ cmd: 'changeStatus' }) @MessagePattern({ cmd: 'changeStatus' })
changeStatus(@Payload() body: string) { changeStatus(@Payload() body: string) {

View File

@ -14,8 +14,8 @@ export class UsersService {
@InjectModel(User.name) private readonly userModel: Model<UserDocument>, @InjectModel(User.name) private readonly userModel: Model<UserDocument>,
@Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy, @Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy,
@Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy, @Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy,
) { } ) { }
private publicKey: string; private publicKey: string;
async create(user: UserDocument): Promise<User> { async create(user: UserDocument): Promise<User> {
let passwordEncriptada = Md5.init(user.password); let passwordEncriptada = Md5.init(user.password);
@ -78,12 +78,12 @@ export class UsersService {
}); });
} }
/* async remove(id: string) { /* async remove(id: string) {
return this.userModel.findByIdAndRemove({ _id: id }).exec(); return this.userModel.findByIdAndRemove({ _id: id }).exec();
}*/ }*/
async remove(id: string) { async remove(id: string) {
return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, { return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
new: true, new: true,
}); });
} }
@ -99,8 +99,12 @@ export class UsersService {
reject(err); reject(err);
} else { } else {
let passwordEncriptada = Md5.init(password); let passwordEncriptada = Md5.init(password);
if (res[0].password == passwordEncriptada) { if (res.length > 0) {
resolve(res[0]); if (res[0].password == passwordEncriptada) {
resolve(res[0]);
} else {
resolve(null);
}
} else { } else {
resolve(null); resolve(null);
} }
@ -180,7 +184,19 @@ export class UsersService {
} }
async deleteAdminSystem(id: string) { async deleteAdminSystem(id: string) {
return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, { return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
new: true,
});
}
deleteAdminCommunity(id: string) {
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
new: true,
});
}
async deleteTenant(id: string) {
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
new: true, new: true,
}); });
} }
@ -202,29 +218,29 @@ export class UsersService {
}); });
} }
async findNumHouseTenant(community_id: string, tenant_id: string) { async findNumHouseTenant(community_id: string, tenant_id: string): Promise<string> {
const pattern = { cmd: 'findOneCommunity' } const pattern = { cmd: 'findOneCommunity' }
const payload = { _id: community_id } const payload = { _id: community_id }
let callback = await this.clientCommunityApp let callback = this.clientCommunityApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((response: string) => ({ response })))
map((response: string) => ({ response }))
)
const finalValue = await lastValueFrom(callback); const finalValue = await lastValueFrom(callback);
const response = finalValue['response']; const response = finalValue['response'];
const houses = response['houses']; const houses = response['houses'];
let num_house = ""; let num_house = "";
await houses.forEach(async house => { await houses.forEach(async (house: { [x: string]: string; }) => {
if (tenant_id == house.tenants.tenant_id) { if (house['tenant_id'] !== undefined) {
num_house = house.number_house; if (house['tenant_id'] === tenant_id) {
num_house = house['number_house'];
} }
}
}) })
return num_house; return num_house;
} }
async changeStatus(id: string, status: string) { async changeStatus(id: string, status: string) {
return this.userModel.findOneAndUpdate({ _id: id }, {status: status}, { return this.userModel.findOneAndUpdate({ _id: id }, { status: status }, {
new: true, new: true,
}); });
} }

View File

@ -17,7 +17,8 @@
"@fullcalendar/interaction": "^5.7.2", "@fullcalendar/interaction": "^5.7.2",
"@fullcalendar/react": "^5.7.0", "@fullcalendar/react": "^5.7.0",
"@fullcalendar/timegrid": "^5.7.2", "@fullcalendar/timegrid": "^5.7.2",
"axios": "^0.19.0", "axios": "^0.19.2",
"bootstrap": "^5.2.0",
"chart.js": "3.3.2", "chart.js": "3.3.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"cors": "^2.8.5", "cors": "^2.8.5",
@ -2288,6 +2289,16 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==",
"peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@svgr/babel-plugin-add-jsx-attribute": { "node_modules/@svgr/babel-plugin-add-jsx-attribute": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz",
@ -4210,6 +4221,24 @@
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="
}, },
"node_modules/bootstrap": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0.tgz",
"integrity": "sha512-qlnS9GL6YZE6Wnef46GxGv1UpGGzAwO0aPL1yOjzDIJpeApeMvqV24iL+pjr2kU4dduoBA9fINKWKgMToobx9A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/twbs"
},
{
"type": "opencollective",
"url": "https://opencollective.com/bootstrap"
}
],
"peerDependencies": {
"@popperjs/core": "^2.11.5"
}
},
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -19688,6 +19717,12 @@
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz",
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==" "integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
}, },
"@popperjs/core": {
"version": "2.11.6",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz",
"integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==",
"peer": true
},
"@svgr/babel-plugin-add-jsx-attribute": { "@svgr/babel-plugin-add-jsx-attribute": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz", "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz",
@ -21217,6 +21252,12 @@
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="
}, },
"bootstrap": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.0.tgz",
"integrity": "sha512-qlnS9GL6YZE6Wnef46GxGv1UpGGzAwO0aPL1yOjzDIJpeApeMvqV24iL+pjr2kU4dduoBA9fINKWKgMToobx9A==",
"requires": {}
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

View File

@ -17,7 +17,8 @@
"@fullcalendar/interaction": "^5.7.2", "@fullcalendar/interaction": "^5.7.2",
"@fullcalendar/react": "^5.7.0", "@fullcalendar/react": "^5.7.0",
"@fullcalendar/timegrid": "^5.7.2", "@fullcalendar/timegrid": "^5.7.2",
"axios": "^0.19.0", "axios": "^0.19.2",
"bootstrap": "^5.2.0",
"chart.js": "3.3.2", "chart.js": "3.3.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"cors": "^2.8.5", "cors": "^2.8.5",

View File

@ -33,7 +33,8 @@ import AdministradoresComunidad from './components/AdministradoresComunidad';
import GuardasSeguridad from './components/GuardasSeguridad'; import GuardasSeguridad from './components/GuardasSeguridad';
import Communities from './components/ComunidadViviendas'; import Communities from './components/ComunidadViviendas';
import Inquilinos from './components/Inquilinos'; import Inquilinos from './components/Inquilinos';
import InquilinosCompletar from "./components/InquilinosCompletar.js"; import RegistroComunicado from './components/RegistroComunicado';
import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
import Crud from './pages/Crud'; import Crud from './pages/Crud';
import EmptyPage from './pages/EmptyPage'; import EmptyPage from './pages/EmptyPage';
@ -200,6 +201,9 @@ const App = () => {
icon: PrimeIcons.BUILDING, icon: PrimeIcons.BUILDING,
to: '/areasComunes', to: '/areasComunes',
}, },
{ label: 'Comunicados', icon: PrimeIcons.COMMENTS, to: '/registroComunicado'},
] ]
}, },
] ]
@ -440,7 +444,6 @@ const App = () => {
<> <>
<Route path="/login" exact component={LogInUser} /> <Route path="/login" exact component={LogInUser} />
</> </>
) )
@ -453,7 +456,6 @@ const App = () => {
<Route path="/administradoresSistema" component={AdministradoresSistema} /> <Route path="/administradoresSistema" component={AdministradoresSistema} />
<Route path="/administradoresComunidad" component={AdministradoresComunidad} /> <Route path="/administradoresComunidad" component={AdministradoresComunidad} />
<Route path="/comunidadesViviendas" component={Communities} /> <Route path="/comunidadesViviendas" component={Communities} />
<Route to="*" exact component={Page404} />
</> </>
) )
@ -465,8 +467,7 @@ const App = () => {
<Route path="/guardasSeguridad" component={GuardasSeguridad} /> <Route path="/guardasSeguridad" component={GuardasSeguridad} />
<Route path="/inquilinos" component={Inquilinos} /> <Route path="/inquilinos" component={Inquilinos} />
<Route path="/areasComunes" component={AreasComunes} /> <Route path="/areasComunes" component={AreasComunes} />
<Route to="*" exact component={Page404} /> <Route path="/registroComunicado" component={RegistroComunicado} />
</> </>
) )
} else { } else {
@ -479,7 +480,6 @@ const App = () => {
return ( return (
<> <>
<Route path="/" exact render={() => <Dashboard colorMode={layoutColorMode} location={location} />} /> <Route path="/" exact render={() => <Dashboard colorMode={layoutColorMode} location={location} />} />
<Route path="/formlayout" component={FormLayoutDemo} /> <Route path="/formlayout" component={FormLayoutDemo} />
<Route path="/input" component={InputDemo} /> <Route path="/input" component={InputDemo} />
<Route path="/floatlabel" component={FloatLabelDemo} /> <Route path="/floatlabel" component={FloatLabelDemo} />
@ -502,8 +502,6 @@ const App = () => {
<Route path="/crud" component={Crud} /> <Route path="/crud" component={Crud} />
<Route path="/empty" component={EmptyPage} /> <Route path="/empty" component={EmptyPage} />
<Route path="/documentation" component={Documentation} /> <Route path="/documentation" component={Documentation} />
</> </>
) )

View File

@ -11,7 +11,7 @@ import { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons';
import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons'; import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons';
import { faAt } from '@fortawesome/free-solid-svg-icons'; import { faAt } from '@fortawesome/free-solid-svg-icons';
import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons'; import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons';
import { faEllipsis } from '@fortawesome/free-solid-svg-icons'; import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
import { faHomeAlt } from '@fortawesome/free-solid-svg-icons'; import { faHomeAlt } from '@fortawesome/free-solid-svg-icons';
import { Dropdown } from 'primereact/dropdown'; import { Dropdown } from 'primereact/dropdown';
import classNames from 'classnames'; import classNames from 'classnames';
@ -31,7 +31,8 @@ const AdministradoresComunidad = () => {
community_name: '', community_name: '',
user_type: '2', user_type: '2',
date_entry: new Date(), date_entry: new Date(),
status: '1' status: '1',
status_text: '',
}; };
const [listaAdmins, setListaAdmins] = useState([]); const [listaAdmins, setListaAdmins] = useState([]);
@ -47,12 +48,23 @@ const AdministradoresComunidad = () => {
const toast = useRef(null); const toast = useRef(null);
const dt = useRef(null); const dt = useRef(null);
const [changeStatusAdminCommunityDialog, setChangeStatusAdminCommunityDialog] = useState(false);
async function listaAdmin() { async function listaAdmin() {
let nombres = await fetch('http://localhost:4000/user/findAdminComunidad/', { method: 'GET' }) await fetch('http://localhost:4000/user/findAdminComunidad/', { method: 'GET' })
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
return Promise.all(data.message.map(item => { return Promise.all(data.message.map(item => {
if (item.status == '1') {
item.status_text = 'Activo';
} else if (item.status == '0') {
item.status_text = 'Inactivo';
} else {
item.status_text = 'Eliminado';
}
//item.full_name returns the repositorie name //item.full_name returns the repositorie name
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' }) return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
.then((response2) => response2.json()) .then((response2) => response2.json())
@ -63,7 +75,13 @@ const AdministradoresComunidad = () => {
}) })
})); }));
}) })
.then(data => setListaAdmins(data)); .then(data => {
data = data.filter(
(val) => val.status != -1,
);
console.log(data)
setListaAdmins(data);
});
} }
@ -72,11 +90,16 @@ const AdministradoresComunidad = () => {
async function getCommunites() { async function getCommunites() {
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' }); let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' })
let resList = await response.json(); .then((response) => response.json())
let list = await resList.message; .then(data => data.message)
.then(data => {
data = data.filter(
(val) => val.status != -1,
)
setCommunitiesList(data);
setCommunitiesList(await list); })
} }
useEffect(() => { useEffect(() => {
@ -85,7 +108,7 @@ const AdministradoresComunidad = () => {
useEffect(() => { useEffect(() => {
getCommunites(); getCommunites();
},[]) }, [])
const cList = communitiesList.map((item) => ({ const cList = communitiesList.map((item) => ({
label: item.name, label: item.name,
@ -94,64 +117,56 @@ const AdministradoresComunidad = () => {
const deleteAdminCommunity = () => { const deleteAdminCommunity = () => {
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, { fetch('http://localhost:4000/user/deleteAdminCommunity/' + adminCommunity._id, {
cache: 'no-cache', cache: 'no-cache',
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
.then( .then(
function (response) { function (response) {
if (response.status != 201) if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status); console.log('Ocurrió un error con el servicio: ' + response.status);
else else
return response.json(); return response.json();
} }
) )
.then( .then(
function (response) { function (response) {
let _administrators = listaAdmins.filter(
(val) => val._id !== adminCommunity._id,
);
setListaAdmins(_administrators);
setDeleteAdminCommunityDialog(false);
setAdminCommunity(emptyAdminCommunity);
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador Comunidad Eliminada', life: 3000 });
}
)
.catch(
err => {
console.log('Ocurrió un error con el fetch', err)
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador Comunidad no se pudo eliminar', life: 3000 });
}
);
let _community = communities.filter(val => val._id !== community._id);
setCommunities(_community);
setDeleteCommunityDialog(false);
setCommunity(emptyCommunity);
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 });
}
)
.catch(
err => {
console.log('Ocurrió un error con el fetch', err)
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 });
}
);
*/
let _administrators = listaAdmins.filter(
(val) => val._id !== adminCommunity._id,
);
setListaAdmins(_administrators);
setDeleteAdminCommunityDialog(false);
setAdminCommunity(emptyAdminCommunity);
toast.current.show({
severity: 'success',
summary: 'Administrador de Comunidad Eliminada',
life: 3000,
});
}; };
const deleteSelectedAdminsCommunity = () => { const deleteSelectedAdminsCommunity = () => {
let _admins = listaAdmins.filter( let _admins = listaAdmins.filter(
(val) => !selectedAdminsCommunities.includes(val), (val) => !selectedAdminsCommunities.includes(val),
); );
/* selectedCommunities.map((item) => { selectedAdminsCommunities.map((item) => {
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, { fetch('http://localhost:4000/user/deleteAdminCommunity/' + item._id, {
cache: 'no-cache', cache: 'no-cache',
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
})*/ })
setListaAdmins(_admins); setListaAdmins(_admins);
setDeleteAdminsCommunitiesDialog(false); setDeleteAdminsCommunitiesDialog(false);
setSelectedAdminsCommunities(null); setSelectedAdminsCommunities(null);
@ -163,6 +178,52 @@ const AdministradoresComunidad = () => {
}); });
}; };
const cambiarStatusAdminCommuniy = () => {
if (adminCommunity.status == '1') {
adminCommunity.status = '0';
adminCommunity.status_text = 'Inactivo';
} else if (adminCommunity.status == '0') {
adminCommunity.status = '1';
adminCommunity.status_text = 'Activo';
}
var data = {
id: adminCommunity._id,
status: adminCommunity.status,
};
fetch('http://localhost:4000/user/changeStatus', {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(
function (response) {
if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status);
else
return response.json();
}
)
.then(
function (response) {
setChangeStatusAdminCommunityDialog(false);
toast.current.show({
severity: 'success',
summary: 'Éxito',
detail: 'Administrador de Comunidad Actualizado',
life: 3000,
});
}
)
.catch(
err => console.log('Ocurrió un error con el fetch', err)
);
}
const saveAdminCommunity = () => { const saveAdminCommunity = () => {
if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.phone) { if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.phone) {
@ -228,11 +289,33 @@ const AdministradoresComunidad = () => {
setDeleteAdminsCommunitiesDialog(true); setDeleteAdminsCommunitiesDialog(true);
}; };
const hideChangeStatusAdmimCommunityDialog = () => {
setChangeStatusAdminCommunityDialog(false);
};
const confirmChangeStatuAdminCommunity = (adminCommunity) => {
setAdminCommunity(adminCommunity);
setChangeStatusAdminCommunityDialog(true);
};
const actionsAdminCommunity = (rowData) => { const actionsAdminCommunity = (rowData) => {
let icono = '';
let text = '';
if (rowData.status == '0') {
icono = "pi pi-eye";
text = "Activar Administrador de Comunidad"
} else if (rowData.status == '1') {
icono = "pi pi-eye-slash";
text = "Inactivar Administrador de Comunidad"
}
return ( return (
<div className="actions"> <div className="actions">
<Button
icon={`${icono}`}
className="p-button-rounded p-button-warning mt-2 mx-2"
onClick={() => confirmChangeStatuAdminCommunity(rowData)}
title={`${text}`}
/>
<Button <Button
icon="pi pi-trash" icon="pi pi-trash"
className="p-button-rounded p-button-danger mt-2" className="p-button-rounded p-button-danger mt-2"
@ -257,6 +340,22 @@ const AdministradoresComunidad = () => {
</> </>
); );
const changeStatusAdminCommunityDialogFooter = (
<>
<Button
label="No"
icon="pi pi-times"
className="p-button-text"
onClick={hideChangeStatusAdmimCommunityDialog}
/>
<Button
label="Yes"
icon="pi pi-check"
className="p-button-text"
onClick={cambiarStatusAdminCommuniy}
/>
</>
);
const leftToolbarTemplate = () => { const leftToolbarTemplate = () => {
return ( return (
@ -344,6 +443,15 @@ const AdministradoresComunidad = () => {
</> </>
) )
const headerStatus = (
<>
<p> {' '}
<FontAwesomeIcon icon={faCircleQuestion} style={{ color: "#C08135" }} />{' '}
Estado
</p>
</>
)
const onInputChange = (e, name) => { const onInputChange = (e, name) => {
@ -360,6 +468,18 @@ const AdministradoresComunidad = () => {
console.log(getCommunityValue) console.log(getCommunityValue)
} }
const statusBodyTemplate = (rowData) => {
return (
<>
<span
className={`status status-${rowData.status}`}
>
{rowData.status_text}
</span>
</>
);
};
return ( return (
@ -380,9 +500,10 @@ const AdministradoresComunidad = () => {
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> <Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
</Column> </Column>
<Column field="email" sortable header={headerEmail} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column> <Column field="email" sortable header={headerEmail} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column field="phone" header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column> <Column field="phone" header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column field="community_name" sortable header={headerCommuntiy} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column> <Column field="community_name" sortable header={headerCommuntiy} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdminCommunity}></Column> <Column field="status" sortable header={headerStatus} body={statusBodyTemplate} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdminCommunity}></Column>
</DataTable> </DataTable>
<Dialog visible={deleteAdminCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminCommunityDialogFooter} onHide={hideDeleteAdminCommunityDialog}> <Dialog visible={deleteAdminCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminCommunityDialogFooter} onHide={hideDeleteAdminCommunityDialog}>
<div className="flex align-items-center justify-content-center"> <div className="flex align-items-center justify-content-center">
@ -396,6 +517,26 @@ const AdministradoresComunidad = () => {
{selectedAdminsCommunities && <span>¿Está seguro eliminar los administradores de las comunidades de viviendas seleccionados?</span>} {selectedAdminsCommunities && <span>¿Está seguro eliminar los administradores de las comunidades de viviendas seleccionados?</span>}
</div> </div>
</Dialog> </Dialog>
<Dialog
visible={changeStatusAdminCommunityDialog}
style={{ width: '450px' }}
header="Confirmar"
modal
footer={changeStatusAdminCommunityDialogFooter}
onHide={hideChangeStatusAdmimCommunityDialog}
>
<div className="flex align-items-center justify-content-center">
<i
className="pi pi-exclamation-triangle mr-3"
style={{ fontSize: '2rem' }}
/>
{adminCommunity && (
<span>
¿Estás seguro que desea cambiar estado a <b>{adminCommunity.name}</b>?
</span>
)}
</div>
</Dialog>
</div> </div>
</div> </div>
<div className="col-12"> <div className="col-12">

View File

@ -44,7 +44,6 @@ const AdministradoresSistema = () => {
status_text: '', status_text: '',
}; };
async function fetchP() { async function fetchP() {
let nombres = await fetch(urlFetch, { method: 'GET' }); let nombres = await fetch(urlFetch, { method: 'GET' });
let adminRes = await nombres.json(); let adminRes = await nombres.json();
@ -60,11 +59,11 @@ const AdministradoresSistema = () => {
}) })
setAdministrators(await data); setAdministrators(await data);
} }
useEffect(() => { useEffect(() => {
fetchP(); fetchP();
}, []) }, [])
function registrarAdmin() { function registrarAdmin() {
var data = { var data = {
dni: document.getElementById('identificacion').value, dni: document.getElementById('identificacion').value,

View File

@ -43,6 +43,7 @@ const AreasComunes = () => {
const dt = useRef(null); const dt = useRef(null);
const [cookies, setCookie] = useCookies(); const [cookies, setCookie] = useCookies();
const [changeStatusAreaDialog, setChangeStatusAreaDialog] = useState(false);
@ -220,6 +221,51 @@ const AreasComunes = () => {
}); });
}; };
const cambiarStatuscommonArea = () => {
if (commonArea.status == '1') {
commonArea.status = '0';
commonArea.status_text = 'Inactivo';
} else if (commonArea.status == '0') {
commonArea.status = '1';
commonArea.status_text = 'Activo';
}
var data = {
id: commonArea._id,
status: commonArea.status,
};
fetch('http://localhost:4000/commonArea/changeStatus', {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(
function (response) {
if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status);
else
return response.json();
}
)
.then(
function (response) {
setChangeStatusAreaDialog(false);
toast.current.show({
severity: 'success',
summary: 'Éxito',
detail: 'Área Común Actualizada',
life: 3000,
});
}
)
.catch(
err => console.log('Ocurrió un error con el fetch', err)
);
}
const hideDeleteCommonAreaDialog = () => { const hideDeleteCommonAreaDialog = () => {
setDeleteCommonAreaDialog(false); setDeleteCommonAreaDialog(false);
} }
@ -237,9 +283,36 @@ const AreasComunes = () => {
setDeleteCommonAreasDialog(true); setDeleteCommonAreasDialog(true);
}; };
const hideChangeStatusAreaDialog = () => {
setChangeStatusAreaDialog(false);
};
const confirmChangeStatusArea = (commonArea) => {
setCommonArea(commonArea);
setChangeStatusAreaDialog(true);
};
const actionsCommonArea = (rowData) => { const actionsCommonArea = (rowData) => {
let icono = '';
let text = '';
if (rowData.status == '0') {
icono = "pi pi-eye";
text = "Activar Área Común"
} else if (rowData.status == '1') {
icono = "pi pi-eye-slash";
text = "Inactivar Área Común"
}
return ( return (
<div className="actions"> <div className="actions">
<Button
icon={`${icono}`}
className="p-button-rounded p-button-warning mt-2 mx-2"
onClick={() => confirmChangeStatusArea(rowData)}
title={`${text}`}
/>
<Button <Button
icon="pi pi-trash" icon="pi pi-trash"
className="p-button-rounded p-button-danger mt-2" className="p-button-rounded p-button-danger mt-2"
@ -276,6 +349,22 @@ const AreasComunes = () => {
</> </>
); );
const changeStatusAreaDialogFooter = (
<>
<Button
label="No"
icon="pi pi-times"
className="p-button-text"
onClick={hideChangeStatusAreaDialog}
/>
<Button
label="Yes"
icon="pi pi-check"
className="p-button-text"
onClick={cambiarStatuscommonArea}
/>
</>
);
const leftToolbarTemplate = () => { const leftToolbarTemplate = () => {
return ( return (
@ -431,6 +520,26 @@ const AreasComunes = () => {
{selectedCommonAreas && <span>¿Está seguro eliminar las áreas comunes seleccionadas?</span>} {selectedCommonAreas && <span>¿Está seguro eliminar las áreas comunes seleccionadas?</span>}
</div> </div>
</Dialog> </Dialog>
<Dialog
visible={changeStatusAreaDialog}
style={{ width: '450px' }}
header="Confirmar"
modal
footer={changeStatusAreaDialogFooter}
onHide={hideChangeStatusAreaDialog}
>
<div className="flex align-items-center justify-content-center">
<i
className="pi pi-exclamation-triangle mr-3"
style={{ fontSize: '2rem' }}
/>
{commonArea && (
<span>
¿Estás seguro que desea cambiar estado a <b>{commonArea.name}</b>?
</span>
)}
</div>
</Dialog>
</div> </div>
</div> </div>
<div className="col-12"> <div className="col-12">
@ -513,7 +622,7 @@ const AreasComunes = () => {
</div> </div>
<div className="field col-12 md:col-6"> <div className="field col-12 md:col-6">
<label htmlFor="bookable">¿Necesita Reservación?</label> <label htmlFor="bookable">¿Necesita Reservación?</label>
<div className="formgrid grid align-items-end" style={{marginTop: '12px', width: '300px'}}> <div className="formgrid grid align-items-end" style={{ marginTop: '12px', width: '300px' }}>
<div className="field-radiobutton col-6"> <div className="field-radiobutton col-6">
<RadioButton <RadioButton

View File

@ -708,7 +708,11 @@ const Communities = () => {
const tenantsBodyTemplate = (rowData) => { const tenantsBodyTemplate = (rowData) => {
let tenants = rowData.tenants; let tenants = rowData.tenants;
let name = findNameTenant(tenants.tenant_id); let name = 'Sin inquilino';
if (rowData.tenants) {
name = findNameTenant(tenants.tenant_id);
}
return ( return (
<> <>
{name} {name}

View File

@ -16,9 +16,10 @@ import { faHashtag } from '@fortawesome/free-solid-svg-icons'
import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons' import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'
import { useCookies } from 'react-cookie' import { useCookies } from 'react-cookie'
import InfoDialog from './generic/InfoDialog' import InfoDialog from './generic/InfoDialog'
import classNames from 'classnames';
const Inquilinos = () => { const Inquilinos = () => {
let emptyTenant = { const emptyTenant = {
_id: null, _id: null,
dni: '', dni: '',
name: '', name: '',
@ -41,16 +42,15 @@ const Inquilinos = () => {
const [globalFilter, setGlobalFilter] = useState(null) const [globalFilter, setGlobalFilter] = useState(null)
const [deleteTenantDialog, setDeleteTenantDialog] = useState(false) const [deleteTenantDialog, setDeleteTenantDialog] = useState(false)
const [deleteTenantsDialog, setDeleteTenantsDialog] = useState(false) const [deleteTenantsDialog, setDeleteTenantsDialog] = useState(false)
const [communitiesList, setCommunitiesList] = useState([]) const [community, setCommunity] = useState([])
const [communityId, setCommunityId] = useState(null) const [houseNumber, setHouseNumber] = useState([])
const [housesList, setHousesList] = useState([])
const [submitted, setSubmitted] = useState(false) const [submitted, setSubmitted] = useState(false)
let [openInfoDialog] = useState(false) let [openInfoDialog] = useState(false)
const toast = useRef(null) const toast = useRef(null)
const dt = useRef(null) const dt = useRef(null)
const [cookies] = useCookies()
const [cookies, setCookie] = useCookies() const [changeStatusTenantDialog, setChangeStatusTenantDialog] = useState(false)
const [changeStatusTenantDialog, setChangeStatusTenantDialog] =
useState(false)
async function tenantsList() { async function tenantsList() {
await fetch( await fetch(
@ -76,15 +76,21 @@ const Inquilinos = () => {
}) })
} }
async function getCommunites() { async function getCommunity() {
let response = await fetch( let response = await fetch(
'http://localhost:4000/community/allCommunities', `http://localhost:4000/community/findCommunityName/${cookies.community_id}`,
{ method: 'GET' }, { method: 'GET' },
) )
let resList = await response.json() const responseJson = await response.json()
let list = await resList.message const result = await responseJson.message
list = await list.filter((val) => val.status !== -1) setCommunity(await result)
setCommunitiesList(await list) const houses = await result.houses.filter((house) =>
house.state === "desocupada"
)
setHousesList(houses.map((house) => ({
label: house.number_house, value: house.number_house
}))
)
} }
useEffect(() => { useEffect(() => {
@ -92,46 +98,44 @@ const Inquilinos = () => {
}, [tenantsList]) }, [tenantsList])
useEffect(() => { useEffect(() => {
getCommunites() getCommunity()
}, []) }, [])
const cList = communitiesList.map((item) => ({ const saveTenant = () => {
label: item.name, if (tenant.email && tenant.number_house && tenant.dni
value: item._id, && tenant.name && tenant.last_name && tenant.phone) {
})) let _tenants = [...tenants]
let _tenant = { ...tenant }
_tenant.community_id = cookies.community_id;
_tenant.number_house = houseNumber;
_tenant.password = _tenant.email;
function registrarInquilino() { fetch(`http://localhost:4000/user/createUser`, {
let newTenant = { cache: 'no-cache',
_id: null, method: 'POST',
dni: '', body: JSON.stringify(_tenant),
name: '', headers: {
last_name: '', 'Content-Type': 'application/json',
email: document.getElementById('correo_electronico').value, },
phone: '', })
password: '', .then((response) => {
community_id: document.getElementById('numero_vivienda').value, if (response.status !== 201)
community_name: '', console.log(`Hubo un error en el servicio: ${response.status}`)
number_house: 'Sin número de vivienda', else return response.json()
date_entry: new Date(), })
user_type: '3', .then(() => {
status: '1', _tenants.push(_tenant)
status_text: '', toast.current.show({
} severity: 'success',
summary: 'Éxito',
fetch('http://localhost:3000/api/createUser', { detail: 'Inquilino creado',
method: 'POST', life: 3000,
cache: 'no-cache', })
body: JSON.stringify(newTenant), setTenants(_tenants)
headers: { setTenant(emptyTenant)
'Content-Type': 'application/json', })
}, .catch((error) => console.log(`Ocurrió un error: ${error}`))
}).then((response) => { } else setSubmitted(true)
if (response.ok) {
alert('Inquilino registrado correctamente')
} else {
alert('Error al registrar inquilino')
}
})
} }
const deleteTenant = () => { const deleteTenant = () => {
@ -424,11 +428,16 @@ const Inquilinos = () => {
) )
} }
const testInquilino = { const onInputChange = (e, name) => {
name: 'Juan', // Nombre const value = (e.target && e.target.value) || ''
last_name: 'Pérez', // Apellidos let _tenant = { ...tenant }
email: 'jperez@gmail.com', _tenant[`${name}`] = value
phone: '+57 300 1234567', // Teléfono setTenant(_tenant)
}
const handleHouses = (e) => {
const getHouseNumber = e.target.value;
setHouseNumber(getHouseNumber);
} }
return ( return (
@ -608,31 +617,98 @@ const Inquilinos = () => {
</Dialog> </Dialog>
</div> </div>
</div> </div>
<div className='col-12'> <div className="col-12">
<div className='card'> <div className="card">
<h5 className='card-header'>Registrar Inquilino</h5> <h5>Registro de un administrador de una comunidad de viviendas</h5>
<div className='p-fluid formgrid grid'> <div className="p-fluid formgrid grid">
<div className='field col-12 md:col-6'> <div className="field col-12 md:col-6">
<label htmlFor='correo_electronico'>Correo electrónico</label> <label htmlFor="name">Nombre</label>
<InputText <div className="p-0 col-12 md:col-12">
required <div className="p-inputgroup">
type='email' <span className="p-inputgroup-addon p-button p-icon-input-khaki">
className='form-control' <i className="pi pi-home"></i>
id='correo_electronico' </span>
/> <InputText type="text" id="name" value={tenant.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.name === '' })} />
</div>
{submitted && tenant.name === '' && <small className="p-invalid">Nombre es requerido.</small>}
</div>
</div> </div>
<div className='field col-12 md:col-6'> <div className="field col-12 md:col-6">
<label htmlFor='numero_vivienda'>Número de Vivienda</label> <label htmlFor="name">Apellido(s)</label>
<Dropdown <div className="p-0 col-12 md:col-12">
required <div className="p-inputgroup">
id='numero_vivienda' <span className="p-inputgroup-addon p-button p-icon-input-khaki">
value={communityId} <i className="pi pi-home"></i>
options={cList} </span>
onChange={(e) => setCommunityId(e.value)} <InputText type="text" id="last_name" value={tenant.last_name} onChange={(e) => onInputChange(e, 'last_name')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.last_name === '' })} />
/> </div>
{submitted && tenant.last_name === '' && <small className="p-invalid">Apellidos son requeridos.</small>}
</div>
</div> </div>
<Button label='Registrar' onClick={registrarInquilino} /> <Button label='Registrar' onClick={registrarInquilino} />
<Button label='testDialog' onClick={openDialog} /> <Button label='testDialog' onClick={openDialog} />
<div className="field col-12 md:col-6">
<label htmlFor="name">Correo Electrónico</label>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup">
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
<i className="pi pi-home"></i>
</span>
<InputText type='email' id="email" value={tenant.email} onChange={(e) => onInputChange(e, 'email')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.email === '' })} />
</div>
{submitted && tenant.email === '' && <small className="p-invalid">Correo electrónico es requerido.</small>}
</div>
</div>
<div className="field col-12 md:col-6">
<label htmlFor="dni">Identificación</label>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup">
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
<i className="pi pi-home"></i>
</span>
<InputText id="dni" value={tenant.dni} onChange={(e) => onInputChange(e, 'dni')} required autoFocus className={classNames({ 'p-invalid': submitted && tenant.dni === '' })} />
</div>
{submitted && tenant.email === '' && <small className="p-invalid">Identificación es requerida.</small>}
</div>
</div>
<div className="field col-12 md:col-6">
<label htmlFor="phone">Número de teléfono</label>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup">
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
<i className="pi pi-phone"></i>
</span>
<InputText id="phone" value={tenant.phone} onChange={(e) => onInputChange(e, 'phone')} type='tel' required autoFocus className={classNames({ 'p-invalid': submitted && tenant.phone === '' })} />
</div>
{submitted
&& tenant.phone === ''
&& <small className="p-invalid">Número de teléfono es requerido.</small>}
</div>
</div>
<div className="field col-12 md:col-6">
<label htmlFor="number_house">Casa a asignar: </label>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup">
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
<i className="pi pi-home"></i>
</span>
<Dropdown
placeholder="--Seleccione la Casa a Asignar--"
id="number_house"
value={houseNumber}
options={housesList}
onChange={handleHouses}
required autoFocus
className={
classNames({ 'p-invalid': submitted && !houseNumber })}
/>
</div>
{submitted
&& !houseNumber
&& <small className="p-invalid">Casa es requerida.</small>}
</div>
</div>
<Button label="Registrar" onClick={saveTenant} />
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,125 +0,0 @@
import { Button } from 'primereact/button'
import { InputText } from 'primereact/inputtext'
import React, { useState } from 'react'
import { useCookies } from 'react-cookie'
const InquilinosCompletar = () => {
let emptyTenant = {
_id: null,
dni: '',
name: '',
last_name: '',
email: '',
phone: '',
password: '',
community_id: '',
community_name: '',
number_house: 'Sin número de vivienda',
user_type: '4',
date_entry: new Date(),
status: '1',
status_text: '',
}
const [tenant, setTenant] = useState(emptyTenant)
const [selectedTentants, setSelectedTenants] = useState(null)
const [globalFilter, setGlobalFilter] = useState(null)
const [deleteTenantDialog, setDeleteTenantDialog] = useState(false)
const [deleteTenantsDialog, setDeleteTenantsDialog] = useState(false)
const [communitiesList, setCommunitiesList] = useState([])
const [communityId, setCommunityId] = useState(null)
const [submitted, setSubmitted] = useState(false)
const [cookies, setCookie] = useCookies()
const [changeStatusTenantDialog, setChangeStatusTenantDialog] =
useState(false)
function finalizarRegistro() {
let data = {
dni: document.getElementById('identificacion').value,
name: document.getElementById('nombre').value,
last_name: document.getElementById('apellidos').value,
phone: document.getElementById('telefono').value,
email: document.getElementById('correo_electronico').value,
community_id: document.getElementById('numero_vivienda').value,
password: document.getElementById('password').value,
user_type: '3',
status: '1',
}
fetch('http://localhost:3000/api/createUser', {
method: 'PUT',
cache: 'no-cache',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
}).then((response) => {
if (response.ok) {
alert('Inquilino registrado correctamente')
} else {
alert('Error al registrar inquilino')
}
})
}
return (
<div className='grid'>
<div className='col-12'>
<div className='card'>
<h5 className='card-header'>Finalizar Registro</h5>
<div className='p-fluid formgrid grid'>
<div className='field col-12 md:col-6'>
<label htmlFor='nombre'>Nombre</label>
<InputText
required
type='text'
className='form-control'
id='nombre'
/>
</div>
<div className='field col-12 md:col-6'>
<label htmlFor='apellidos'>Apellido(s)</label>
<InputText
required
type='text'
className='form-control'
id='apellidos'
/>
</div>
<div className='field col-12 md:col-6'>
<label htmlFor='identificacion'>Identificación</label>
<InputText
required
type='text'
className='form-control'
id='identificacion'
/>
</div>
<div className='field col-12 md:col-6'>
<label htmlFor='correo_electronico'>Correo electrónico</label>
<InputText
required
type='email'
className='form-control'
id='correo_electronico'
/>
</div>
<div className='field col-12 md:col-6'>
<label htmlFor='password'>Password</label>
<InputText
required
type='password'
className='form-control'
id='password'
/>
</div>
<Button label='Registrar' onClick={finalizarRegistro} />
</div>
</div>
</div>
</div>
)
}
export default React.memo(InquilinosCompletar)

View File

@ -0,0 +1,165 @@
import React, { useEffect, useState, useRef } from 'react';
import { InputText } from 'primereact/inputtext';
import { Button } from 'primereact/button';
import { InputTextarea } from 'primereact/inputtextarea';
import { useCookies } from "react-cookie";
import { DataTable } from 'primereact/datatable';
import { Column } from 'primereact/column';
import { Toast } from 'primereact/toast';
import { Dialog } from 'primereact/dialog';
import { Toolbar } from 'primereact/toolbar';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons';
import { faCommentAlt } from '@fortawesome/free-solid-svg-icons';
import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons';
import { faAt } from '@fortawesome/free-solid-svg-icons';
import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons';
import { faEllipsis } from '@fortawesome/free-solid-svg-icons';
import { faHomeAlt } from '@fortawesome/free-solid-svg-icons';
import { Dropdown } from 'primereact/dropdown';
import classNames from 'classnames';
const RegistroComunicado = () => {
let emptyComunicado = {
_id: null,
post: '',
user_id: '',
community_id: ''
};
useEffect(()=>{
listaComunis();
},[])
const [comunicado, setComunicado] = useState(emptyComunicado);
const [comunicados,setComuicados]=useState([]);
const [comunicadoId, setComunicadoId] = useState(null);
const [submitted, setSubmitted] = useState(false);
const toast = useRef(null);
const dt = useRef(null);
const [cookies, setCookie] = useCookies();
const [globalFilter, setGlobalFilter] = useState(null);
async function listaComunis() {
let comunicadosA=await fetch('http://localhost:4000/post/allPosts', {method:'GET'});
let comunicadosRes= await comunicadosA.json();
setComuicados(comunicadosRes.message);
console.log(comunicadosRes.message);
}
const saveComunicado = () => {
var data = {
post: document.getElementById('txt_comunicado').value,
user_id: cookies.id,
community_id: cookies.community_id
};
fetch('http://localhost:4000/post/createPost', {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(
function (response) {
if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status);
else
return response.json();
}
)
.then(
function (response) {
}
)
.catch(
err => console.log('Ocurrió un error con el fetch', err)
);
}
const header = (
<React.Fragment>
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0">Comunicados de la comunidad</h5>
<span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" />
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />
</span>
</div>
</React.Fragment>
);
const headerPost = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faCommentAlt} style={{ color: "#D7A86E" }} />{' '}
Descripción comunicado</p>
</>
)
const leftToolbarTemplate = () => {
return (
<React.Fragment>
<div className="my-2">
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" />
</div>
</React.Fragment>
)
}
const rightToolbarTemplate = () => {
return (
<React.Fragment>
<Button label="Exportar" icon="pi pi-upload" className="p-button-help" />
</React.Fragment>
)
}
return (
<div className="grid">
<div className="col-12">
<Toast ref={toast} />
<div className="card">
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
<DataTable ref={dt} value={comunicados} dataKey="_id" paginator rows={5}
scrollable scrollHeight="400px" scrollDirection="both" header={header}
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} administradores de comunidades de viviendas"
globalFilter={globalFilter} emptyMessage="No hay administradores de comunidades registrados.">
<Column selectionMode="multiple" headerStyle={{ width: '3rem' }}></Column>
<Column field="post" sortable header={headerPost} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
</DataTable>
</div>
</div>
<div className="col-12">
<div className="card">
<h5>Registro de un comunicado para la comunidad</h5>
<div className="p-fluid formgrid grid">
<div className="field col-12 md:col-12">
<label htmlFor="name">Contenido del comunicado</label>
<div className="p-0 col-12 md:col-12">
<div className="p-inputgroup">
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
<i className="pi pi-pencil"></i>
</span>
<InputTextarea id="txt_comunicado" rows="4"/>
</div>
</div>
</div>
<Button label="Registrar" onClick={saveComunicado} />
</div>
</div>
</div>
</div>
);
};
export default React.memo(RegistroComunicado);