Skip to content

fix(event): deliver report-issue submissions instead of alerting #103

Closed

Description

@Ardnived

Summary

The report-issue form validates, passes a real Turnstile challenge, then window.alert(JSON.stringify(payload, null, 2)) and shows the localized "sent" confirmation (src/components/organisms/ReportIssueForm/ReportIssueForm.tsx:118-121, the TODO(#80)). Nothing reaches any server — yet ERROR_POLICY routes viewers to this CTA as the designated last resort on four of six failure kinds (server/config/contract/unknown). When the widget breaks on a host page, the "report" is a JSON alert dialog, and the UI claims success anyway. Ship-blocker 4 in the release-readiness review (§9: "zero production error signal").

Status check (2026-08-06): the backend has landed. sydevs/SahajCloud#602 ("feat(api): add a captcha-gated contact-admin endpoint") closed 2026-08-04. The shared POST /api/contact-admin is client-key gated, Turnstile-verified server-side, and emails [email protected] with the sender's address as Reply-To; the body contract is { message (10..5000), email?, subject? (<=200), turnstileToken, context? { path, hostUrl, locale, error, userAgent } }. So the primary path here is the real mutation. Open issue #80 already sketches exactly this wiring and remains the reference plan — this ticket carries it as a release blocker, and the implementing PR should close both (Closes #80 in the PR body).

Proposed changes

  • Confirm the endpoint is deployed on the target backend (VITE_SAHAJCLOUD_URL, default https://cloud.sydevelopers.com) — #602 is merged; deployment is the remaining unknown.
  • If deployed (expected): wire the real mutation per feat(widget): submit issue reports to the SahajCloud endpoint #80's plan —
    • contactAdmin in src/config/api/mutate.ts via the requestJson helper (custom non-CRUD endpoint, same shape as createRegistration), sending subject: 'Issue report'; parse the response through a zod schema per .claude/rules/data-layer.md.
    • Replace the alert with a TanStack useMutation: pending / error / thank-you states mirroring RegistrationForm. On failure show an inline Alert and keep the typed message so nothing is lost; on a 403 (captcha rejection) reset the Turnstile widget in place so the viewer can retry without reopening the modal.
  • If NOT deployed: ship the interim instead — route submission through the existing mailto fallback (the Turnstile-blocked branch already renders mailto:[email protected]; ReportIssueForm.tsx:187-191, degraded-state contract documented in src/hooks/use-turnstile.ts:80-85) so a submission ALWAYS goes somewhere real. Never show the "sent" confirmation for something that wasn't delivered.
  • Security note (carry forward from commit 368e1f7): ReportContext.error is the thrown message — attacker-influenceable text, capped at 500 chars (src/lib/report.ts:233 MAX_ERROR_LENGTH, applied at :255). Anywhere it is forwarded, ENCODE it: the onward email template must not interpolate it raw (coordinate with SahajCloud's template if needed), and any client-built mailto: URL must encodeURIComponent every interpolated field.

Acceptance criteria

  • Submitting the form POSTs to /api/contact-admin with the client API key attached by the shared request context (no ad-hoc auth handling), and the response is parsed through a zod schema — OR, if the endpoint is confirmed undeployed, the submit path degrades to the mailto route and says so honestly
  • The window.alert and its TODO(#80) are gone; no code path shows the "sent" state without a real delivery
  • Failure keeps the typed message and allows retry; a 403 resets the Turnstile widget without reopening the modal
  • The thrown message (ReportContext.error) is encoded, never raw-interpolated, in anything mailed onward or built into a mailto: URL
  • New user-facing strings exist in every locale (via pnpm i18n:add)
  • A unit test covers the submit path with the request layer mocked at the boundary (vi.mock + vi.hoisted, per .claude/rules/tests.md)
  • pnpm lint && pnpm typecheck && pnpm test:run pass
  • The implementing PR closes feat(widget): submit issue reports to the SahajCloud endpoint #80 alongside this issue
  • Write an implementation report to .claude/reports/<issue-number>-<short-slug>.md — in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved.

Files affected

  • src/components/organisms/ReportIssueForm/ReportIssueForm.tsx (the only owned file)
  • Strictly additive only: a new contactAdmin export in src/config/api/mutate.ts, a new response schema in src/types/, new locale keys under public/locales/*/
  • src/lib/report.ts is owned by a sibling ticket — if a type tweak there is unavoidable, keep it strictly additive

Parallel implementation: this ticket OWNS ReportIssueForm.tsx; sibling release-hardening tickets run concurrently — avoid edits outside owned files except strictly additive ones. (The pnpm lockfile is shared between two sibling tickets; conflicts there are expected and resolved by re-running pnpm install — this ticket should not need to touch it.)

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions