Skip to content

Conversation

@jamesg8025
Copy link

@jamesg8025 jamesg8025 commented Oct 11, 2025

Implements agency tab functionality with dedicated '/agencies/' API endpoint.

  • Added agencies API route and interfaces
  • Implemented agency search in SearchProvider
  • Added agency results display in SearchResults component
  • Agency search does require exact case matching

@jamesg8025 jamesg8025 force-pushed the issue-478-add-agency-search-page branch from 14d219e to eba6116 Compare October 18, 2025 10:18
@jamesg8025 jamesg8025 force-pushed the issue-478-add-agency-search-page branch from eba6116 to c7e4f5f Compare November 15, 2025 09:52
@jamesg8025 jamesg8025 marked this pull request as ready for review November 15, 2025 10:00
@jamesg8025 jamesg8025 changed the title [WIP] Issue 478 add agency search page Issue 478 add agency search page Nov 15, 2025
@mikeyavorsky mikeyavorsky requested a review from cyng24 November 18, 2025 00:08
import { useSearchParams } from "next/navigation"
import { SearchResponse, AgencyResponse } from "@/utils/api"
import { useSearch } from "@/providers/SearchProvider"
import { useEffect } from "react"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this to line 3 to consolidate imports?

Comment on lines 25 to 43
useEffect(() => {
const performAgencySearch = async () => {
if (tab !== 3 || !currentQuery) return

setAgencyLoading(true)
try {
const response = await searchAgencies({ name: currentQuery })
setAgencyResults(response.results || [])
setAgencyTotal(response.total || 0)
} catch (error) {
console.error('Agency search failed:', error)
setAgencyResults([])
setAgencyTotal(0)
} finally {
setAgencyLoading(false)
}
}
performAgencySearch()
}, [currentQuery, tab, searchAgencies])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I'm going to be adding a unit search on the same page, I'm wondering if this is the best place to have all the logic.

Could you move performAgencySearch outside the useEffect and then do the tab check?

useEffect(() => {
   if (tab === 3) performAgencySearch();
   if (tab === other_tabs) performOtherTabSearch(); // so we can list all the functions clearly
}, [currentQuery, tab]);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also would probably be good to have a debounce for currentQuery changes so we aren't calling search for every keystroke.

Comment on lines +115 to +126
<CustomTabPanel value={tab} index={3}>
{agencyLoading ? (
<Typography>Searching agencies...</Typography>
) : (
<>
<Typography sx={{ marginBottom: "1rem", fontWeight: "bold" }}>
{agencyTotal} agency results
</Typography>
{agencyResults.map((result) => (
<CardHeader
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my other comment:
I'm wondering if we can move this into another component that can be customized according to what's being searched. That way we don't have all these hardcoded (by agency, but unit, etc) CustomTabPanels.

I don't know if you want to do this or I can make that change when I start my Unit Search task.

Add more debug logs to observe results data structure

Add Agency tab with basic result filtering

- Filter existing search results by content_type === 'Agency'
- Does not handle officer-to-agency searches yet

Add agencies API integration

Implement Agency tab with a dedicated agencies API endpoint

- Add /agencies endpoint to apiRoutes
- Add searchAgencies function to SearchProvider
- Update Agency tab to call agencies API when selected
- Encountered CORS error

Fix Agency search results
- Fixed agency endpoint
- Return proper agency information
- Adjust Agency info card rendering in search results

Add useEffect for reactive agency search state and remove debug logs
- Better scalability for future tab functions
- Also consolidated React imports
@jamesg8025 jamesg8025 force-pushed the issue-478-add-agency-search-page branch from c7e4f5f to adcd2f5 Compare December 17, 2025 03:40
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.

2 participants