Skip to content

Commit

Permalink
updated queries with new fetch format
Browse files Browse the repository at this point in the history
  • Loading branch information
ermish authored and NabbeunNabi committed Mar 11, 2024
1 parent 4aaf272 commit df486cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions stores/locationsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async function queryFacilities(): Promise<Facility[]> {
} satisfies FacilitySearchFilters
}

const result = await gqlClient.request<Facility[]>(searchFacilitiesQuery, searchFacilitiesData)
return result
const result = await gqlClient.request<{ facilities: Facility[] }>(searchFacilitiesQuery, searchFacilitiesData)
return result?.facilities ?? []
} catch (error) {
console.log(`Error getting facilities for dropdown: ${JSON.stringify(error)}`)
alert(`Error getting data! Please contact our support team by clicking the bottom right link on the page!`)
Expand Down
13 changes: 7 additions & 6 deletions stores/searchResultsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ async function queryProfessionals(searchSpecialty?: Specialty, searchLanguage?:
}

console.log('searching professionals')
const response = await gqlClient.request<HealthcareProfessional[]>(searchProfessionalsQuery, searchProfessionalsData)
const professionalsSearchResult = (response ?? []) as HealthcareProfessional[]
console.log(`Fetched professionals: ${JSON.stringify(professionalsSearchResult)}`)
const response = await gqlClient.request<{ healthcareProfessionals: HealthcareProfessional[] }>(searchProfessionalsQuery, searchProfessionalsData)
console.log(`Fetched professionals: ${JSON.stringify(response)}`)

const professionalsSearchResult = (response?.healthcareProfessionals ?? []) as HealthcareProfessional[]
return professionalsSearchResult
} catch (error) {
console.log(`Error getting professionals: ${JSON.stringify(error)}`)
Expand Down Expand Up @@ -119,9 +120,9 @@ async function queryFacilities(healthcareProfessionalIds: string[], searchCity?:
}

console.log('searching facilities')
const response = await gqlClient.request<Facility[]>(searchFacilitiesQuery, searchFacilitiesData)
const facilitiesSearchResults = (response ?? []) as Facility[]
console.log(`Fetched facilities: ${JSON.stringify(facilitiesSearchResults)}`)
const response = await gqlClient.request<{ facilities: Facility[] }>(searchFacilitiesQuery, searchFacilitiesData)
console.log(`Fetched facilities: ${JSON.stringify(response)}`)
const facilitiesSearchResults = (response?.facilities ?? []) as Facility[]

//filter the search results by location if a location is selected
const locationFilteredSearchResults = searchCity
Expand Down

0 comments on commit df486cb

Please sign in to comment.