2022-08-23 02:53:58 +00:00
|
|
|
import { format } from "date-fns";
|
|
|
|
import {
|
2022-08-29 23:15:46 +00:00
|
|
|
Box,
|
2022-08-23 02:53:58 +00:00
|
|
|
ScrollView,
|
|
|
|
Text,
|
|
|
|
Stack,
|
2022-08-23 04:20:07 +00:00
|
|
|
Heading,
|
|
|
|
Badge
|
2022-08-23 02:53:58 +00:00
|
|
|
} from "native-base";
|
|
|
|
import PropTypes from 'prop-types';
|
2022-09-01 15:26:50 +00:00
|
|
|
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
2022-08-23 02:53:58 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-09-01 21:13:44 +00:00
|
|
|
export const ReservasCard = ({id, date, startTime, name}) => {
|
2022-09-01 05:41:36 +00:00
|
|
|
|
|
|
|
const dateFormated = date.toString().split("T")[0]
|
2022-08-23 02:53:58 +00:00
|
|
|
|
2022-09-01 21:13:44 +00:00
|
|
|
const deleteReservas = async(id) => {
|
2022-08-23 02:53:58 +00:00
|
|
|
|
2022-09-01 21:13:44 +00:00
|
|
|
|
2022-09-01 15:26:50 +00:00
|
|
|
try {
|
|
|
|
|
2022-09-01 21:13:44 +00:00
|
|
|
await fetch(`http://localhost:4000/reservation/deleteReservation/`+`${id}`, {
|
2022-09-01 15:26:50 +00:00
|
|
|
|
|
|
|
cache: 'no-cache',
|
|
|
|
method: 'DELETE',
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-23 02:53:58 +00:00
|
|
|
return (
|
|
|
|
<ScrollView showsVerticalScrollIndicator={false}>
|
|
|
|
|
|
|
|
|
|
|
|
<Box mt="5" 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}>
|
2022-08-23 04:20:07 +00:00
|
|
|
|
2022-09-01 04:58:53 +00:00
|
|
|
|
|
|
|
<Heading size="lg" ml="-1">
|
2022-08-24 17:15:27 +00:00
|
|
|
{name}
|
2022-08-23 02:53:58 +00:00
|
|
|
</Heading>
|
2022-09-01 04:58:53 +00:00
|
|
|
<Text fontSize="md" _light={{
|
2022-09-01 05:41:36 +00:00
|
|
|
color: "amber.600"
|
2022-08-23 02:53:58 +00:00
|
|
|
}} _dark={{
|
|
|
|
color: "violet.400"
|
|
|
|
}} fontWeight="500" ml="-0.5" mt="-1">
|
|
|
|
{dateFormated}
|
|
|
|
</Text>
|
|
|
|
</Stack>
|
2022-09-01 04:58:53 +00:00
|
|
|
<Text fontSize="md" fontWeight="400">
|
2022-08-23 02:53:58 +00:00
|
|
|
Hora de inicio: {startTime}
|
|
|
|
</Text>
|
2022-09-01 04:58:53 +00:00
|
|
|
|
2022-08-23 02:53:58 +00:00
|
|
|
|
|
|
|
</Stack>
|
2022-09-01 04:58:53 +00:00
|
|
|
|
|
|
|
|
2022-09-01 22:19:11 +00:00
|
|
|
{/* <MaterialCommunityIcons ml="70" name="delete" size={28} color="#7C0808" onPress={() =>{deleteReservas(id)}} /> */}
|
2022-08-23 02:53:58 +00:00
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
</ScrollView>
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
2022-09-01 15:26:50 +00:00
|
|
|
ReservasCard.propTypes = {
|
|
|
|
date: PropTypes.string.isRequired,
|
|
|
|
startTime: PropTypes.string.isRequired,
|
2022-09-01 21:13:44 +00:00
|
|
|
id: PropTypes.string.isRequired
|
2022-09-01 15:26:50 +00:00
|
|
|
}
|