Added cookies and changed m2 color view to include parcel
This commit is contained in:
parent
587f6fc950
commit
5022a2ccda
46
react_usse/package-lock.json
generated
46
react_usse/package-lock.json
generated
@ -15,7 +15,8 @@
|
|||||||
"react-icons": "^3.2.2",
|
"react-icons": "^3.2.2",
|
||||||
"react-leaflet": "4.2.1",
|
"react-leaflet": "4.2.1",
|
||||||
"react-scripts": "^5.0.1",
|
"react-scripts": "^5.0.1",
|
||||||
"sort-by": "^1.2.0"
|
"sort-by": "^1.2.0",
|
||||||
|
"universal-cookie": "^7.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@ampproject/remapping": {
|
"node_modules/@ampproject/remapping": {
|
||||||
@ -3476,6 +3477,11 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/cookie": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA=="
|
||||||
|
},
|
||||||
"node_modules/@types/eslint": {
|
"node_modules/@types/eslint": {
|
||||||
"version": "8.21.1",
|
"version": "8.21.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.1.tgz",
|
||||||
@ -15542,6 +15548,23 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/universal-cookie": {
|
||||||
|
"version": "7.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-7.1.4.tgz",
|
||||||
|
"integrity": "sha512-Q+DVJsdykStWRMtXr2Pdj3EF98qZHUH/fXv/gwFz/unyToy1Ek1w5GsWt53Pf38tT8Gbcy5QNsj61Xe9TggP4g==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/cookie": "^0.6.0",
|
||||||
|
"cookie": "^0.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/universal-cookie/node_modules/cookie": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/universalify": {
|
"node_modules/universalify": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||||
@ -18943,6 +18966,11 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/cookie": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA=="
|
||||||
|
},
|
||||||
"@types/eslint": {
|
"@types/eslint": {
|
||||||
"version": "8.21.1",
|
"version": "8.21.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.21.1.tgz",
|
||||||
@ -27568,6 +27596,22 @@
|
|||||||
"crypto-random-string": "^2.0.0"
|
"crypto-random-string": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"universal-cookie": {
|
||||||
|
"version": "7.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-7.1.4.tgz",
|
||||||
|
"integrity": "sha512-Q+DVJsdykStWRMtXr2Pdj3EF98qZHUH/fXv/gwFz/unyToy1Ek1w5GsWt53Pf38tT8Gbcy5QNsj61Xe9TggP4g==",
|
||||||
|
"requires": {
|
||||||
|
"@types/cookie": "^0.6.0",
|
||||||
|
"cookie": "^0.6.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cookie": {
|
||||||
|
"version": "0.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||||
|
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"universalify": {
|
"universalify": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"escape-string-regexp": "^1.0.5",
|
"escape-string-regexp": "^1.0.5",
|
||||||
"leaflet" : "",
|
"leaflet": "",
|
||||||
"react-leaflet" : "4.2.1",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-icons": "^3.2.2",
|
"react-icons": "^3.2.2",
|
||||||
|
"react-leaflet": "4.2.1",
|
||||||
"react-scripts": "^5.0.1",
|
"react-scripts": "^5.0.1",
|
||||||
"sort-by": "^1.2.0"
|
"sort-by": "^1.2.0",
|
||||||
|
"universal-cookie": "^7.1.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
@ -5,16 +5,26 @@ import { FaBars } from 'react-icons/fa';
|
|||||||
import './App.css';
|
import './App.css';
|
||||||
import escapeRegExp from 'escape-string-regexp';
|
import escapeRegExp from 'escape-string-regexp';
|
||||||
|
|
||||||
|
import Cookies from 'universal-cookie';
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
state = {
|
state = {
|
||||||
allLocations: {},
|
allLocations: {},
|
||||||
query : '',
|
query : '',
|
||||||
toggleMenu: false,
|
toggleMenu: false,
|
||||||
|
cookies : new Cookies(),
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.setState({ allLocations : locations})
|
this.setState({ allLocations : locations})
|
||||||
|
const cookies = new Cookies();
|
||||||
|
this.cookies = cookies;
|
||||||
|
this.setState({ price: cookies.get('price') })
|
||||||
|
this.setState({ minPrice: cookies.get('minPrice') })
|
||||||
|
this.setState({ afstandNFI: cookies.get('NFI') })
|
||||||
|
this.setState({ afstandHoogstraat: cookies.get('Hoogstraat') })
|
||||||
|
this.setState({ afstandBakkersdijk: cookies.get('Bakkersdijk') })
|
||||||
|
this.setState({ afstandKorhoen: cookies.get('Korhoen') })
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggleMenu = () => {
|
onToggleMenu = () => {
|
||||||
@ -27,6 +37,14 @@ class App extends Component {
|
|||||||
|
|
||||||
updatePrice = (maxPrice) => {
|
updatePrice = (maxPrice) => {
|
||||||
this.setState({ price: parseInt(maxPrice.trim())})
|
this.setState({ price: parseInt(maxPrice.trim())})
|
||||||
|
const cookies = this.cookies.set('price', maxPrice, { path: '/' })
|
||||||
|
this.setState({ cookies: cookies })
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePriceMin = (minPrice) => {
|
||||||
|
this.setState({ minPrice: parseInt(minPrice.trim())})
|
||||||
|
const cookies = this.cookies.set('minPrice', minPrice, { path: '/' })
|
||||||
|
this.setState({ cookies: cookies })
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAfstand = (minuten, naar) => {
|
updateAfstand = (minuten, naar) => {
|
||||||
@ -42,10 +60,12 @@ class App extends Component {
|
|||||||
if (naar === 'Bakkersdijk') {
|
if (naar === 'Bakkersdijk') {
|
||||||
this.setState({ afstandBakkersdijk: parseInt(minuten.trim())})
|
this.setState({ afstandBakkersdijk: parseInt(minuten.trim())})
|
||||||
}
|
}
|
||||||
|
const cookies = this.cookies.set(naar, minuten, { path: '/' })
|
||||||
|
this.setState({ cookies: cookies })
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { allLocations, query, price, afstandNFI, afstandHoogstraat, afstandKorhoen, afstandBakkersdijk } = this.state
|
const { allLocations, query, price, minPrice, afstandNFI, afstandHoogstraat, afstandKorhoen, afstandBakkersdijk } = this.state
|
||||||
let showingLocations
|
let showingLocations
|
||||||
if (query || price || afstandNFI || afstandHoogstraat || afstandKorhoen || afstandBakkersdijk) {
|
if (query || price || afstandNFI || afstandHoogstraat || afstandKorhoen || afstandBakkersdijk) {
|
||||||
showingLocations = allLocations;
|
showingLocations = allLocations;
|
||||||
@ -61,6 +81,12 @@ class App extends Component {
|
|||||||
location.price <= maxPrice
|
location.price <= maxPrice
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if(minPrice){
|
||||||
|
const price = parseInt(minPrice) * 1000
|
||||||
|
showingLocations = showingLocations.filter((location) =>
|
||||||
|
location.price >= price
|
||||||
|
)
|
||||||
|
}
|
||||||
if(afstandNFI){
|
if(afstandNFI){
|
||||||
showingLocations = showingLocations.filter((location) =>
|
showingLocations = showingLocations.filter((location) =>
|
||||||
location.nfi_location.duration <= (afstandNFI * 60)
|
location.nfi_location.duration <= (afstandNFI * 60)
|
||||||
@ -101,6 +127,7 @@ class App extends Component {
|
|||||||
query={this.state.query}
|
query={this.state.query}
|
||||||
onUpdateQuery={this.updateQuery}
|
onUpdateQuery={this.updateQuery}
|
||||||
onUpdatePrice={this.updatePrice}
|
onUpdatePrice={this.updatePrice}
|
||||||
|
onUpdateMinPrice={this.updatePriceMin}
|
||||||
onUpdateAfstand={this.updateAfstand}
|
onUpdateAfstand={this.updateAfstand}
|
||||||
onToggleMenu={this.onToggleMenu}
|
onToggleMenu={this.onToggleMenu}
|
||||||
onListItemClick={this.onListItemClick}
|
onListItemClick={this.onListItemClick}
|
||||||
@ -108,6 +135,7 @@ class App extends Component {
|
|||||||
selectedLocation={this.state.selectedLocation}
|
selectedLocation={this.state.selectedLocation}
|
||||||
locationData={this.state.locationData}
|
locationData={this.state.locationData}
|
||||||
maxPrice={this.state.price}
|
maxPrice={this.state.price}
|
||||||
|
minPrice={this.state.minPrice}
|
||||||
afstandNFI={this.state.afstandNFI}
|
afstandNFI={this.state.afstandNFI}
|
||||||
afstandHoogstraat={this.state.afstandHoogstraat}
|
afstandHoogstraat={this.state.afstandHoogstraat}
|
||||||
afstandKorhoen={this.state.afstandKorhoen}
|
afstandKorhoen={this.state.afstandKorhoen}
|
||||||
|
@ -37,11 +37,11 @@ L.Marker.prototype.options.icon = DefaultIcon;
|
|||||||
|
|
||||||
function valueToColor(value) {
|
function valueToColor(value) {
|
||||||
// Clamp the value between 2000 and 5000
|
// Clamp the value between 2000 and 5000
|
||||||
value = Math.max(2000, Math.min(5000, value));
|
value = Math.max(500, Math.min(3000, value));
|
||||||
|
|
||||||
// Map the value to the range 0 to 255
|
// Map the value to the range 0 to 255
|
||||||
let green = Math.round(255 * (5000 - value) / 3000);
|
let green = Math.round(255 * (3000 - value) / 3000);
|
||||||
let red = Math.round(255 * (value - 2000) / 3000);
|
let red = Math.round(255 * (value - 500) / 3000);
|
||||||
|
|
||||||
// Ensure the values are within the RGB range
|
// Ensure the values are within the RGB range
|
||||||
green = Math.max(0, Math.min(255, green));
|
green = Math.max(0, Math.min(255, green));
|
||||||
@ -105,6 +105,7 @@ class LeafletMap extends Component {
|
|||||||
render() {
|
render() {
|
||||||
let { markers} = this.props
|
let { markers} = this.props
|
||||||
let { maxPrice} = this.props
|
let { maxPrice} = this.props
|
||||||
|
let {minPrice} = this.props
|
||||||
let { afstandNFI} = this.props
|
let { afstandNFI} = this.props
|
||||||
let { afstandHoogstraat} = this.props
|
let { afstandHoogstraat} = this.props
|
||||||
let { afstandKorhoen} = this.props
|
let { afstandKorhoen} = this.props
|
||||||
@ -129,6 +130,13 @@ class LeafletMap extends Component {
|
|||||||
<button onClick={() => this.props.onToggleMenu()}>close</button>
|
<button onClick={() => this.props.onToggleMenu()}>close</button>
|
||||||
|
|
||||||
|
|
||||||
|
<div className='priceFilterBlock'>
|
||||||
|
<li>Minimale prijs</li>
|
||||||
|
<input type="range" min="100" max="700" onInput={(e) => {
|
||||||
|
this.props.onUpdateMinPrice(e.target.value)
|
||||||
|
}} />
|
||||||
|
<output>{minPrice}</output>
|
||||||
|
</div>
|
||||||
<div className='priceFilterBlock'>
|
<div className='priceFilterBlock'>
|
||||||
<li>Maximale prijs</li>
|
<li>Maximale prijs</li>
|
||||||
<input type="range" min="100" max="700" onInput={(e) => {
|
<input type="range" min="100" max="700" onInput={(e) => {
|
||||||
@ -196,9 +204,9 @@ class LeafletMap extends Component {
|
|||||||
/>
|
/>
|
||||||
{markers && markers.map((marker) => (
|
{markers && markers.map((marker) => (
|
||||||
// marker.price_m2
|
// marker.price_m2
|
||||||
<Marker key={marker.house_id} position={{ lng : marker.position[0], lat : marker.position[1]}} icon={this.getCustomIcon(marker.price_m2)}>
|
<Marker key={marker.house_id} position={{ lng : marker.position[0], lat : marker.position[1]}} icon={this.getCustomIcon(marker.price_m2_total)}>
|
||||||
<Popup>
|
<Popup>
|
||||||
Prijs: {marker.price} Per m2: {marker.price_m2} <br/>
|
Prijs: {marker.price} Per m2: {marker.price_m2_total} <br/>
|
||||||
NFI: {Math.floor(marker.nfi_location.distance / 1000)} km, {Math.floor(marker.nfi_location.duration / 60)} minuten <br/>
|
NFI: {Math.floor(marker.nfi_location.distance / 1000)} km, {Math.floor(marker.nfi_location.duration / 60)} minuten <br/>
|
||||||
Korhoen: {Math.floor(marker.korhoen_location.distance / 1000)} km, {Math.floor(marker.korhoen_location.duration / 60)} minuten <br/>
|
Korhoen: {Math.floor(marker.korhoen_location.distance / 1000)} km, {Math.floor(marker.korhoen_location.duration / 60)} minuten <br/>
|
||||||
Bakkersdijk: {Math.floor(marker.bakkersdijk_location.distance / 1000)} km, {Math.floor(marker.bakkersdijk_location.duration / 60)} minuten <br/>
|
Bakkersdijk: {Math.floor(marker.bakkersdijk_location.distance / 1000)} km, {Math.floor(marker.bakkersdijk_location.duration / 60)} minuten <br/>
|
||||||
|
Loading…
Reference in New Issue
Block a user