mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Fix topbar search initial value
This commit is contained in:
parent
812a7b85b0
commit
9333b53bb7
3 changed files with 5 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ import { createResourceLocatorString } from '../../util/routes';
|
|||
import routeConfiguration from '../../routeConfiguration';
|
||||
import { IconSearch, Button } from '../../components';
|
||||
import { LocationSearchForm } from '../../forms';
|
||||
import config from '../../config';
|
||||
|
||||
import css from './SectionHero.css';
|
||||
|
||||
|
|
@ -22,7 +23,8 @@ const SectionHero = props => {
|
|||
const handleSearchSubmit = values => {
|
||||
const { search, selectedPlace } = values.location;
|
||||
const { origin, bounds, country } = selectedPlace;
|
||||
const searchParams = { address: search, origin, bounds, country };
|
||||
const originMaybe = config.sortSearchByDistance ? { origin } : {};
|
||||
const searchParams = { ...originMaybe, address: search, bounds, country };
|
||||
history.push(createResourceLocatorString('SearchPage', routeConfiguration(), {}, searchParams));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class TopbarComponent extends Component {
|
|||
);
|
||||
|
||||
// Only render current search if full place object is available in the URL params
|
||||
const locationFieldsPresent = address && origin && bounds && country;
|
||||
const locationFieldsPresent = address && bounds && country;
|
||||
const initialSearchFormValues = {
|
||||
location: locationFieldsPresent
|
||||
? {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ propTypes.route = shape({
|
|||
// Place object from LocationAutocompleteInput
|
||||
propTypes.place = shape({
|
||||
address: string.isRequired,
|
||||
origin: propTypes.latlng.isRequired,
|
||||
origin: propTypes.latlng,
|
||||
bounds: propTypes.latlngBounds, // optional viewport bounds
|
||||
country: string, // country code, e.g. FI, US
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue