diff --git a/app/(tabs)/agenda/agendaView.tsx b/app/(tabs)/agenda/agendaView.tsx
index 7fd9b00..e4ed253 100644
--- a/app/(tabs)/agenda/agendaView.tsx
+++ b/app/(tabs)/agenda/agendaView.tsx
@@ -32,7 +32,7 @@ export function ViewAgenda({ data, handleClose }: Props) {
- setConfigVisible(false)} data={data} />
+ setConfigVisible(false)} data={data} />
diff --git a/app/(tabs)/agenda/components/configAgenda.tsx b/app/(tabs)/agenda/components/configAgenda.tsx
index 4b648e8..b466096 100644
--- a/app/(tabs)/agenda/components/configAgenda.tsx
+++ b/app/(tabs)/agenda/components/configAgenda.tsx
@@ -1,32 +1,49 @@
import { Ionicons } from '@expo/vector-icons';
-import { useEffect } from 'react';
-import { Pressable, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
+import { Pressable, StyleSheet, Text, TouchableOpacity, View, Modal } from 'react-native';
+import { useState } from 'react';
+import { ConfirmDel } from './confirmDelete';
type Props = {
data: {
id: string
+ uid_da_agenda: string
nome_agenda: string;
chave_de_convite: string;
firstCreated: string;
};
handleClose: () => void
+ closeAll: () => void
}
-export function ConfigAgenda({ data, handleClose }: Props) {
- const uid = encodeURIComponent(data.id);
- const name = encodeURIComponent(data.nome_agenda);
- const chave = encodeURIComponent(process.env.EXPO_PUBLIC_API_KEY ?? ' ')
- const url= `${process.env.EXPO_PUBLIC_API_URL}/update/agenda?uid_da_agenda=${uid}&nome_agenda=${name}&api_key=${chave}`
- useEffect(()=>{
- fetch(url)
- .then(response=>{
- if(!response.ok){
- const errorText = response.text();
- throw new Error(`${response.status} - ${errorText}`);
- }
- return response.json();
- })
- });
+export function ConfigAgenda({ closeAll, data, handleClose }: Props) {
+ const [viewDel, setViewDel] = useState(false)
+ const deletarAgenda = async () => {
+ const uid = encodeURIComponent(data.id); // ou data.uid_da_agenda, conforme a API espera
+ const chave = encodeURIComponent(process.env.EXPO_PUBLIC_API_KEY ?? '');
+ const url = `${process.env.EXPO_PUBLIC_API_URL}/delete/agenda?uid_da_agenda=${uid}&api_key=${chave}`;
+
+ try {
+ const response = await fetch(url, {
+ method: 'DELETE',
+ });
+
+ if (!response.ok) {
+ const text = await response.text();
+ throw new Error(`Erro: ${response.status} - ${text}`);
+ }
+
+ console.log("Agenda deletada com sucesso!");
+ } catch (error) {
+ console.log("Erro ao deletar a agenda:", error);
+ }
+ };
+
+
+ async function deleteAndClose() {
+ await deletarAgenda();
+ console.log('operação finalizada');
+ closeAll();
+ }
return (
@@ -40,21 +57,24 @@ export function ConfigAgenda({ data, handleClose }: Props) {
{data.nome_agenda}
-
+
- {data.chave_de_convite}
+ {data.chave_de_convite}
{data.firstCreated}
-
+ setViewDel(true)} style={styles.delete}>
Deletar agenda
+
+ setViewDel(false)} finalRemove={deleteAndClose}/>
+
)
@@ -105,7 +125,7 @@ const styles = StyleSheet.create({
},
contentBorderTop: {
flexDirection: "row",
- justifyContent:"space-between",
+ justifyContent: "space-between",
paddingHorizontal: 10,
paddingVertical: 20,
borderWidth: 1,
@@ -123,7 +143,7 @@ const styles = StyleSheet.create({
},
commands: {
justifyContent: "flex-end",
- marginHorizontal:15,
+ marginHorizontal: 15,
marginVertical: 20
},
delete: {
@@ -133,7 +153,7 @@ const styles = StyleSheet.create({
},
delText: {
- fontSize:18,
+ fontSize: 18,
color: "red"
}
})
\ No newline at end of file
diff --git a/app/(tabs)/agenda/components/confirmDelete.tsx b/app/(tabs)/agenda/components/confirmDelete.tsx
new file mode 100644
index 0000000..99d7bd0
--- /dev/null
+++ b/app/(tabs)/agenda/components/confirmDelete.tsx
@@ -0,0 +1,89 @@
+import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
+import { Ionicons } from "@expo/vector-icons";
+
+
+type Props={
+ finalRemove: ()=> void;
+ handleClose: ()=> void
+ data:{
+ id: string
+ uid_da_agenda: string
+ nome_agenda: string;
+ chave_de_convite: string;
+ firstCreated: string;
+ }
+}
+
+export function ConfirmDel({ data, handleClose, finalRemove }:Props){
+
+
+ return(
+
+
+
+
+
+
+ Deseja realmente deletar a agenda:
+ {data.nome_agenda}?
+
+
+
+ Deletar
+
+
+
+ )
+}
+
+const styles = StyleSheet.create({
+ container: {
+ padding: "3%",
+ backgroundColor: "rgba(93, 93, 93, 0.5)",
+ flex:1,
+ justifyContent:"center",
+ alignItems: "center"
+ },
+
+ text:{
+ width:"100%",
+ alignItems:"center",
+ },
+ nameAgenda:{
+ fontSize: 23,
+ marginVertical: 15,
+ fontWeight: 'bold'
+ },
+
+ close:{
+ position:"absolute",
+ top: -20,
+ left: -5
+ },
+
+ content: {
+ justifyContent: "center",
+ alignItems:"center",
+ width: "90%",
+ padding: 15,
+ backgroundColor: "#FFF",
+ borderRadius: 6,
+ paddingBottom: 30,
+ paddingTop: 30,
+ },
+
+ button:{
+ backgroundColor: "#b686f4",
+ height:50,
+ width: 150,
+ borderRadius: 6,
+ justifyContent: "center",
+ alignItems:"center"
+ },
+
+ btnText:{
+ color:"#FFF",
+ fontSize:17,
+ fontWeight:"bold"
+ }
+})
\ No newline at end of file