From fc7488f8aafd52eb4779a96ef10ad42c910ba4ed Mon Sep 17 00:00:00 2001 From: keannu125 Date: Wed, 29 Mar 2023 20:32:05 +0800 Subject: [PATCH 1/2] Fixed public notes api --- src/Components/Api/Api.tsx | 12 +++--------- .../PublicNote/{Note.tsx => PublicNote.tsx} | 0 .../PublicNotes/{Notes.tsx => PublicNotes.tsx} | 2 +- src/Components/ViewToggle/ViewToggle.tsx | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) rename src/Components/PublicNote/{Note.tsx => PublicNote.tsx} (100%) rename src/Components/PublicNotes/{Notes.tsx => PublicNotes.tsx} (93%) diff --git a/src/Components/Api/Api.tsx b/src/Components/Api/Api.tsx index 00c9aff..63358ee 100644 --- a/src/Components/Api/Api.tsx +++ b/src/Components/Api/Api.tsx @@ -28,15 +28,9 @@ 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; - }); + return instance.get("/api/v1/public_notes/").then((response) => { + return response.data; + }); } export function GetNote(id: number) { diff --git a/src/Components/PublicNote/Note.tsx b/src/Components/PublicNote/PublicNote.tsx similarity index 100% rename from src/Components/PublicNote/Note.tsx rename to src/Components/PublicNote/PublicNote.tsx diff --git a/src/Components/PublicNotes/Notes.tsx b/src/Components/PublicNotes/PublicNotes.tsx similarity index 93% rename from src/Components/PublicNotes/Notes.tsx rename to src/Components/PublicNotes/PublicNotes.tsx index 5f497f8..5250a7b 100644 --- a/src/Components/PublicNotes/Notes.tsx +++ b/src/Components/PublicNotes/PublicNotes.tsx @@ -5,7 +5,7 @@ import { Button } from "@mui/material"; import { useQuery } from "react-query"; import { GetPublicNotes } from "../Api/Api"; import { NoteProps } from "../../Interfaces/Interfaces"; -import PublicNote from "../PublicNote/Note"; +import PublicNote from "../PublicNote/PublicNote"; export default function PublicNotes() { const navigate = useNavigate(); diff --git a/src/Components/ViewToggle/ViewToggle.tsx b/src/Components/ViewToggle/ViewToggle.tsx index 8552070..ca9e994 100644 --- a/src/Components/ViewToggle/ViewToggle.tsx +++ b/src/Components/ViewToggle/ViewToggle.tsx @@ -3,7 +3,7 @@ import { useState } from "react"; import styles from "../../styles"; import { Switch } from "@mui/material"; import Notes from "../Notes/Notes"; -import PublicNotes from "../PublicNotes/Notes"; +import PublicNotes from "../PublicNotes/PublicNotes"; export default function ViewToggle() { const [switchLabel, setLabel] = useState("Viewing public notes"); From 7b63a12ae469fd921b963d90a2fa3877e22177eb Mon Sep 17 00:00:00 2001 From: keannu125 Date: Wed, 29 Mar 2023 20:34:28 +0800 Subject: [PATCH 2/2] Removed unused token code snippet --- src/Components/Api/Api.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Api/Api.tsx b/src/Components/Api/Api.tsx index 63358ee..aa2aa7e 100644 --- a/src/Components/Api/Api.tsx +++ b/src/Components/Api/Api.tsx @@ -27,7 +27,6 @@ export function GetNotes() { } export function GetPublicNotes() { - const token = JSON.parse(localStorage.getItem("token") || "{}"); return instance.get("/api/v1/public_notes/").then((response) => { return response.data; });