Skip to content

Build the stream-creation form and wire it to POST /api/v2/streams #331

@greatest0fallt1me

Description

@greatest0fallt1me

Description

The streams list advertises a "Create Stream" / "Create Your First Stream" call to action in app/streams/StreamsPageContent.tsx, but no creation UI exists — the buttons lead nowhere and the page renders only mockStreams. Meanwhile the backend is ready: POST /api/v2/streams (app/api/v2/streams/route.ts) accepts { recipient, rate, schedule, token }, runs shared field validation through validateCreateStreamBody (app/lib/stream-validation.ts), and returns the v2 stream shape on 201. This issue adds a client form that collects those fields, mirrors the server validation rules, and submits via the existing idempotent API client.

Requirements and context

  • Add a stream-creation form (e.g. app/streams/new/page.tsx plus a StreamForm component) with fields for recipient, rate, schedule, and optional token.
  • Submit using fetchWithIdempotency from lib/apiClient.ts (it already injects the Idempotency-Key header for mutating requests) to POST /api/v2/streams.
  • Client-side validation must mirror validateCreateStreamBody: required recipient validated as a Stellar public key, rate a positive decimal with at most 7 decimal places, and schedule one of SUPPORTED_SCHEDULES (secondyear).
  • Render the field-level 422 VALIDATION_ERROR details[] returned by the route next to the corresponding inputs, and surface non-422 failures via the existing ErrorToast/ErrorBanner components.
  • Non-functional: disable submit while in flight, show a busy state, and on 201 route the user to the created stream's detail page.

Acceptance criteria

  • A creation form collects recipient, rate, schedule, and optional token and posts to /api/v2/streams via fetchWithIdempotency.
  • Client validation matches validateCreateStreamBody rules (public-key recipient, positive 7-dp rate, allowed schedule).
  • Server 422 field errors map to the right inputs; other errors render through ErrorToast/ErrorBanner.
  • The "Create Stream" CTAs in StreamsPageContent navigate to the form.
  • Submit is disabled while pending and the user is routed to the new stream on success.
  • Tests cover valid submit, a field-level validation failure, and a server-error path.

Suggested execution

1. Fork the repo and create a branchgit checkout -b feature/stream-creation-form.

2. Implement changes — add app/streams/new/page.tsx and a StreamForm component under app/components/, importing SUPPORTED_SCHEDULES from app/lib/stream-validation.ts and isValidStellarPublicKey from app/lib/wallet-link.ts.

3. Write/extend tests — add a StreamForm.test.tsx next to the component (Jest + Testing Library, mocking fetchWithIdempotency), following the harness style in app/streams/page.test.tsx and app/components/Modal.test.tsx.

4. Test and commit

npm test
npm run lint
npm run build

Example commit message

feat(streams): add stream-creation form wired to POST /api/v2/streams

Guidelines

Touched modules must reach >=90% line coverage. All inputs need associated <label>s and aria-describedby error wiring, and the README route table / openapi.json create flow should be referenced in the component docs. Timeframe: 96 hours.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions