Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes issues related to updating partner reviews by adding functionality to resend verification emails for unverified reviews and improving the admin interface to properly handle email verification status.
Changes:
- Added a new API endpoint and service function to resend verification emails for unverified reviews
- Updated the admin UI to display email verification status and conditionally show either a "resend verification email" or "save" button
- Modified the mapper logic to show all reviews (including unverified ones) to admin users
- Updated Node.js version from 22 to 24 in .nvmrc to match package.json engines field
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| .nvmrc | Updates Node.js version from 22 to 24, aligning with package.json engines specification |
| server/lib/partenaire-de-la-charte/reviews/service.ts | Adds resendVerificationEmail function and trailing comma fixes |
| server/lib/partenaire-de-la-charte/reviews/mapper.ts | Changes admin view to show all reviews instead of filtering to only email-verified ones |
| server/lib/partenaire-de-la-charte/reviews/controller.ts | Adds GET endpoint for resending verification emails with proper error handling |
| pages/partenaires-de-la-charte/[id].tsx | Adds frontend function to resend verification emails and conditional UI rendering based on verification status |
| components/partenaires-de-la-charte/reviews/reviews-table.tsx | Adds "Email vérifié" column header to reviews table |
| components/partenaires-de-la-charte/reviews/review-item.tsx | Displays email verification status badge in review list |
Comments suppressed due to low confidence (1)
server/lib/partenaire-de-la-charte/reviews/service.ts:79
- The updateReview function allows setting isPublished to true even when isEmailVerified is false. While the frontend (pages/partenaires-de-la-charte/[id].tsx:250) disables the publish checkbox for unverified emails, the backend should also validate this to prevent direct API calls from bypassing this business rule. Consider adding a check: if (payload.isPublished && !review.isEmailVerified) throw new Error("Cannot publish unverified review").
export async function updateReview(reviewId: string, payload: any) {
const review = await findOneOrFail(reviewId);
review.isPublished = payload.isPublished;
review.reply = payload.reply;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ); | ||
| } catch (error) { | ||
| Logger.error( | ||
| `Une erreur est survenue lors de l'envoie de la notification de review`, |
There was a problem hiding this comment.
The error message contains a grammatical error in French. "l'envoie" should be "l'envoi". "Envoie" is a verb conjugation (he/she sends), while "envoi" is the noun (the sending/shipment).
| @@ -76,7 +97,7 @@ export async function verifyEmail(reviewId: string, token: string) { | |||
| } catch (error) { | |||
| Logger.error( | |||
| `Une erreur est survenue lors de l'envoie de la notification de review`, | |||
There was a problem hiding this comment.
The error message contains a grammatical error in French. "l'envoie" should be "l'envoi". "Envoie" is a verb conjugation (he/she sends), while "envoi" is the noun (the sending/shipment).
| await fetch( | ||
| `/api/partenaires-de-la-charte/reviews/${selectedReview.id}/resend-verification-email`, | ||
| ); |
There was a problem hiding this comment.
The fetch call does not check the response status. If the API returns an error response (4xx or 5xx), the try block will still execute and show a success toast message to the user. The response should be checked using a pattern similar to other API calls in this file, or by using the processResponse helper function pattern seen in lib/partenaires-de-la-charte.ts.
| await fetch( | |
| `/api/partenaires-de-la-charte/reviews/${selectedReview.id}/resend-verification-email`, | |
| ); | |
| const response = await fetch( | |
| `/api/partenaires-de-la-charte/reviews/${selectedReview.id}/resend-verification-email`, | |
| ); | |
| if (!response.ok) { | |
| let message = ""; | |
| try { | |
| message = await response.text(); | |
| } catch { | |
| // ignore body parsing errors and fall back to generic message | |
| } | |
| throw new Error( | |
| message || `HTTP error ${response.status} while resending verification email`, | |
| ); | |
| } |
| ); | ||
| } catch (error) { | ||
| Logger.error( | ||
| `Une erreur est survenue lors de l'envoie de la notification de review`, |
There was a problem hiding this comment.
The error message contains a grammatical error in French. "l'envoie" should be "l'envoi". "Envoie" is a verb conjugation (he/she sends), while "envoi" is the noun (the sending/shipment).
No description provided.