Merge pull request #211 from DeimosPr4/UH-listaInvitadosGuarda

Pantallas guarda de seguridad
This commit is contained in:
Traym17 2022-08-30 22:50:57 -06:00 committed by GitHub
commit e035df8a0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 115 additions and 37 deletions

View File

@ -433,6 +433,12 @@ export class AppController {
findGuestUser(@Param('id') paramGuestId: string) { findGuestUser(@Param('id') paramGuestId: string) {
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') @Post('guest/updateGuest')
updateGuest( updateGuest(
@Body('_id') _id: string){ @Body('_id') _id: string){
@ -523,7 +529,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);

View File

@ -549,6 +549,14 @@ export class AppService {
.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 updateGuest(_id: string
) { ) {
const pattern = { cmd: 'removeGuest' }; const pattern = { cmd: 'removeGuest' };
@ -655,6 +663,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' };

View File

@ -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,
} }

View File

@ -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}
/> />
)) ))
} }

View File

@ -15,6 +15,10 @@ export default function Invitados({navigation}) {
const { user } = useContext(UserContext); const { user } = useContext(UserContext);
const id = user._id; const id = user._id;
//const id = "6301df20dac7dcf76dcecade"; //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([]); const [invitado, setInvitado] = useState([]);
useEffect(() => { useEffect(() => {
@ -23,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) {
} }
@ -118,13 +132,9 @@ export default function Invitados({navigation}) {
</VStack> </VStack>
<Spacer /> <Spacer />
<MaterialCommunityIcons name="delete" size={28} color="#7C0808" onPress={() =>{deleteInvitado(item._id)}} /> {user_type == 3 && <MaterialCommunityIcons name="delete" size={28} color="#7C0808" onPress={() =>{deleteInvitado(item._id)}} />}
</HStack> </HStack>
</Box>} keyExtractor={item => item.id} /> </Box>} keyExtractor={item => item.id} />
</Box> </Box>

View File

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

View File

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

View File

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

View File

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

View File

@ -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'];

View File

@ -18,10 +18,14 @@ export class GuestsService {
} }
async findGuestUser(id: string): Promise<Guest[]> { async findGuestUser(id: string): Promise<Guest[]> {
console.log(id);
return this.guestModel.find({_tenant_id:id, status:"1"}).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> {
return this.guestModel.findOne({ _id: id }).exec(); return this.guestModel.findOne({ _id: id }).exec();
} }