-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VACMS-18444 Facility Locator: add click functionality for mobile map markers #34362
base: main
Are you sure you want to change the base?
Changes from all commits
f516816
a88a46b
63204dc
a18ad5d
e74b785
c38a813
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { focusElement } from 'platform/utilities/ui'; | ||
import { resultMapper } from '../utils/resultMapper'; | ||
|
||
const MobileMapSearchResult = ({ mobileMapPinSelected, query }) => { | ||
const headerRef = useRef(null); | ||
|
||
useEffect( | ||
() => { | ||
if (headerRef?.current) { | ||
focusElement(headerRef.current); | ||
} | ||
}, | ||
[headerRef], | ||
); | ||
|
||
return ( | ||
<> | ||
{!mobileMapPinSelected && ( | ||
<p className="vads-u-margin-y--3"> | ||
Select a number to show information about that location. | ||
</p> | ||
)} | ||
{mobileMapPinSelected && ( | ||
<div className="mobile-search-result"> | ||
{resultMapper(mobileMapPinSelected, query, 0)} | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
MobileMapSearchResult.propTypes = { | ||
mobileMapPinSelected: PropTypes.object, | ||
query: PropTypes.object, | ||
}; | ||
|
||
export default MobileMapSearchResult; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,12 @@ | |
import PropTypes from 'prop-types'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
|
||
import DelayedRender from 'platform/utilities/ui/DelayedRender'; | ||
import { facilityTypes } from '../config'; | ||
import { | ||
CLINIC_URGENTCARE_SERVICE, | ||
PHARMACY_RETAIL_SERVICE, | ||
LocationType, | ||
Error, | ||
Covid19Vaccine, | ||
EMERGENCY_CARE_SERVICES, | ||
} from '../constants'; | ||
|
||
import { Error } from '../constants'; | ||
import { recordSearchResultsEvents } from '../utils/analytics'; | ||
import { resultMapper } from '../utils/resultMapper'; | ||
import { updateSearchQuery, searchWithBounds } from '../actions'; | ||
|
||
import VaFacilityResult from './search-results-items/VaFacilityResult'; | ||
import CCProviderResult from './search-results-items/CCProviderResult'; | ||
import PharmacyResult from './search-results-items/PharmacyResult'; | ||
import UrgentCareResult from './search-results-items/UrgentCareResult'; | ||
import EmergencyCareResult from './search-results-items/EmergencyCareResult'; | ||
import Covid19Result from './search-results-items/Covid19Result'; | ||
import SearchResultMessage from './SearchResultMessage'; | ||
|
||
export const ResultsList = ({ | ||
|
@@ -53,7 +38,7 @@ | |
})), | ||
); | ||
}, | ||
[results], | ||
Check warning on line 41 in src/applications/facility-locator/components/ResultsList.jsx GitHub Actions / Linting (Files Changed)
|
||
); | ||
|
||
useEffect( | ||
|
@@ -62,20 +47,9 @@ | |
recordSearchResultsEvents(props, resultsData); | ||
} | ||
}, | ||
[resultsData], | ||
Check warning on line 50 in src/applications/facility-locator/components/ResultsList.jsx GitHub Actions / Linting (Files Changed)
|
||
); | ||
|
||
function isHealthAndHealthConnect(apiResult, searchQuery) { | ||
let final = false; | ||
if ( | ||
searchQuery?.facilityType === 'health' && | ||
apiResult?.attributes?.phone?.healthConnect !== null | ||
) { | ||
final = true; | ||
} | ||
return final; | ||
} | ||
|
||
/** | ||
* Returns Result items by type | ||
* @param query object | ||
|
@@ -84,119 +58,7 @@ | |
*/ | ||
const renderResultItems = (searchQuery, apiResults) => { | ||
return apiResults?.map((result, index) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved the |
||
let item; | ||
const showHealthConnectNumber = isHealthAndHealthConnect(result, query); | ||
|
||
switch (searchQuery.facilityType) { | ||
case 'health': | ||
case 'cemetery': | ||
case 'benefits': | ||
case 'vet_center': | ||
item = | ||
searchQuery.serviceType === Covid19Vaccine ? ( | ||
<Covid19Result location={result} key={result.id} index={index} /> | ||
) : ( | ||
<VaFacilityResult | ||
location={result} | ||
query={searchQuery} | ||
key={result.id} | ||
index={index} | ||
showHealthConnectNumber={showHealthConnectNumber} | ||
/> | ||
); | ||
break; | ||
case 'provider': | ||
// Support non va urgent care search through ccp option | ||
if (searchQuery.serviceType === CLINIC_URGENTCARE_SERVICE) { | ||
item = ( | ||
<UrgentCareResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
} else if (searchQuery.serviceType === PHARMACY_RETAIL_SERVICE) { | ||
item = ( | ||
<PharmacyResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
} else if ( | ||
EMERGENCY_CARE_SERVICES.includes(searchQuery.serviceType) | ||
) { | ||
item = ( | ||
<EmergencyCareResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
} else { | ||
item = ( | ||
<CCProviderResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
} | ||
break; | ||
case 'pharmacy': | ||
item = ( | ||
<PharmacyResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
break; | ||
case 'emergency_care': | ||
if (result.type === LocationType.CC_PROVIDER) { | ||
item = ( | ||
<EmergencyCareResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
} else { | ||
item = ( | ||
<VaFacilityResult | ||
location={result} | ||
query={searchQuery} | ||
key={result.id} | ||
index={index} | ||
/> | ||
); | ||
} | ||
break; | ||
case 'urgent_care': | ||
if (result.type === LocationType.CC_PROVIDER) { | ||
item = ( | ||
<UrgentCareResult | ||
provider={result} | ||
query={searchQuery} | ||
key={result.id} | ||
/> | ||
); | ||
} else { | ||
item = ( | ||
<VaFacilityResult | ||
location={result} | ||
query={searchQuery} | ||
key={result.id} | ||
index={index} | ||
/> | ||
); | ||
} | ||
break; | ||
default: | ||
item = null; | ||
} | ||
|
||
return item; | ||
return resultMapper(result, searchQuery, index); | ||
}); | ||
}; | ||
|
||
|
@@ -304,7 +166,6 @@ | |
pagination: state.searchResult.pagination, | ||
position, | ||
searchString, | ||
selectedResult: state.searchResult.selectedResult, | ||
resultTime: state.searchResult.resultTime, | ||
}; | ||
} | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this function to a utility file as it is now shared between
ResultsList
(used for desktop and the list view on mobile) andSearchResult
(used for the single listing on mobile map view)