@@ -65,6 +63,7 @@ export default function Notes() {
content={note.content}
date_created={note.date_created}
owner={note.owner}
+ public={note.public}
/>
);
})}
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}
+
+
+
+
+ Timestamp: {String(props.date_created)}
+
+
Public: {props.public ? "Yes" : "No"}
+
+
+ );
+}
diff --git a/src/Components/PublicNotes/Notes.tsx b/src/Components/PublicNotes/Notes.tsx
new file mode 100644
index 0000000..5f497f8
--- /dev/null
+++ b/src/Components/PublicNotes/Notes.tsx
@@ -0,0 +1,63 @@
+import * as React from "react";
+import styles from "../../styles";
+import { useNavigate } from "react-router-dom";
+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";
+
+export default function PublicNotes() {
+ const navigate = useNavigate();
+ const {
+ data: notes,
+ isLoading,
+ error,
+ } = useQuery("public_notes", GetPublicNotes, { retry: 0 });
+ if (isLoading) {
+ return (
+
+ );
+ } else if (error) {
+ return (
+
+
Error contacting Notes server
+
+ );
+ } else if (notes.length === 0) {
+ return (
+
+
No notes exist yet
+
Make one!
+
+
+ );
+ }
+ return (
+ <>
+ {notes.map((note: NoteProps, index: number) => {
+ return (
+
+ );
+ })}
+ >
+ );
+}
diff --git a/src/Components/ViewToggle/ViewToggle.tsx b/src/Components/ViewToggle/ViewToggle.tsx
new file mode 100644
index 0000000..ced5423
--- /dev/null
+++ b/src/Components/ViewToggle/ViewToggle.tsx
@@ -0,0 +1,65 @@
+import * as React from "react";
+import { useState } from "react";
+import styles from "../../styles";
+import { Switch } from "@mui/material";
+import Notes from "../Notes/Notes";
+import PublicNotes from "../PublicNotes/Notes";
+
+export default function ViewToggle() {
+ const [switchLabel, setLabel] = useState("Viewing public notes");
+ const [togglePublic, setToggled] = useState(true);
+ if (togglePublic) {
+ return (
+
+
+
{
+ setToggled(!togglePublic);
+ if (togglePublic) {
+ setLabel("Viewing own notes");
+ } else {
+ setLabel("Viewing public notes");
+ }
+ }}
+ />
+ {switchLabel}
+
+
+
+ );
+ }
+ return (
+
+
+
{
+ setToggled(!togglePublic);
+ if (togglePublic) {
+ setLabel("Viewing own notes");
+ } else {
+ setLabel("Viewing public notes");
+ }
+ }}
+ />
+ {switchLabel}
+
+
+
+ );
+}
diff --git a/src/Interfaces/Interfaces.tsx b/src/Interfaces/Interfaces.tsx
index 768ae65..24576c1 100644
--- a/src/Interfaces/Interfaces.tsx
+++ b/src/Interfaces/Interfaces.tsx
@@ -6,6 +6,7 @@ export interface NoteProps {
id: number;
date_created: Date;
owner: string;
+ public: boolean;
}
export interface IconProps {
@@ -34,10 +35,12 @@ export interface ActivationParams {
export interface AddNoteParams {
title: string;
content: string;
+ public: boolean;
}
export interface UpdateNoteParams {
id: number;
title: string;
content: string;
+ public: boolean;
}
diff --git a/src/Routes/Home/Home.tsx b/src/Routes/Home/Home.tsx
index ddc9770..e069b13 100644
--- a/src/Routes/Home/Home.tsx
+++ b/src/Routes/Home/Home.tsx
@@ -1,11 +1,11 @@
import styles from "../../styles";
import Header from "../../Components/Header/Header";
-import Notes from "../../Components/Notes/Notes";
+import ViewToggle from "../../Components/ViewToggle/ViewToggle";
export default function Home() {
return (
-
+
);
}
diff --git a/src/Routes/Login/Login.tsx b/src/Routes/Login/Login.tsx
index 9b5bf95..98be5f3 100644
--- a/src/Routes/Login/Login.tsx
+++ b/src/Routes/Login/Login.tsx
@@ -32,6 +32,7 @@ export default function Login() {
onChange={(e: React.ChangeEvent
) => {
setUser({ ...user, username: e.target.value });
}}
+ value={user.username}
/>
@@ -43,6 +44,7 @@ export default function Login() {
onChange={(e: React.ChangeEvent) => {
setUser({ ...user, password: e.target.value });
}}
+ value={user.password}
/>