diff --git a/src/components/Markdowns/MarkdownEditor.js b/src/components/Markdowns/MarkdownEditor.js
index 90eee44..999ead2 100644
--- a/src/components/Markdowns/MarkdownEditor.js
+++ b/src/components/Markdowns/MarkdownEditor.js
@@ -10,7 +10,8 @@ import { okaidia } from "react-syntax-highlighter/dist/esm/styles/prism";
import "katex/dist/katex.min.css";
import "./MarkdownEditor.css";
import config from "../../config";
-import {fetch_} from "../../utils/requestUtils";
+import { fetch_ } from "../../utils/requestUtils";
+import PathManager from "../PathManager";
const MarkdownEditor = () => {
const { roles } = useContext(AuthContext);
@@ -18,7 +19,7 @@ const MarkdownEditor = () => {
const { id } = useParams();
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
- const [path, setPath] = useState("");
+ const [pathId, setPathId] = useState(1);
useEffect(() => {
if (id) {
@@ -29,10 +30,10 @@ const MarkdownEditor = () => {
.then((data) => {
setTitle(data.title);
setContent(data.content);
- setPath(data.path);
+ setPathId(data.path_id);
})
.catch((err) => {
- console.error("failed to load markdown", err);
+ console.error("Failed to load markdown", err);
});
}
}, [id]);
@@ -42,26 +43,27 @@ const MarkdownEditor = () => {
const method = id ? "PUT" : "POST";
fetch_(url, {
method,
- body: JSON.stringify({ title, content, path }),
+ body: JSON.stringify({ title, content, path_id: pathId }),
}, {
use_cache: false,
use_token: true,
}).then((res) => {
- if(res.ok)
+ if (res.ok) {
navigate("/");
- else
+ } else {
return res.json().then((data) => {
- throw new Error(data.error || "Failed to load markdown");
+ throw new Error(data.error || "Failed to save markdown");
});
+ }
}).catch((err) => {
- console.error("failed to load markdown", err);
- })
-
+ console.error("Failed to save markdown", err);
+ });
};
const hasPermission = roles.includes("admin") || roles.includes("creator");
- if (!hasPermission)
+ if (!hasPermission) {
return
Permission Denied
;
+ }
return (
@@ -84,18 +86,13 @@ const MarkdownEditor = () => {
- {/* Path Field */}
+ {/* PathManager Field */}
-
- setPath(e.target.value)}
- />
-
+
{/* Content Field */}
diff --git a/src/components/Navigations/MainNavigation.js b/src/components/Navigations/MainNavigation.js
index 5be7605..265feae 100644
--- a/src/components/Navigations/MainNavigation.js
+++ b/src/components/Navigations/MainNavigation.js
@@ -58,14 +58,22 @@ const MainNavigation = () => {
{user.profile.name}
-