Skip to content

BuyPolicyModal: crop oracle key shows computed key preview but provides no rainfall preview fetch #148

Description

@nonsobethel0-dev

Summary

src/components/BuyPolicyModal.tsx shows the computed oracle key for crop policies (e.g., rainfall:1.5,36.8:2026-06) in a read-only preview at line 209-213, but never fetches or displays the actual historical rainfall data for that location and period.

src/lib/api.ts line 146-150 already exposes fetchRainfallPreview(lat, lng, year, month):

export function fetchRainfallPreview(
  lat: number, lng: number, year: number, month: number,
): Promise<{ value: string; confidence: number }> {
  return get('/oracle/rainfall', { params: { lat, lng, year, month } });
}

Without showing this data in the modal, a user buying a rainfall parametric policy has no indication of what the historical baseline is for their chosen location and month. They cannot verify whether the oracle conditions are likely to trigger.

Acceptance criteria

  • When a crop policy's lat/lng/year/month inputs are complete, the modal fetches and displays the fetchRainfallPreview result inline (e.g., "Avg rainfall: 45.2 mm · Confidence: 87%")
  • A loading spinner is shown while the preview loads
  • If the preview API returns an error, a non-blocking warning is shown (not a blocking error)
  • The preview updates whenever lat, lng, year, or month changes (debounced)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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