// going back - history page
goBack() {
const { listingProperties, resp, forBack } = this.props;
if (window.history.length <= 1) {
let pType = listingProperties.PropertyListingType;
if (pType === 'rental' || pType === 'room_rental') {
pType = 'rent';
} else if (pType === 'sale') {
pType = 'buy';
}
let targetPath;
if (resp.ref === undefined || (resp.ref.indexOf('/listing/') !== -1) ) {
const titleBackSearch = forBack.title.replace(/[^\x00-\x7F]/g, "");
let params = `keyword=${titleBackSearch}`;
if (Object.entries(forBack.asset).length !== 0) {
const ast = forBack.asset['und'][0]['target_id'];
params += `&asset_id=${ast}`;
}
targetPath = `/${pType}?${params}`;
} else {
targetPath = resp.ref;
}
let search = '';
if (targetPath.indexOf('?')) {
const t = targetPath.split('?');
targetPath = t[0];
search = t[1];
}
search = (search === undefined)?'':search;
Router.push({
pathname: targetPath,
search: `?${search}`,
});
} else {
Router.back();
}
}