export default class Router { constructor(comp) { this.component = comp; } update () { // Take the state from the component and update the URL const {listingId, sort, minPrice, maxPrice, minSize, maxSize, filters: {rooms, category}} = this.component.state; const bounds = this.component.map.getBounds().toUrlValue(); const params = []; params.push(`listingId=${listingId}`); params.push(`sort=${sort}`); params.push(`bounds=${bounds}`); params.push(`rooms=${Object.keys(rooms).filter(v => rooms[v]).join(",")}`); params.push(`category=${Object.keys(category).filter(v => category[v]).join(",")}`); window.history.pushState({}, '', `/?${params.join("&")}`); } }