Skip to content

Create TanStack Query hooks for categories #21

@RossCabrera

Description

@RossCabrera

Overview

Create custom React Query (TanStack Query) hooks for categories management
with caching and optimistic updates.

Hooks to Create

useCategories()

  • Fetches all categories for user
  • Caches data
  • Refetches on window focus
  • Returns: { data, isLoading, error }

useCreateCategory()

  • Mutation for creating category
  • Returns: { mutate, isPending, error }
  • Invalidates categories list

useUpdateCategory(id)

  • Mutation for updating category
  • Optimistic update
  • Returns: { mutate, isPending, error }

useDeleteCategory(id)

  • Mutation for deleting category
  • Handles cascade (sets notes.category to NULL)
  • Returns: { mutate, isPending, error }

Acceptance Criteria

  • Hooks use TanStack Query
  • Data cached automatically
  • Refetching works
  • Optimistic updates work
  • Error handling works
  • Mutations invalidate cache
  • Deleting category handled
  • Works with axios interceptors
  • TypeScript support

Related Issues

Metadata

Metadata

Assignees

Labels

TaskGeneral work that doesn’t directly add features or fix bugs (maintenance, updates, setup tasks).

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions