Merge pull request #208 from DeimosPr4/UH-actualizacionInvitado

Agregar categoría al invitado
This commit is contained in:
Traym17 2022-08-29 20:45:54 -06:00 committed by GitHub
commit 53b1973d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 11 deletions

View File

@ -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": {

View File

@ -403,6 +403,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,
@ -414,6 +415,7 @@ export class AppController {
tenant_id, tenant_id,
community_id, community_id,
date_entry, date_entry,
type_guest,
); );
} }

View File

@ -512,11 +512,12 @@ 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)

View File

@ -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";
@ -21,6 +21,7 @@ export default function AgregarInvitados({ navigation }) {
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 [errors, setErrors] = useState({});
const [categoria, setCategoria] = React.useState("");
const [info, setInfo] = useState({ const [info, setInfo] = useState({
name: "", name: "",
@ -28,9 +29,12 @@ export default function AgregarInvitados({ navigation }) {
dni: "", dni: "",
phone: "", phone: "",
number_plate:"", number_plate:"",
status: "-0", status: "1",
tenant_id: user._id, tenant_id: user._id,
community_id: user.community_id //tenant_id: "6301df20dac7dcf76dcecade",
community_id: user.community_id,
//community_id: "62be68215692582bbfd77134",
type_guest:""
}); });
const onHandleChange = (name) => (value) => setInfo(prev => ({...prev, [name]: value})) const onHandleChange = (name) => (value) => setInfo(prev => ({...prev, [name]: value}))
@ -90,6 +94,7 @@ export default function AgregarInvitados({ navigation }) {
if (response.status != 201){ if (response.status != 201){
console.log('ocurrio un error '); console.log('ocurrio un error ');
}else{ }else{
navigation.navigate('Inicio');
return response.json(); return response.json();
} }
}) })
@ -143,6 +148,18 @@ export default function AgregarInvitados({ navigation }) {
<FormControl > <FormControl >
<FormControl.Label>Placa</FormControl.Label> <FormControl.Label>Placa</FormControl.Label>
<TextInput style={styles.input} type="text" onChangeText={onHandleChange("number_plate")} /> <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="Choose Service" _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

View File

@ -13,8 +13,8 @@ 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 = "62ff074949eb1e993a9d0fda"; //const id = "6301df20dac7dcf76dcecade";
const [invitado, setInvitado] = useState([]); const [invitado, setInvitado] = useState([]);
useEffect(() => { useEffect(() => {
@ -110,6 +110,11 @@ export default function Invitados({navigation}) {
}}> }}>
{"Número Placa: "+item.number_plate} {"Número Placa: "+item.number_plate}
</Text> </Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{"Tipo de acceso: "+item.type_guest}
</Text>
</VStack> </VStack>
<Spacer /> <Spacer />

View File

@ -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": {

View File

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

View File

@ -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);

View File

@ -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": {