Skip to content

feat: Implement React Query hooks for managing bounties - #30

Merged
0xdevcollins merged 1 commit into
boundlessfi:mainfrom
Dprof-in-tech:feta-create-custom-react-query-hooks
Jan 25, 2026
Merged

feat: Implement React Query hooks for managing bounties#30
0xdevcollins merged 1 commit into
boundlessfi:mainfrom
Dprof-in-tech:feta-create-custom-react-query-hooks

Conversation

@Dprof-in-tech

@Dprof-in-tech Dprof-in-tech commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces a new set of React Query hooks for managing bounties, including fetching, updating, deleting, and infinite scrolling of bounty data. The changes modularize and streamline bounty-related data fetching and mutations, making the codebase more maintainable and improving the developer experience when working with bounty features.

New React Query hooks for bounties:

  • Added useBounties for fetching paginated lists of bounties, along with a shared bountyKeys utility for consistent query keys.
  • Added useBounty for fetching a single bounty by ID with optional query enabling.
  • Added useInfiniteBounties for infinite scrolling of bounty lists, including a helper to flatten paginated results.

Mutation hooks for bounties:

  • Added useCreateBounty, useUpdateBounty, useDeleteBounty, and useClaimBounty hooks for creating, updating (with optimistic updates), deleting (with optimistic removal and rollback), and claiming bounties, all with appropriate cache invalidation and updates.

closes #28

Summary by CodeRabbit

  • New Features
    • Added bounty management capabilities including create, update, delete, and claim operations.
    • Introduced pagination and infinite scroll support for bounty browsing.
    • Enhanced caching and optimistic UI updates for improved performance and responsiveness.

✏️ Tip: You can customize this high-level summary in your review settings.

…ching, infinite listing, and CRUD operations.
@coderabbitai

coderabbitai Bot commented Jan 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request introduces four custom React Query hook modules for bounty data management. The changes create reusable hooks for fetching bounty lists, single bounties, and performing mutations (create, update, delete, claim), alongside support for infinite pagination and cache key management.

Changes

Cohort / File(s) Summary
Query Hooks
hooks/use-bounties.ts, hooks/use-bounty.ts, hooks/use-infinite-bounties.ts
Introduces query hooks for fetching bounties: useBounties(params?) for paginated lists with configurable parameters, useBounty(id, options?) for single bounty fetching with optional enabled flag, and useInfiniteBounties(params?) for infinite scroll pagination. Defines bountyKeys namespace for consistent query key management across all bounty queries. Includes flattenBountyPages() helper to flatten paginated responses.
Mutation Hooks
hooks/use-bounty-mutations.ts
Adds four mutation hooks: useCreateBounty() for creating new bounties with list cache invalidation, useUpdateBounty() with optimistic UI updates and cache restoration on error, useDeleteBounty() with optimistic list modifications, and useClaimBounty() for claiming bounties. All mutations integrate with shared query client and implement appropriate cache invalidation and rollback strategies.

Sequence Diagram(s)

sequenceDiagram
    actor Component
    participant Query as React Query Hook
    participant Client as Query Client
    participant API as Bounties API
    
    Component->>Query: useBounties(params) / useBounty(id)
    Query->>Client: Check cache with bountyKeys
    alt Cache Hit
        Client-->>Query: Return cached data
    else Cache Miss
        Query->>API: bountiesApi.list(params) / getById(id)
        API-->>Query: Return Bounty data
        Query->>Client: Update cache
    end
    Query-->>Component: Return loading, error, data state
Loading
sequenceDiagram
    actor Component
    participant Mutation as Mutation Hook
    participant Client as Query Client
    participant API as Bounties API
    
    Component->>Mutation: useCreateBounty() / useUpdateBounty() / useDeleteBounty()
    Mutation->>Client: onMutate: Save previous data
    Client-->>Mutation: Return rollback context
    Mutation->>Client: Optimistic update (if applicable)
    Mutation->>API: Call API endpoint
    alt Success
        API-->>Mutation: Success response
        Mutation->>Client: Invalidate bountyKeys
    else Error
        Mutation->>Client: Rollback to previous data
    end
    Mutation-->>Component: Return mutation state (status, data, error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops through the bounty cache with glee,
Queries and mutations now flow so free,
Optimistic updates make the UI dance,
Keys are nested, data's well-maintained—
React Query hooks, a developer's chance!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: implementing React Query hooks for managing bounties, which aligns with all files added in the changeset.
Linked Issues check ✅ Passed All coding requirements from issue #28 are met: all four hook files created, optimistic updates implemented in mutations, query invalidation present, and comprehensive TypeScript typing throughout.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #28 objectives. The four new hook files and their implementations match the specified requirements with no extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@0xdevcollins

Copy link
Copy Markdown
Contributor

LGTM 🚀

@0xdevcollins
0xdevcollins merged commit 8af055a into boundlessfi:main Jan 25, 2026
2 checks passed
0xDeon pushed a commit to 0xDeon/bounties that referenced this pull request Jan 26, 2026
…om-react-query-hooks

feat: Implement React Query hooks for managing bounties
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.

Create Custom React Query Hooks

2 participants