Skip to content

Commit b282e37

Browse files
committed
Fix Agency search results
- Fixed agency endpoint - Return proper agency information - Adjust Agency info card rendering in search results
1 parent a135d80 commit b282e37

3 files changed

Lines changed: 35 additions & 16 deletions

File tree

frontend/app/search/SearchResults.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const SearchResults = ({ total, results }: SearchResultsProps) => {
3636
setAgencyLoading(true)
3737
try {
3838
// search by name for now
39-
const reponse = await searchAgencies({ name: currentQuery })
40-
setAgencyResults(Response.results || [])
41-
setAgencyTotal(Response.total || 0)
39+
const response = await searchAgencies({ name: currentQuery })
40+
setAgencyResults(response.results || [])
41+
setAgencyTotal(response.total || 0)
4242
} catch (error) {
4343
console.error('Agency search failed:', error)
4444
setAgencyResults([])
@@ -113,6 +113,7 @@ const SearchResults = ({ total, results }: SearchResultsProps) => {
113113
/>
114114
))}
115115
</CustomTabPanel>
116+
116117
<CustomTabPanel value={tab} index={3}>
117118
{agencyLoading ? (
118119
<Typography>Searching agencies...</Typography>
@@ -122,17 +123,16 @@ const SearchResults = ({ total, results }: SearchResultsProps) => {
122123
{agencyTotal} agency results
123124
</Typography>
124125
{agencyResults.map((result) => (
125-
126126
<CardHeader
127127
key={result.uid}
128-
title={result.title}
129-
subheader={result.subtitle}
128+
title={result.name}
129+
subheader={`${result.hq_city || 'Unknown City'}, ${result.hq_state || 'Unknown State'}`}
130130
slotProps={{ subheader: { fontWeight: "bold", color: "#000" } }}
131131
action={
132132
<Box sx={{ display: "flex", gap: "1rem" }}>
133-
<span style={{ fontSize: "12px", color: "#666" }}>{result.content_type}</span>
134-
<span style={{ fontSize: "12px", color: "#666" }}>{result.source}</span>
135-
<span style={{ fontSize: "12px", color: "#666" }}>{result.last_updated}</span>
133+
<span style={{ fontSize: "12px", color: "#666" }}>Agency</span>
134+
{result.jurisdiction && <span style={{ fontSize: "12px", color: "#666" }}>{result.jurisdiction}</span>}
135+
{result.website_url && <span style={{ fontSize: "12px", color: "#666" }}>{result.website_url}</span>}
136136
</Box>
137137
}
138138
sx={{

frontend/utils/api.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,31 @@ export interface AgenciesRequest extends AuthenticatedRequest {
137137

138138
export interface AgencyResponse {
139139
uid: string
140-
title: string
141-
subtitle: string
142-
content_type: string
143-
source: string
144-
last_updated: string
145-
// Could add other agency-specific fields here as needed
140+
name: string
141+
website_url?: string | null
142+
hq_address?: string | null
143+
hq_city?: string | null
144+
hq_state?: string | null
145+
hq_zip?: string | null
146+
phone?: string | null
147+
email?: string | null
148+
description?: string | null
149+
jurisdiction?: string | null
150+
units?: Array<{
151+
uid: string
152+
name: string
153+
website_url?: string | null
154+
phone?: string | null
155+
email?: string | null
156+
description?: string | null
157+
address?: string | null
158+
city?: string | null
159+
state?: string | null
160+
zip?: string | null
161+
agency_url?: string | null
162+
officers_url?: string | null
163+
date_established?: string | null
164+
}>
146165
}
147166

148167
export type AgenciesApiResponse = {

frontend/utils/apiRoutes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const API_ROUTES = {
1515
self: "/users/self"
1616
},
1717

18-
agencies: "/agencies"
18+
agencies: "/agencies/"
1919

2020
}
2121

0 commit comments

Comments
 (0)