mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 19:42:11 +10:00
Merge pull request #733 from sharetribe/handle-missing-geolocation
Handle missing geolocation
This commit is contained in:
commit
4c96408ae9
3 changed files with 11 additions and 8 deletions
|
|
@ -77,16 +77,18 @@ const tabCompleted = (tab, listing) => {
|
|||
|
||||
/**
|
||||
* Check which wizard tabs are active and which are not yet available. Tab is active if previous
|
||||
* tab is completed.
|
||||
* tab is completed. In edit mode all tabs are active.
|
||||
*
|
||||
* @param isNew flag if a new listing is being created or an old one being edited
|
||||
* @param listing data to be checked
|
||||
*
|
||||
* @return object containing activity / editability of different tabs of this wizard
|
||||
*/
|
||||
const tabsActive = listing => {
|
||||
const tabsActive = (isNew, listing) => {
|
||||
return TABS.reduce((acc, tab) => {
|
||||
const previousTabIndex = TABS.findIndex(t => t === tab) - 1;
|
||||
const isActive = previousTabIndex >= 0 ? tabCompleted(TABS[previousTabIndex], listing) : true;
|
||||
const isActive =
|
||||
previousTabIndex >= 0 ? !isNew || tabCompleted(TABS[previousTabIndex], listing) : true;
|
||||
return { ...acc, [tab]: isActive };
|
||||
}, {});
|
||||
};
|
||||
|
|
@ -198,7 +200,7 @@ class EditListingWizard extends Component {
|
|||
const rootClasses = rootClassName || css.root;
|
||||
const classes = classNames(rootClasses, className);
|
||||
const currentListing = ensureListing(listing);
|
||||
const tabsStatus = tabsActive(currentListing);
|
||||
const tabsStatus = tabsActive(isNew, currentListing);
|
||||
|
||||
// If selectedTab is not active, redirect to the beginning of wizard
|
||||
if (!tabsStatus[selectedTab]) {
|
||||
|
|
|
|||
|
|
@ -241,9 +241,10 @@ export class SearchMapComponent extends Component {
|
|||
const classes = classNames(rootClassName || css.root, className);
|
||||
const mapClasses = mapRootClassName || css.mapRoot;
|
||||
|
||||
const listingsWithLocation = originalListings.filter(l => !!l.attributes.geolocation);
|
||||
const listings = coordinatesConfig.fuzzy
|
||||
? withCoordinatesObfuscated(originalListings)
|
||||
: originalListings;
|
||||
? withCoordinatesObfuscated(listingsWithLocation)
|
||||
: listingsWithLocation;
|
||||
|
||||
// container element listens clicks so that opened SearchMapInfoCard can be closed
|
||||
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ const LISTING_STATES = [
|
|||
const listingAttributes = shape({
|
||||
title: string.isRequired,
|
||||
description: string.isRequired,
|
||||
geolocation: propTypes.latlng.isRequired,
|
||||
geolocation: propTypes.latlng,
|
||||
deleted: propTypes.value(false).isRequired,
|
||||
state: oneOf(LISTING_STATES).isRequired,
|
||||
price: propTypes.money,
|
||||
|
|
@ -156,7 +156,7 @@ const listingAttributes = shape({
|
|||
const ownListingAttributes = shape({
|
||||
title: string.isRequired,
|
||||
description: string.isRequired,
|
||||
geolocation: propTypes.latlng.isRequired,
|
||||
geolocation: propTypes.latlng,
|
||||
deleted: propTypes.value(false).isRequired,
|
||||
state: oneOf(LISTING_STATES).isRequired,
|
||||
price: propTypes.money,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue