Skip to content

feat(widget): submit issue reports to the SahajCloud endpoint #80

Closed

Description

@Ardnived

Summary

#79 ships the report-issue modal with its submit stubbed to an alert();
sydevs/SahajCloud#602 adds the shared POST /api/contact-admin. This connects
them: send the real request, parse the response, and give the viewer honest
success and failure states.

Blocked by #79 and sydevs/SahajCloud#602 — start once the endpoint is
deployed.

Proposed changes

  • Add contactAdmin to src/config/api/mutate.ts, posting to /contact-admin
    via the shared requestJson helper (a custom, non-CRUD endpoint — same shape
    as createRegistration) with subject: 'Issue report', parsing the response
    through a ContactResponseSchema per .claude/rules/data-layer.md.
  • Replace the TODO alert in ReportIssueForm with a TanStack useMutation,
    mirroring RegistrationForm's pending / error / thank-you states.
  • On failure show an inline Alert and keep the typed message so nothing is
    lost; on a captcha rejection (403) reset the Turnstile widget so the viewer can
    retry without reopening the modal.
  • Point VITE_TURNSTILE_SITE_KEY at the real production site key (Cloudflare
    dashboard) and document it in .claude/docs/environment.md; keep the test key
    for dev / Ladle / CI.
  • Refresh the CMS contract (pnpm types:cms, pnpm types:openapi) so the
    endpoint's response type is in sync.

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
  • A successful report shows the thank-you state, and an email actually
    arrives at [email protected] (verified once against the deployed
    backend)
  • A server error shows an inline error, keeps the typed message, and allows a
    retry; a 403 (captcha) resets the Turnstile widget in place
  • The temporary alert() and its TODO are gone
  • Error / success strings exist in every locale
  • Lint + typecheck + pnpm test:run pass; the mutation is covered by a unit
    test with the request layer mocked

Files affected

  • src/config/api/mutate.ts, src/types/report.ts
  • src/components/organisms/ReportIssueForm/ReportIssueForm.tsx
  • .env, .claude/docs/environment.md, public/locales/*/common.json

References

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