Skip to content

Commit 092510d

Browse files
Update frontend/src/pages/content/ContentEditor.tsx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent e693e20 commit 092510d

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

frontend/src/pages/content/ContentEditor.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,26 @@ export default function ContentEditor({ isEditMode }: { isEditMode: boolean }) {
6464
}
6565
}, [editor]);
6666

67+
// At the top of frontend/src/pages/content/ContentEditor.tsx
68+
-import { useNavigate } from "react-router-dom";
69+
+import { useNavigate, useParams } from "react-router-dom";
70+
71+
function ContentEditor({ /* props */ }) {
72+
const navigate = useNavigate();
73+
+ const { id } = useParams<{ id: string }>();
74+
6775
// Fetch existing content data if in edit mode
6876
useEffect(() => {
6977
if (isEditMode) {
70-
// Fetch existing content data if in edit mode
7178
const fetchContent = async () => {
7279
try {
73-
const content = await axios.get(
74-
`${apiURL}/content/${window.location.pathname.split("/").pop()}`,
75-
{
76-
withCredentials: true,
77-
}
80+
- const content = await axios.get(
81+
- `${apiURL}/content/${window.location.pathname.split("/").pop()}`,
82+
+ const content = await axios.get(
83+
+ `${apiURL}/content/${id}`,
84+
{
85+
withCredentials: true,
86+
}
7887
);
7988

8089
if (content.data) {
@@ -83,8 +92,10 @@ export default function ContentEditor({ isEditMode }: { isEditMode: boolean }) {
8392
if (editor) {
8493
editor.commands.setContent(content.data.content);
8594
}
86-
if (content.data.thumbnailUrl) {
87-
setThumbnailPreview(content.data.thumbnailUrl);
95+
- if (content.data.thumbnailUrl) {
96+
- setThumbnailPreview(content.data.thumbnailUrl);
97+
+ if (content.data.thumbnail) {
98+
+ setThumbnailPreview(content.data.thumbnail);
8899
}
89100
} else {
90101
setError("Failed to load content. Please try again.");
@@ -97,7 +108,8 @@ export default function ContentEditor({ isEditMode }: { isEditMode: boolean }) {
97108
fetchContent();
98109
}
99110
}, [isEditMode, editor]);
100-
111+
// …
112+
}
101113
// ---------------------------------------
102114
// -------------- Functions --------------
103115
// ---------------------------------------

0 commit comments

Comments
 (0)