Skip to content
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 19548 - orientation of map and controls for Facility Locator #33609

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f2c03f1
update controls
eselkin Dec 16, 2024
e277aa6
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 16, 2024
af69361
fix resize
eselkin Dec 18, 2024
4e5ebec
fix radius
eselkin Dec 20, 2024
1417715
cleanup lock
eselkin Dec 23, 2024
31fffcd
fix
eselkin Dec 23, 2024
25acf9a
min radius is now 60 so >=
eselkin Dec 24, 2024
bb0e141
fix zip
eselkin Dec 24, 2024
142307b
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 24, 2024
e93ef55
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 26, 2024
cbd5bb4
style updates
eselkin Dec 26, 2024
29fa40b
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 30, 2024
6eb29cd
fix widths on va-button - for future of configurable width
eselkin Dec 30, 2024
452756a
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 31, 2024
9169975
does this test work both locally and on CI
eselkin Dec 31, 2024
b776c8f
manage demensions
eselkin Dec 31, 2024
c555860
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 31, 2024
36b92ee
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Dec 31, 2024
6d16b01
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 2, 2025
dc2a2e1
more configurable sizes for CI
eselkin Jan 2, 2025
5be20f8
.25
eselkin Jan 2, 2025
7c20e9c
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 3, 2025
654ba3a
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 6, 2025
399821f
more mobile test issues that are not really mobile
eselkin Jan 6, 2025
8703821
merge
eselkin Jan 6, 2025
81686bf
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 7, 2025
006df7b
using va-alert instead of VaAlert and removed unneeded style
eselkin Jan 7, 2025
e94dc67
cleanup some styles
eselkin Jan 7, 2025
0a71281
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 7, 2025
de874ba
working spacing
eselkin Jan 7, 2025
a281605
Merge branch 'VACMS-19548-orientation-of-map-controls-fl' of github.c…
eselkin Jan 7, 2025
6c5bc4f
since changed padding make dimensions relatively bigger
eselkin Jan 8, 2025
1df217c
vaselect error uniformity with other errors
eselkin Jan 9, 2025
ac8a39e
merge fix post separation of applications
eselkin Jan 9, 2025
bd916f6
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 10, 2025
c128c2b
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 13, 2025
69f0959
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 14, 2025
f51b4e5
VACMS - 19549 19800 conditional render services select, and loading i…
eselkin Jan 16, 2025
feaaa44
Merge branch 'main' into VACMS-19548-orientation-of-map-controls-fl
eselkin Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function generateWebpackDevConfig(buildOptions) {
},
port: buildOptions.port,
host: buildOptions.host,
client: { webSocketURL },
client: { webSocketURL, overlay: false },
Copy link
Contributor Author

@eselkin eselkin Dec 24, 2024

Choose a reason for hiding this comment

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

Allows some tests to run if using yarn watch
Cypress has a webpack dev server it would rather us use, but we don't use it.

devMiddleware: {
publicPath: '/generated/',
stats: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const genBBoxFromAddress = (query, expandedRadius = false) => {
Math.max(featureBox[3], coordinates[1] + searchBoundingRadius),
];
}

