diff --git a/App.tsx b/App.tsx
index 62b43f4..e08a156 100644
--- a/App.tsx
+++ b/App.tsx
@@ -13,31 +13,31 @@ import Register from "./src/Routes/Register/Register";
import { Provider } from "react-redux";
import Store from "./src/Features/Redux/Store/Store";
import { QueryClient, QueryClientProvider } from "react-query";
-
+import EditNote from "./src/Routes/EditNote/EditNote";
const Drawer = createDrawerNavigator();
const queryClient = new QueryClient();
export default function App() {
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
);
-}
\ No newline at end of file
+}
diff --git a/src/Components/Note/Note.tsx b/src/Components/Note/Note.tsx
index 3610a08..e56b355 100644
--- a/src/Components/Note/Note.tsx
+++ b/src/Components/Note/Note.tsx
@@ -1,12 +1,14 @@
import * as React from "react";
import { View, Text, TextInput, ScrollView } from "react-native";
import styles from "../../styles";
-import { NoteProps } from "../../Interfaces/Interfaces";
+import { NoteProps, RootDrawerParamList } from "../../Interfaces/Interfaces";
import ButtonCentered from "../Buttons/ButtonCentered/ButtonCentered";
import { useQueryClient, useMutation } from "react-query";
import { DeleteNote } from "../Api/Api";
+import { useNavigation } from "@react-navigation/native";
export default function Note(props: NoteProps) {
+ const navigation = useNavigation();
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: DeleteNote,
@@ -45,7 +47,10 @@ export default function Note(props: NoteProps) {
console.log("Edited note id " + props.id)}
+ onPress={() => {
+ navigation.navigate("EditNote", { noteId: props.id });
+ console.log("Editing note id " + props.id);
+ }}
width={64}
>
diff --git a/src/Routes/EditNote/EditNote.tsx b/src/Routes/EditNote/EditNote.tsx
new file mode 100644
index 0000000..ecddbbd
--- /dev/null
+++ b/src/Routes/EditNote/EditNote.tsx
@@ -0,0 +1,119 @@
+import * as React from "react";
+import { View, Text, TextInput } from "react-native";
+import styles from "../../styles";
+import Background from "../../Components/Background/Background";
+import { SafeAreaView } from "react-native-safe-area-context";
+import { useEffect, useState } from "react";
+import { TouchableOpacity } from "react-native";
+import { RootDrawerParamList } from "../../Interfaces/Interfaces";
+import { useNavigation } from "@react-navigation/native";
+import { useMutation, useQuery, useQueryClient } from "react-query";
+import { AddNote, GetNote, UpdateNote } from "../../Components/Api/Api";
+
+export default function EditNote({ navigation, route }: any) {
+ const { noteId } = route.params;
+ const [note, setNote] = useState({
+ title: "",
+ content: "",
+ public: true,
+ });
+ async function retrieve() {
+ let a = await GetNote(noteId);
+ setNote(a);
+ return a;
+ }
+ const { data, isLoading, error } = useQuery("note", retrieve, {
+ retry: 0,
+ });
+ useEffect(() => {
+ setNote(data);
+ }, [data]);
+
+ const queryClient = useQueryClient();
+ const mutation = useMutation({
+ mutationFn: UpdateNote,
+ onSuccess: () => {
+ queryClient.invalidateQueries("notes");
+ queryClient.invalidateQueries("public_notes");
+ },
+ });
+ if (error) {
+ return (
+
+
+ Error retrieving specific note
+
+
+ );
+ }
+ if (isLoading) {
+ return (
+
+
+ Loading note...
+
+
+ );
+ }
+ if (data && note) {
+ return (
+
+
+ Edit Note
+
+
+
+
+ {
+ setNote({ ...note, title: text });
+ }}
+ maxLength={20}
+ />
+
+
+ {
+ await setNote({ ...note, content: text });
+ }}
+ />
+
+ {
+ try {
+ await mutation.mutate({
+ title: note.title,
+ content: note.content,
+ id: noteId,
+ });
+ navigation.navigate("Home");
+ } catch (error) {}
+ console.log(note.content);
+ }}
+ >
+ SAVE
+
+ {
+ navigation.navigate("Home");
+ }}
+ >
+ CANCEL
+
+
+
+
+ );
+ }
+}
diff --git a/src/Routes/Note/Note.tsx b/src/Routes/Note/Note.tsx
deleted file mode 100644
index 0e2ce6d..0000000
--- a/src/Routes/Note/Note.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import * as React from "react";
-import { View, Text } from "react-native";
-
-export default function Note(id: number) {
- return (
-
- Note
-
- );
-}
diff --git a/src/styles.tsx b/src/styles.tsx
index 7b212a1..c53a371 100644
--- a/src/styles.tsx
+++ b/src/styles.tsx
@@ -158,9 +158,10 @@ const styles = StyleSheet.create({
},
typeinput: {
color: "white",
- flex: 1,
- paddingBottom: 250,
+ marginBottom: 16,
marginLeft: 5,
+ minHeight: 128,
+ maxHeight: 768,
},
title: {
color: "white",