Some checks failed
Formulaire in-app de remontée de bug / suggestion pour les utilisateurs connectés (PR 1/2 de l'issue #80). - Modèle Prisma `ContactMessage` (+ relation inverse sur `UserProfile`) et migration `20260908120000_contact_message` — table neuve, aucun backfill. `authorId` nullable + `onDelete: SetNull` : un signalement survit à la suppression de son compte. - Contrat partagé `schemas/contact.ts` : `CONTACT_MESSAGE_TYPES`, `submitContactMessageSchema` (type enum, message 10-5000 trim, pageUrl / appVersion optionnels — jamais le user-agent). - Module API `contact` : `POST /contact` (`requireAuth`, monté `/contact`), `204` sans corps. Le user-agent est lu de l'en-tête de requête, jamais du corps. Émet `analytics.recordEvent(contact.submitted, …)`. - Page `/parametres/contact` (`ContactPage` + `contact.ts` + `.scss`) : select de type, textarea, validation cliente via le schéma partagé, états succès / erreur (`ErrorMessageService`, jamais `err.message`). Entrée de nav « Nous contacter » dans `SETTINGS_ITEMS` + clé i18n + icône. `apiClient.submitContactMessage(input)` ajoute `pageUrl` / `appVersion`. - Tests : `apps/api/test/contact.test.ts` (Mocha — insertion, en-tête UA, champs nullables, message trop court / trop long, type inconnu), `contact.feature` + steps (Cypress e2e — envoi + confirmation + contexte), `contact-page.cy.ts` (rendu + garde `RequireAuth` + label d'erreur). - Docs : `batch-cooking-modele.md`, `backend-architecture.md`, `frontend-architecture.md`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
25 lines
947 B
TypeScript
25 lines
947 B
TypeScript
import type { ContactMessageType, SubmitContactMessageInput } from "@batch-cooking/shared";
|
|
|
|
/**
|
|
* Builds the `POST /contact` payload (issue #80) from the two things the
|
|
* user picked in the form — the message `type` and its text — plus the two
|
|
* pieces of context captured automatically: the path they're on
|
|
* (`window.location.pathname`) and the running app version
|
|
* (`__APP_VERSION__`, injected by `vite.config.ts`). Kept out of
|
|
* `ContactPage` so those ambient reads sit in one unit-testable place.
|
|
*
|
|
* The user-agent is deliberately NOT set here — the API reads it straight
|
|
* from the request header, never trusting the client for it (see
|
|
* `submitContactMessageSchema`, which omits it).
|
|
*/
|
|
export function buildContactMessageInput(
|
|
type: ContactMessageType,
|
|
message: string,
|
|
): SubmitContactMessageInput {
|
|
return {
|
|
type,
|
|
message,
|
|
pageUrl: window.location.pathname,
|
|
appVersion: __APP_VERSION__,
|
|
};
|
|
}
|