Merge pull request #95 from sharetribe/empty-search

Allow searching without location
This commit is contained in:
Kimmo Puputti 2017-03-27 13:49:51 +03:00 committed by GitHub
commit ccd98aade2
7 changed files with 14 additions and 36 deletions

View file

@ -1,10 +1,9 @@
import React, { PropTypes } from 'react';
import { Menu, NamedLink } from '../../components';
import { NamedLink } from '../../components';
import css from './SearchResultsPanel.css';
const SearchResultsPanel = props => (
<div>
<Menu />
{props.children}
<div className={css.navigation}>
<NamedLink className={css.button} name="SearchFiltersPage">Filters</NamedLink>

View file

@ -1,6 +1,5 @@
exports[`SearchResultsPanel matches snapshot 1`] = `
<div>
<Menu />
<div>
<withFlattenedRoutes(withRouter(NamedLink))
name="SearchFiltersPage">

View file

@ -2,12 +2,11 @@ import React from 'react';
import { Field, reduxForm, propTypes as formPropTypes } from 'redux-form';
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
import { LocationAutocompleteInput, Button } from '../../components';
import { autocompleteSearchRequired, autocompletePlaceSelected } from '../../util/validators';
import css from './HeroSearchForm.css';
const HeroSearchForm = props => {
const { className, intl, handleSubmit, pristine, submitting } = props;
const { className, intl, handleSubmit, submitting } = props;
const addClassName = className ? { className } : {};
return (
@ -19,9 +18,8 @@ const HeroSearchForm = props => {
placeholder={intl.formatMessage({ id: 'HeroSearchForm.placeholder' })}
format={null}
component={LocationAutocompleteInput}
validate={[autocompleteSearchRequired(), autocompletePlaceSelected()]}
/>
<Button className={css.locationButton} type="submit" disabled={pristine || submitting}>
<Button className={css.locationButton} type="submit" disabled={submitting}>
<FormattedMessage id="HeroSearchForm.search" />
<div className={css.searchIcon}>
<svg width="18" height="18" viewBox="189 165 18 18" xmlns="http://www.w3.org/2000/svg">

View file

@ -17,7 +17,7 @@ exports[`HeroSearchForm matches snapshot 1`] = `
</div>
<button
className=""
disabled={true}
disabled={false}
type="submit">
<span>
Search

View file

@ -12,8 +12,8 @@ export const LandingPageComponent = props => {
const { push: historyPush, flattenedRoutes } = props;
const handleSubmit = values => {
const { location: { selectedPlace } } = values;
const { address, origin, bounds } = selectedPlace;
const selectedPlace = values && values.location ? values.location.selectedPlace : null;
const { address, origin, bounds } = selectedPlace || {};
const searchQuery = stringify({ address, origin, bounds });
const path = pathByRouteName('SearchPage', flattenedRoutes);
historyPush(`${path}?${searchQuery}`);

View file

@ -62,8 +62,14 @@ export const searchListingsError = e => ({
export const searchListings = searchParams =>
(dispatch, getState, sdk) => {
dispatch(searchListingsRequest(searchParams));
return sdk.listings
.search(searchParams)
const { origin, include = [] } = searchParams;
const searchOrQuery = origin
? sdk.listings.search(searchParams)
: sdk.listings.query({ include });
return searchOrQuery
.then(response => {
dispatch(showListingsSuccess(response));
dispatch(searchListingsSuccess(response));

View file

@ -12,12 +12,6 @@ const House = () => <span dangerouslySetInnerHTML={{ __html: '&#127968;' }} />;
const Topbar = props => {
const { isAuthenticated, onLogout, push: historyPush } = props;
const hamburger = { dangerouslySetInnerHTML: { __html: '&#127828;' } };
const handleChange = e => {
const value = e.target.value;
historyPush(value);
};
const handleLogout = () => {
// History push function is passed to the action to enable
@ -31,24 +25,6 @@ const Topbar = props => {
<NamedLink className={css.home} name="LandingPage">
<House />
</NamedLink>
<select value="default" className={css.navDropDown} onChange={handleChange}>
<option value="default" {...hamburger} />
<option value="/s">Search</option>
<option value="/l/Bike-Pelago/12345">Listing page</option>
<option value="/u/Bikerrs">Profile</option>
<option value="/u/Bikerrs/edit">Edit profile</option>
<option value="/checkout/lid1234">Checkout</option>
<option value="/inbox">Inbox</option>
<option value="/orders">Orders</option>
<option value="/sales">Sales</option>
<option value="/password/forgotten">Request password</option>
<option value="/password/change">Change password</option>
<option value="/listings">Manage listings</option>
<option value="/account">Account settings</option>
<option value="/account/contact-details">Contact details</option>
<option value="/account/payout-preferences">Payout preferences</option>
<option value="/account/security">Security</option>
</select>
</div>
<div className={css.user}>
{isAuthenticated