Conversation
Also updating the docs for this
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a full-stack error reporting system with frontend form, Redux state management, backend persistence in MongoDB, and tutorial documentation updates.
- Adds shared
ErrorDocumenttype and exports it - Implements backend route/service/collection for creating error reports
- Integrates frontend Redux slice, async thunk, and
ReportErrorform component
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| shared/src/types/index.ts | Export new error types |
| shared/src/types/error/index.ts | Define ErrorDocument schema |
| server/src/routes/error.ts | New Express route for posting error reports |
| server/src/index.ts | Mount /errors router |
| server/src/db/models/error/errorServices.ts | Service logic for creating error reports |
| server/src/db/models/error/errorCollection.ts | MongoDB collection insert for error reports |
| Client/src/redux/error/errorSlice.ts | Redux slice and async thunk for submitting error reports |
| Client/src/redux/error/crudError.ts | HTTP client to POST error reports |
| Client/src/pages/ErrorPage/ErrorPage.tsx | Integrate ReportError form into error page UI |
| Client/src/components/errorPage/ReportError.tsx | Full UI form component with Zod validation |
| documentation/full-stack-tutorial.md | Tutorial updates for store, reducers, and component |
Comments suppressed due to low confidence (3)
documentation/full-stack-tutorial.md:88
- [nitpick] The section numbering jumps from 9 to 11. Renumber this header to
### 10. Improve the Component Designto keep the steps sequential.
### 11. Improve the Component Design
Client/src/redux/error/errorSlice.ts:1
- There are no unit tests covering the
submitErrorReportthunk or reducers. Consider adding tests for pending, fulfilled, and rejected states to ensure the slice behaves as expected.
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
server/src/db/models/error/errorServices.ts:7
- The service signature still requires
userIdbut the frontend does not supply it. Either omituserIdfrom the input type and inject it server-side, or ensure the authenticated user ID is added before calling this function.
errorData: Omit<ErrorDocument, "_id" | "createdAt" | "updatedAt" | "status">
| res.status(500).json({ | ||
| message: "Error creating error report", | ||
| error: (error as Error).message, |
There was a problem hiding this comment.
Avoid returning internal error messages to clients in production, as this can leak implementation details. Consider logging error.message internally and returning a generic error response instead.
| res.status(500).json({ | |
| message: "Error creating error report", | |
| error: (error as Error).message, | |
| console.error("Error creating error report:", (error as Error).message); | |
| res.status(500).json({ | |
| message: "Error creating error report", |
| type CreateErrorReportData = Omit< | ||
| ErrorDocument, | ||
| "_id" | "createdAt" | "updatedAt" | "status" | ||
| >; |
There was a problem hiding this comment.
[nitpick] The CreateErrorReportData type is duplicated between crudError.ts and the Redux slice. Consider centralizing this type in the shared types to prevent drift and ensure consistency.
| type CreateErrorReportData = Omit< | |
| ErrorDocument, | |
| "_id" | "createdAt" | "updatedAt" | "status" | |
| >; | |
| import { CreateErrorReportData } from "@polylink/shared/types"; |
📌 Summary
This PR implements a new error reporting system that allows users to submit detailed error reports when they encounter issues. The system includes a form component with validation, Redux state management, and backend integration.
🔍 Related Issues
Closes # (Please add the relevant issue number)
🛠 Changes Made
Frontend Changes
Created new
ReportErrorcomponent with:Enhanced
ErrorPagecomponent:Added Redux integration:
Backend Changes
Documentation
✅ Checklist
📸 Screenshots (if applicable)
The error reporting form is now integrated into the error page with a modern, user-friendly interface. The form includes:
❓ Additional Notes