Skip to content

[Web UI] Add explicit types to useFilterState hook #120

@santoshkumarradha

Description

@santoshkumarradha

Summary

The useFilterState hook returns a tuple or object with various filter state values and functions, but the return type may not be fully typed, reducing IDE support and type safety.

Current State

  • File: control-plane/web/client/src/hooks/useFilterState.ts
  • Issue: Return type may use inferred types or any

Tasks

  1. Define explicit interface for hook return value
  2. Type all state values and setter functions
  3. Export types for consumer components to use

Example Implementation

// Define the return type interface
export interface FilterState {
  filters: FilterTag[];
  setFilters: React.Dispatch<React.SetStateAction<FilterTag[]>>;
  addFilter: (filter: FilterTag) => void;
  removeFilter: (filterId: string) => void;
  clearFilters: () => void;
  hasActiveFilters: boolean;
}

// Apply to hook
export function useFilterState(initialFilters?: FilterTag[]): FilterState {
  // ... implementation
  
  return {
    filters,
    setFilters,
    addFilter,
    removeFilter,
    clearFilters,
    hasActiveFilters,
  };
}

Acceptance Criteria

  • Return type interface defined and exported
  • Hook return type explicitly annotated
  • All consumer components get proper type inference
  • TypeScript compilation passes
  • Linting passes (npm run lint)

Files

  • control-plane/web/client/src/hooks/useFilterState.ts

Using AI to solve this issue? Read our AI-Assisted Contributions guide for testing requirements, prompt strategies, and common pitfalls to avoid.

Metadata

Metadata

Assignees

Labels

area:web-uiReact web UI functionalitygood first issueGood for newcomerstype-safetyTypeScript or Python type improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions