From d0879f7eecf5fb8dca686d1dc6f5f06ef32fea68 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Wed, 29 Mar 2023 20:08:56 +0800 Subject: [PATCH] Added component for viewing public notes --- src/Components/Api/Api.tsx | 13 +++++ src/Components/PublicNote/Note.tsx | 25 +++++++++ src/Components/PublicNotes/Notes.tsx | 66 ++++++++++++++++++++++++ src/Components/ViewToggle/ViewToggle.tsx | 65 +++++++++++++++++++++++ src/Routes/Home/Home.tsx | 4 +- 5 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 src/Components/PublicNote/Note.tsx create mode 100644 src/Components/PublicNotes/Notes.tsx create mode 100644 src/Components/ViewToggle/ViewToggle.tsx diff --git a/src/Components/Api/Api.tsx b/src/Components/Api/Api.tsx index e2aa672..e5ec623 100644 --- a/src/Components/Api/Api.tsx +++ b/src/Components/Api/Api.tsx @@ -26,6 +26,19 @@ export function GetNotes() { }); } +export function GetPublicNotes() { + const token = JSON.parse(localStorage.getItem("token") || "{}"); + return instance + .get("/api/v1/public_notes/", { + headers: { + Authorization: "Token " + token, + }, + }) + .then((response) => { + return response.data; + }); +} + export function GetNote(id: number) { const token = JSON.parse(localStorage.getItem("token") || "{}"); return instance diff --git a/src/Components/PublicNote/Note.tsx b/src/Components/PublicNote/Note.tsx new file mode 100644 index 0000000..a1454c9 --- /dev/null +++ b/src/Components/PublicNote/Note.tsx @@ -0,0 +1,25 @@ +import * as React from "react"; +import styles from "../../styles"; +import { NoteProps } from "../../Interfaces/Interfaces"; + +export default function PublicNote(props: NoteProps) { + return ( +
+
+

Owner: {props.owner}

+

Title: {props.title}

+
+