diff --git a/src/Components/PublicNotes/Notes.tsx b/src/Components/PublicNotes/Notes.tsx new file mode 100644 index 0000000..efc4850 --- /dev/null +++ b/src/Components/PublicNotes/Notes.tsx @@ -0,0 +1,55 @@ +import * as React from "react"; +import { View, Text, TouchableOpacity, ScrollView } from "react-native"; +import { useQuery } from "react-query"; +import { GetNotes, GetPublicNotes } from "../Api/Api"; +import styles from "../../styles"; +import { useSelector } from "react-redux"; +import { RootState } from "../../Features/Redux/Store/Store"; +import { NoteProps, RootDrawerParamList } from "../../Interfaces/Interfaces"; +import { useNavigation } from "@react-navigation/native"; +import Note from "../Note/Note"; + +export default function PublicNotes() { + const navigation = useNavigation(); + const { + data: notes, + isLoading, + error, + } = useQuery("public_notes", GetPublicNotes, { retry: 0 }); + if (isLoading) { + return ( + + Loading public notes... + + ); + } else if (error) { + return ( + + Error contacting Notes server + + ); + } else if (notes.length === 0) { + return ( + + There are no public notes... + + ); + } + return ( + + {notes.map((note: NoteProps, index: number) => { + return ( + + ); + })} + + ); +} diff --git a/src/Routes/Home/Home.tsx b/src/Routes/Home/Home.tsx index 0e171f8..50bc561 100644 --- a/src/Routes/Home/Home.tsx +++ b/src/Routes/Home/Home.tsx @@ -5,13 +5,14 @@ import Background from "../../Components/Background/Background"; import Notes from "../../Components/Notes/Notes"; import { Switch } from "react-native-gesture-handler"; import { useState } from "react"; +import PublicNotes from "../../Components/PublicNotes/Notes"; export default function Home() { const [switchLabel, setLabel] = useState("Viewing public notes"); - const [togglePublic, setToggled] = useState(false); + const [togglePublic, setToggled] = useState(true); function Preview() { if (togglePublic) { - return Viewing public notes; + return ; } else { return ; }