diff --git a/src/Components/Note/Note.tsx b/src/Components/Note/Note.tsx index 19657c0..3610a08 100644 --- a/src/Components/Note/Note.tsx +++ b/src/Components/Note/Note.tsx @@ -2,8 +2,19 @@ import * as React from "react"; import { View, Text, TextInput, ScrollView } from "react-native"; import styles from "../../styles"; import { NoteProps } from "../../Interfaces/Interfaces"; +import ButtonCentered from "../Buttons/ButtonCentered/ButtonCentered"; +import { useQueryClient, useMutation } from "react-query"; +import { DeleteNote } from "../Api/Api"; export default function Note(props: NoteProps) { + const queryClient = useQueryClient(); + const mutation = useMutation({ + mutationFn: DeleteNote, + onSuccess: () => { + queryClient.invalidateQueries("notes"); + queryClient.invalidateQueries("public_notes"); + }, + }); return ( @@ -19,6 +30,29 @@ export default function Note(props: NoteProps) { {props.content} + + { + console.log("Deleted note id " + props.id); + mutation.mutate(props.id); + }} + width={64} + > + + Delete Note + + + console.log("Edited note id " + props.id)} + width={64} + > + + Edit Note + + + ); } diff --git a/src/Routes/Note/Note.tsx b/src/Routes/Note/Note.tsx new file mode 100644 index 0000000..0e2ce6d --- /dev/null +++ b/src/Routes/Note/Note.tsx @@ -0,0 +1,10 @@ +import * as React from "react"; +import { View, Text } from "react-native"; + +export default function Note(id: number) { + return ( + + Note + + ); +}