const radius = radiusFromBoundingBox(
features?.[0]?.bbox
? features
Expand Down
7 changes: 6 additions & 1 deletion src/applications/facility-locator/api/LocatorApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ class LocatorApi {
fetch(url, api.settings)
.then(res => res.json())
.then(
data => resolve(data.data.map(specialty => specialty.attributes)),
data => {
if (data.errors?.length) {
return reject(data.errors[0]);
}
return resolve(data.data.map(specialty => specialty.attributes));
},
error => reject(error),
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';

function ControlResultsHolder({ children, isSmallDesktop }) {
// If the screen is smaller than small desktop we just return the children
if (!isSmallDesktop) {
return children;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cannot be enclosed in a div if not small desktop or smaller because grouping and orientation is completely different.

}

return <div id="vertical-oriented-left-controls">{children}</div>;
}

ControlResultsHolder.propTypes = {
children: PropTypes.node.isRequired,
isSmallDesktop: PropTypes.bool.isRequired,
};

export default ControlResultsHolder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import PropTypes from 'prop-types';

function EmergencyCareAlert({ shouldShow = false }) {
if (!shouldShow) {
return null;
}
return (
<va-alert
slim
full-width
status="info"
class="vads-u-margin-top--1"
data-testid="emergency-care-info-note"
id="emergency-care-info-note"
>
<strong>Note:</strong> If you think your life or health is in danger, call{' '}
<va-telephone contact="911" /> or go to the nearest emergency department
right away.
</va-alert>
);
}

EmergencyCareAlert.propTypes = {
shouldShow: PropTypes.bool,
};

export default EmergencyCareAlert;
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { setFocus } from '../utils/helpers';

function PpmsServiceError({ currentQuery }) {
const shownAlert = useRef(null);
useEffect(
() => {
if (
shownAlert.current &&
currentQuery?.fetchSvcsError &&
!shownAlert.current.hasAttribute('tabindex')
) {
setTimeout(() => {
// We need the timeout because the alert is rendered after the error is set
// and we need to wait for the alert to be rendered before setting focus
// Also, the required field (facilityType) steals focus immediately no matter how it is set
setFocus(shownAlert.current);
}, 50);
}
},
[shownAlert, currentQuery],
);
if (currentQuery?.fetchSvcsError) {
return (
<va-alert
status="error"
class="vads-u-margin-bottom--4"
id="fetch-ppms-services-error"
ref={shownAlert}
>
<h2 slot="headline">We’ve run into a problem</h2>
<p className="vads-u-margin-y--0">
Community provider searches aren’t working right now. Try again later.
</p>
</va-alert>
);
}
return null;
}

PpmsServiceError.propTypes = {
currentQuery: PropTypes.object,
};

const mapStateToProps = state => {
return {
currentQuery: state.searchQuery,
};
};

export default connect(mapStateToProps)(PpmsServiceError);
77 changes: 38 additions & 39 deletions src/applications/facility-locator/components/SearchControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
} from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import {
healthServices,
benefitsServices,
urgentCareServices,
facilityTypesOptions,
emergencyCareServices,
Expand All @@ -18,6 +17,7 @@
import ServiceTypeAhead from './ServiceTypeAhead';
import { setFocus } from '../utils/helpers';
import { SearchControlsTypes } from '../types';
import ServicesLoadingOrShow from './ServicesLoadingOrShow';

const SearchControls = props => {
const {
Expand All @@ -31,6 +31,7 @@

const [selectedServiceType, setSelectedServiceType] = useState(null);
const locationInputFieldRef = useRef(null);
const facilityTypeDropdownRef = useRef(null);

const onlySpaces = str => /^\s+$/.test(str);

Expand All @@ -55,6 +56,8 @@
onChange({
facilityType: e.target.value,
serviceType: null,
// Since the facility type may cause an error (PPMS), reset it if the type is changed
fetchSvcsError: null,
});
};

Expand All @@ -68,6 +71,7 @@

const handleSubmit = e => {
e.preventDefault();
e.stopPropagation();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added because of va-button effects, but also limited with the type of submission from the button.


const {
facilityType,
Expand All @@ -77,7 +81,6 @@
searchString,
specialties,
} = currentQuery;

let analyticsServiceType = serviceType;

const updateReduxState = propName => {
Expand Down Expand Up @@ -120,7 +123,6 @@
'fl-search-svc-type': analyticsServiceType,
'fl-current-zoom-depth': zoomLevel,
});

onSubmit();
};

Expand Down Expand Up @@ -158,7 +160,7 @@
htmlFor="street-city-state-zip"
id="street-city-state-zip-label"
>
<span id="city-state-zip-text">City, state or postal code</span>{' '}
<span id="city-state-zip-text">Zip code or city, state</span>{' '}
<span className="form-required-span">(*Required)</span>
</label>
{geolocationInProgress ? (
Expand All @@ -167,7 +169,7 @@
<span aria-live="assertive">Finding your location...</span>
</div>
) : (
<button

Check warning on line 172 in src/applications/facility-locator/components/SearchControls.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/facility-locator/components/SearchControls.jsx:172:13:The <va-button> Web Component should be used instead of the button HTML element.
onClick={handleGeolocationButtonClick}
type="button"
className="use-my-location-link"
Expand All @@ -181,7 +183,7 @@
{showError && (
<span className="usa-input-error-message" role="alert">
<span className="sr-only">Error</span>
Please fill in a city, state, or postal code.
Please fill in a zip code or city, state.
</span>
)}
<div className="input-container">
Expand All @@ -193,11 +195,10 @@
onChange={handleQueryChange}
onBlur={handleLocationBlur}
value={searchString}
title="Your location: Street, City, State or Postal code"
/>
{searchString?.length > 0 && (
<button

Check warning on line 200 in src/applications/facility-locator/components/SearchControls.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/facility-locator/components/SearchControls.jsx:200:13:The <va-button> Web Component should be used instead of the button HTML element.
aria-label="Clear your city, state or postal code"
aria-label="Clear your zip code or city, state"
type="button"
id="clear-input"
className="clear-button"
Expand Down Expand Up @@ -228,7 +229,6 @@
{locationOptions[facility]}
</option>
));

return (
<div
className={classNames(
Expand All @@ -237,18 +237,20 @@
`facility-type-dropdown-val-${facilityType || 'none'}`,
)}
>
<VaSelect
uswds
required
id="facility-type-dropdown"
className={showError ? 'vads-u-padding-left--1p5' : null}
label="Facility Type"
value={facilityType || ''}
onVaSelect={e => handleFacilityTypeChange(e)}
error={showError ? 'Please choose a facility type.' : null}
>
{options}
</VaSelect>
<div className="facility-type-dropdown-block">
<VaSelect
ref={facilityTypeDropdownRef}
required
id="facility-type-dropdown"
className={showError ? 'vads-u-padding-left--1p5' : null}
label="Facility type"
value={facilityType || ''}
onVaSelect={e => handleFacilityTypeChange(e)}
error={showError ? 'Please choose a facility type.' : null}
>
{options}
</VaSelect>
</div>
</div>
);
};
Expand Down Expand Up @@ -277,21 +279,20 @@
case LocationType.EMERGENCY_CARE:
services = emergencyCareServices;
break;
case LocationType.BENEFITS:
services = benefitsServices;
break;
case LocationType.CC_PROVIDER:
return (
<div className="typeahead">
<ServiceTypeAhead
handleServiceTypeChange={handleServiceTypeChange}
initialSelectedServiceType={serviceType}
showError={showError}
/>
</div>
<ServicesLoadingOrShow serviceType="ppms_services">
<div id="service-typeahead-container" className="typeahead">
<ServiceTypeAhead
handleServiceTypeChange={handleServiceTypeChange}
initialSelectedServiceType={serviceType}
showError={showError}
/>
</div>
</ServicesLoadingOrShow>
);
default:
services = {};
return null;
}

// Create option elements for each VA service type.
Expand All @@ -302,7 +303,7 @@
));

return (
<span className="service-type-dropdown-container">
<div className="service-type-dropdown-container">
<label htmlFor="service-type-dropdown">Service type</label>
<select
id="service-type-dropdown"
Expand All @@ -312,7 +313,7 @@
>
{options}
</select>
</span>
</div>
);
};

Expand Down Expand Up @@ -383,13 +384,11 @@
id="facility-search-controls"
onSubmit={handleSubmit}
>
<div className="columns">
<div className="columns vads-u-margin--0 vads-u-padding--0">
{renderLocationInputField()}
<div id="search-controls-bottom-row">
{renderFacilityTypeDropdown()}
{renderServiceTypeDropdown()}
<input id="facility-search" type="submit" value="Search" />
</div>
{renderFacilityTypeDropdown()}
{renderServiceTypeDropdown()}
<va-button id="facility-search" submit="prevent" text="Search" />
</div>
</form>
</div>
Expand Down
Loading
Loading