katoikia-app/mobile-ui/components/Invitados.js

97 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

import React, { useContext, useEffect, useState } from "react";
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { UserContext } from "../context/UserContext";
import { API } from "../environment/api";
2022-08-19 04:30:47 +00:00
import {
Box, Button,
Center, FormControl, Heading, ScrollView, VStack,FlatList, HStack,Avatar,Spacer,Text
2022-08-19 04:30:47 +00:00
} from "native-base";
export default function Invitados({navigation}) {
const [isRequesting, setIsRequesting] = useState(false);
const [invitados, setInvitados] = useState([]);
2022-08-23 05:27:12 +00:00
const { user } = useContext(UserContext);
const id = user._id;
useEffect(() => {
2022-08-23 05:27:12 +00:00
const onRequestInvitadosData = async () => {
setIsRequesting(true);
try {
const jsonResponse = await fetch(`${API.BASE_URL}/guest/findGuestUser/`+`${id}`, {
method: "GET",
headers: {
'Content-Type': 'application/json'
}
})
const response = await jsonResponse.json();
2022-08-23 06:21:25 +00:00
//console.log(response);
setInvitados(response.message);
} catch (error) {
}
setIsRequesting(false)
}
2022-08-23 05:27:12 +00:00
onRequestInvitadosData()
})
2022-08-19 04:30:47 +00:00
return (
<Box>
<Heading fontSize="xl" p="4" pb="3">
Lista de invitados
</Heading>
<FlatList data={invitados} renderItem={({
item
2022-08-23 05:27:12 +00:00
}) => <Box key={item._id} borderBottomWidth="1" _dark={{
borderColor: "gray.600"
}} borderColor="coolGray.200" pl="4" pr="5" py="2">
2022-08-23 05:27:12 +00:00
<HStack space={3} justifyContent="space-between" >
<MaterialCommunityIcons name="account" size={48} color="#D7A86E" />
<VStack>
<Text _dark={{
color: "warmGray.50"
}} color="coolGray.800" bold>
{item.name+" "+item.last_name}
</Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{item.dni}
</Text>
<Text color="coolGray.600" _dark={{
color: "warmGray.200"
}}>
{item.phone}
</Text>
</VStack>
<Spacer />
<Text fontSize="xs" _dark={{
color: "warmGray.50"
}} color="coolGray.800" alignSelf="flex-start">
{item.number_plate}
</Text>
</HStack>
</Box>} keyExtractor={item => item.id} />
2022-08-23 05:27:12 +00:00
<Button width='200' mt="4" ml='85' backgroundColor='tertiary.600' onPress={() => navigation.navigate('invitado')}>
Agregar invitado
</Button>
</Box>
2022-08-23 05:27:12 +00:00
2022-08-19 04:30:47 +00:00
);
2022-08-23 05:27:12 +00:00
2022-08-19 04:30:47 +00:00
}