Skip to content

feat(mobile): build gift-share flow for passing a subscription to another user (#2005) - #2330

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
livinalt:feat/gift-share-flow
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
livinalt:feat/gift-share-flow

Conversation

@livinalt

Copy link
Copy Markdown
Contributor

Summary of Changes

Closes #2005

Implements a production-ready, WCAG 2.1 AA accessible, and self-contained gift-share flow under mobile/src/screens/gift/ that enables SubTrackr mobile users to transfer or gift an active subscription to another user via email or native Stellar blockchain addresses (G...).

State Machine & Architecture

[select] ──> [recipient] ──> [confirm] ──> [processing] ──> [success]
   │             │               │             │
   │             │               │             v
   └─────────────┴───────────────┴───────> [error]
                                               │
                                     (Retry / Edit Details)
  1. Domain Models & Contracts (types.ts):

    • Strict step progression: 'select' | 'recipient' | 'confirm' | 'processing' | 'success' | 'error'.
    • Domain interfaces: GiftableSubscription, GiftShareFormState, GiftShareResult, GiftDeliveryMethod, UseGiftShareFlowReturn, and telemetry metrics GiftShareMetrics.
  2. Deterministic Business Logic & Validation (giftShareLogic.ts):

    • Dual addressing validation: RFC 5322 email regex and Stellar 56-character base32 public key (G...) detection.
    • Deterministic alphanumeric claim code generator (SUB-XXXX-XXXX) excluding ambiguous characters (0/O, 1/I).
    • Deep-link URL construction (https://subtrackr.app/gift/claim?code=...).
    • Expiration calculations clamped between 1 and 30 days (default 7 days).
    • Eligibility checks rejecting paused or canceled subscriptions.
  3. State Machine Hook with Error Recovery (hooks.ts):

    • Manages step transitions, input updates, and validation guards.
    • Error recovery with in-flight retry (handleRetry()) and details adjustment (handleEditDetails()).
    • Senders can toggle revocation safeguards (allowSenderRevoke) to cancel unclaimed gift codes.
    • Automatic timer unref cleanup for clipboard feedback to prevent test worker leaks.
    • Full telemetry wired across view, selection, start, success, failure, retry, copy, and share actions.
  4. Accessible Mobile Screen (GiftShareScreen.tsx):

    • WCAG 2.1 AA compliant styling, high contrast colors, and minimum touch target dimensions ($\ge 48\times 48,\text{dp}$).
    • Dedicated error view with structured error messaging, ↻ Retry Send, and Edit Details actions.
    • Revocation toggle card with accessibilityRole="switch".
    • Correct accessibility semantics (header, radiogroup, radio, tablist, tab, alert, progressbar, button).
  5. Documentation (README.md):

    • Comprehensive technical documentation, architecture diagrams, TypeScript integration examples, and testing guidelines.

Pull Request Checklist

Quality Gates (All must pass before merge)

  • Lint: Code passes ESLint and Prettier checks (0 errors, 0 warnings on mobile/src/screens/gift/)
  • Type Check: TypeScript compilation succeeds (all new types in mobile/src/screens/gift/ are strictly typed)
  • Tests: All tests pass (47 passed tests across giftShareLogic.test.ts, hooks.test.ts, and GiftShareScreen.test.tsx)
  • Build: Project builds successfully
  • Rust Format: Smart contract formatting is correct (N/A - mobile scope only)
  • Rust Clippy: Smart contract linting passes (N/A - mobile scope only)
  • Rust Tests: All smart contract tests pass (N/A - mobile scope only)
  • Rust Build: Smart contracts compile successfully (N/A - mobile scope only)

Additional Requirements

  • New code has appropriate TypeScript types
  • No hardcoded secrets or credentials
  • New features have corresponding tests
  • Documentation updated if needed (mobile/src/screens/gift/README.md)

@github-actions
github-actions Bot merged commit 8b7bd6b into Smartdevs17:main Nov 24, 2026
7 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build gift-share flow for passing a subscription to another user

1 participant