diff --git a/src/Components/PublicNote/PublicNote.tsx b/src/Components/PublicNote/PublicNote.tsx new file mode 100644 index 0000000..9eef3cc --- /dev/null +++ b/src/Components/PublicNote/PublicNote.tsx @@ -0,0 +1,37 @@ +import * as React from "react"; +import { View, Text, TextInput, ScrollView } from "react-native"; +import styles from "../../styles"; +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 PublicNote(props: NoteProps) { + const navigation = useNavigation(); + const queryClient = useQueryClient(); + const mutation = useMutation({ + mutationFn: DeleteNote, + onSuccess: () => { + queryClient.invalidateQueries("notes"); + queryClient.invalidateQueries("public_notes"); + }, + }); + return ( + + + + + + + {props.content} + + + + ); +} diff --git a/src/Components/PublicNotes/Notes.tsx b/src/Components/PublicNotes/Notes.tsx index efc4850..82ab0c1 100644 --- a/src/Components/PublicNotes/Notes.tsx +++ b/src/Components/PublicNotes/Notes.tsx @@ -8,6 +8,7 @@ import { RootState } from "../../Features/Redux/Store/Store"; import { NoteProps, RootDrawerParamList } from "../../Interfaces/Interfaces"; import { useNavigation } from "@react-navigation/native"; import Note from "../Note/Note"; +import PublicNote from "../PublicNote/PublicNote"; export default function PublicNotes() { const navigation = useNavigation(); @@ -39,7 +40,7 @@ export default function PublicNotes() { {notes.map((note: NoteProps, index: number) => { 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); + + + { + setNote({ ...note, title: text }); }} - > - SAVE - - { - navigation.navigate("Home"); - }} - > - CANCEL - + maxLength={20} + /> - + + { + await setNote({ ...note, content: text }); + }} + /> + + + setNote({ ...note, public: !note.public })} + value={note.public} + /> + + Public? + + + { + try { + await mutation.mutate({ + title: note.title, + content: note.content, + public: note.public, + id: noteId, + }); + navigation.navigate("Home"); + } catch (error) {} + console.log(note.content); + }} + > + SAVE + + { + navigation.navigate("Home"); + }} + > + CANCEL + + ); } diff --git a/src/styles.tsx b/src/styles.tsx index c53a371..a77b043 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -180,7 +180,8 @@ const styles = StyleSheet.create({ addnotecont: { marginTop: 30, marginLeft: 22, - height: 500, + paddingBottom: 30, + minHeight: 500, width: 350, borderRadius: 25, backgroundColor: "black",