-
Notifications
You must be signed in to change notification settings - Fork 0
Coding challenge (Rafael Macapagal) #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Backend Implemented PDF viewer API Implemented Docs viewer API Frontend Created file reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a file viewer feature that allows users to view PDF and DOCX files. The backend provides new API endpoints for file content retrieval and viewing, while the frontend adds components to display these files appropriately.
- Added backend endpoints for viewing PDF files and converting DOCX files to HTML
- Enhanced frontend with file type detection and rendering components
- Updated file interface to include filename property
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| frontend/src/app/page.tsx | Added file viewer functionality with PDF and DOCX rendering components |
| backend/server.js | Implemented new API endpoints for file content retrieval and PDF viewing |
Comments suppressed due to low confidence (4)
frontend/src/app/page.tsx:73
- Variable name 'file_split' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileSplit'.
const file_split = file.filename.split('.')
frontend/src/app/page.tsx:74
- Variable name 'file_type' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileType'.
const file_type = file_split.slice(-1)[0]
backend/server.js:59
- Variable name 'file_type' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileType'.
const file_type = path.extname(file.filename)
backend/server.js:80
- Variable name 'file_type' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileType'.
const file_type = path.extname(file.filename)
| interface File { | ||
| id: string; | ||
| name: string; | ||
| filename: string |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the filename property declaration. This is inconsistent with the other interface properties.
| filename: string | |
| filename: string; |
Copilot uses AI. Check for mistakes.
| }) | ||
| { | ||
| return ( | ||
| <div dangerouslySetInnerHTML={{__html: html}}></div> |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using dangerouslySetInnerHTML with unsanitized HTML content from the server creates a potential XSS vulnerability. Consider sanitizing the HTML content before rendering.
Copilot uses AI. Check for mistakes.
| }) | ||
| { | ||
| return ( | ||
| <iframe src={link} width={750} height={1000} /> |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iframe is missing important security attributes. Consider adding 'sandbox' and 'title' attributes for better security and accessibility.
| <iframe src={link} width={750} height={1000} /> | |
| <iframe src={link} width={750} height={1000} sandbox="allow-scripts allow-same-origin" title="PDF Viewer" /> |
Copilot uses AI. Check for mistakes.
| }; | ||
|
|
||
| useEffect(() => { | ||
| setFileLoading(true) |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the statement. This is inconsistent with the coding style used elsewhere in the file.
| setFileLoading(true) | |
| setFileLoading(true); |
Copilot uses AI. Check for mistakes.
| console.error("file not found!") | ||
| setFileLoading(false) | ||
| return |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the statement. This is inconsistent with the coding style used elsewhere in the file.
| console.error("file not found!") | |
| setFileLoading(false) | |
| return | |
| console.error("file not found!"); | |
| setFileLoading(false); | |
| return; |
Copilot uses AI. Check for mistakes.
| } | ||
| const file_type = path.extname(file.filename) | ||
| if ( file_type !== '.pdf' ) { | ||
| return res.status(422).json({ message: "Preview not supported" }); |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent error response format. This endpoint uses 'message' property while other error responses use 'error' property. Should be consistent across the API.
| return res.status(422).json({ message: "Preview not supported" }); | |
| return res.status(422).json({ error: "Preview not supported" }); |
Copilot uses AI. Check for mistakes.
Backend
Implemented PDF viewer API
Implemented Docs viewer API
Frontend
Created file reader