feat: add admin chapter content editor#220
Conversation
|
@Aish-kul16 is attempting to deploy a commit to the Adarsh's projects Team on Vercel. A member of the Team first needs to authorize it. |
MRIARC-08
left a comment
There was a problem hiding this comment.
Thanks for the contribution! The editor UI is a good start and it covers some parts of the issue like split-panel editing, live preview, file upload, clear option, and draft autosave.
However, this does not fully meet the issue requirements yet. The editor needs to work for a real chapter at /admin/chapters/[chapterId]/edit, fetch the existing chapter markdown content, and save the updated content back to the database. Currently, the Save and Cancel buttons do not perform any action, the content starts from placeholder text, and the localStorage draft key is global instead of being chapter-specific.
Please update the PR to:
- use the
[chapterId]route properly - fetch the current chapter content before editing
- connect the Save button to the chapter update API/server action
- make Cancel return back or reset to the original content
- make the draft key chapter-specific
- show the actual content source from the chapter data, not only local state
- improve validation beyond only checking empty content
Once these are handled, this should be much closer to the expected outcome.
|
Hi @MRIARC-08 , thank you for the feedback i will do the following changes and update you soon. |
|
Hi @MRIARC-08 I've updated the PR to address the requested changes:
|
MRIARC-08
left a comment
There was a problem hiding this comment.
@Aish-kul16 This update still exposes an unauthenticated PATCH endpoint that can modify chapter content. The route must enforce authenticated admin authorization. The editor also never initializes originalContent, so Cancel resets to an empty value, and it targets the old MarkdownRenderer path instead of the live reader. Please address these functional and authorization blockers.
|
Hi @MRIARC-08 I've fixed the I'm currently working on the admin authorization requirement for the PATCH endpoint. For the comment about "targeting the old MarkdownRenderer path instead of the live reader", could you point me to the intended reader component/path that should be used for the preview? I wasn't able to identify the live reader from the current codebase and want to make sure I align the implementation with the existing architecture. |
|
@Aish-kul16 Thanks for the update. GitHub still shows no commit after the latest authorization/config review. Please push the completed changes, including the admin-authorization fix, and tag me when the branch is ready for another pass. |
|
@MRIARC-08 I've pushed the latest changes addressing the review feedback:
The branch is ready for another review pass. For the "live reader" comment, I'm still not sure which reader component/path should be used instead of MarkdownRenderer. If there's a specific component you'd like me to target, please let me know and I'll update it accordingly. |
MRIARC-08
left a comment
There was a problem hiding this comment.
@Aish-kul16 The admin check and originalContent initialization are now present. The live reader component you asked about is src/components/MarkdownViewer.tsx, used by ChapterContent.tsx; the editor still previews through the legacy MarkdownRenderer. The save handler also shows success without checking res.ok, so a 401/403/500 is reported as saved. Please switch the preview to MarkdownViewer, handle non-success responses, and clean the focused lint output (90 formatting errors plus unused state/hook dependency warnings).
|
Thanks for the clarification @MRIARC-08, I found import MarkdownRenderer from '@/components/MarkdownRenderer';
<MarkdownRenderer content={chapter.content ?? ''} />I wasn't able to find a |
|
@Aish-kul16 Current |
|
@MRIARC-08 I've rebased onto current main and updated the editor to use While rerunning lint after the rebase, I hit the newer Before removing or restructuring the draft restoration behavior, I'd appreciate guidance on the preferred pattern for this codebase so I can keep the feature while satisfying the updated lint rules. |
|
@Aish-kul16 For the For draft restoration, use one of these patterns:
|
e51a3e5 to
a4677ce
Compare
MRIARC-08
left a comment
There was a problem hiding this comment.
@Aish-kul16 Thanks for the update. The branch now merges cleanly and the previous draft-loading direction is better, but it still needs changes before merge.
Local checks:
pnpm exec tsc --noEmitpasses.pnpm testpasses: 8 files / 35 tests.- Focused ESLint on the touched admin/NCERT files fails with 46 Prettier errors.
Functional blocker after latest main changes: GET /api/ncert/chapter now requires the parent class and subject context, but the editor still loads with only chapterId:
/api/ncert/chapter?chapterId=${chapterId}
That will fail against current main. Please update the editor/load route to use the current NCERT chapter API contract or add a properly authorized admin-specific fetch path for chapter editing.
After that, run the formatter. Since this adds an admin editor UI, it will still need manual UI review before merge.
|
@MRIARC-08 Thanks for the review. I tracked down the recent NCERT route validation changes (#426) and see that the public The current admin editor route is still
I can implement either approach; I just want to align with the intended architecture before making that change. |
Closes #77
Description
Added an admin chapter content editor at:
/admin/chapters/[chapterId]/editFeatures Implemented
.mdand.txtfilesTesting