Merge pull request #203 from DeimosPr4/uh-deleteInvitados

Uh delete invitados
This commit is contained in:
Traym17 2022-08-24 22:37:11 -06:00 committed by GitHub
commit fc36627951
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 13 deletions

View File

@ -431,7 +431,11 @@ export class AppController {
findGuestUser(@Param('id') paramGuestId: string) { findGuestUser(@Param('id') paramGuestId: string) {
return this.appService.findGuestUser(paramGuestId); return this.appService.findGuestUser(paramGuestId);
} }
@Post('guest/updateGuest')
updateGuest(
@Body('_id') _id: string){
return this.appService.updateGuest(_id);
}
// #==== API Payment // #==== API Payment

View File

@ -322,6 +322,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' };
@ -541,11 +542,22 @@ 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 })));
} }
updateGuest(_id: string
) {
const pattern = { cmd: 'removeGuest' };
const payload = {
_id: _id
};
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })))
}
// ====================== PAYMENTS =============================== // ====================== PAYMENTS ===============================
//POST parameter from API //POST parameter from API

View File

@ -29,6 +29,7 @@ export default function AgregarInvitados({ navigation }) {
"dni": dni, "dni": dni,
"phone": phone, "phone": phone,
"number_plate": number_plate, "number_plate": number_plate,
"status":"-0",
"tenant_id": user.id, "tenant_id": user.id,
"community_id": user.community_id "community_id": user.community_id
} }

View File

@ -8,11 +8,14 @@ import {
} 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 = "62ff074949eb1e993a9d0fda";
const [invitado, setInvitado] = useState([]);
useEffect(() => { useEffect(() => {
@ -42,6 +45,34 @@ export default function Invitados({navigation}) {
}) })
const deleteInvitado = async(pid) => {
const data = {
"_id": pid
}
try {
await fetch("http://localhost:4000/guest/updateGuest", {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => {
if (response.status != 201){
console.log('ocurrio un error ');
}else{
return response.json();
}
})
} catch (error) {
console.log("ERROR: " + error);
}
}
return ( return (
<Box> <Box>
@ -67,20 +98,22 @@ 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"
}}> }}>
(506) {item.phone} {"Teléfono: "+item.phone}
</Text> </Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{"Número Placa: "+item.number_plate}
</Text>
</VStack> </VStack>
<Spacer /> <Spacer />
<Text fontSize="xs" _dark={{ <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} />

View File

@ -39,7 +39,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);
} }
} }

View File

@ -18,7 +18,8 @@ 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(); console.log(id);
return this.guestModel.find({_tenant_id:id, status:"-0"}).setOptions({ sanitizeFilter: true }).exec();
} }
findOneId(id: string): Promise<Guest> { findOneId(id: string): Promise<Guest> {