welcome popeup + mobile friendly

This commit is contained in:
GotPPay
2017-11-06 14:38:47 +01:00
parent 7a5f7242ac
commit ec9a29e04d
14 changed files with 200 additions and 115 deletions

View File

@@ -1,84 +1,84 @@
import React from 'react'
import {render} from 'react-dom'
import Main from './components/Main'
import Welcome from './components/Welcome'
import React from 'react';
import {render} from 'react-dom';
import Main from './components/Main';
import Welcome from './components/Welcome';
const getInitialState = url => {
const params = window.location.search.substr(1).split('&')
const params = window.location.search.substr (1).split ('&');
const initialState = {
rooms: {},
category: {}
}
category: {},
};
for (const param of params) {
const [key, value] = param.split('=')
const [key, value] = param.split ('=');
if (key === 'rooms' && value !== '') {
initialState.rooms = {}
value.split(',').forEach(k => {
initialState.rooms[parseInt(k)] = true
})
initialState.rooms = {};
value.split (',').forEach (k => {
initialState.rooms[parseInt (k)] = true;
});
}
if (key === 'category' && value !== '') {
initialState.category = {}
value.split(',').forEach(k => {
initialState.category[parseInt(k)] = true
})
initialState.category = {};
value.split (',').forEach (k => {
initialState.category[parseInt (k)] = true;
});
}
if (key === 'sort') {
initialState.sort = value
initialState.sort = value;
}
if (key === 'bounds') {
initialState.bounds = value
initialState.bounds = value;
}
if (key === 'listingId') {
initialState.listingId = value
initialState.listingId = value;
}
if (key === 'type') {
initialState.type = value
if (key === 'adType') {
initialState.adType = value;
}
if (key === 'zoom') {
initialState.zoom = parseInt(value)
initialState.zoom = parseInt (value);
}
if (['minSize', 'maxSize', 'minPrice', 'maxPrice'].includes(key)) {
initialState[key] = parseFloat(value)
if (['minSize', 'maxSize', 'minPrice', 'maxPrice'].includes (key)) {
initialState[key] = parseFloat (value);
}
}
return initialState
}
return initialState;
};
const root = document.getElementById('root')
const initialState = getInitialState(window.location)
const root = document.getElementById ('root');
const initialState = getInitialState (window.location);
const renderMain = (additionalState = {}) => {
const main = <Main initialState={{...initialState, ...additionalState}} />
render(main, root)
}
const main = <Main initialState={{...initialState, ...additionalState}} />;
render (main, root);
};
renderMain()
//renderMain ();
// disable temp
/*
if (Object.keys(initialState).length === 2 &&
window.localStorage.getItem('lastLoad') == null) {
const onSearch = ({bounds, type, location}) => {
window.location = `/?bounds=${bounds}&type=${type}`
//renderMain({
//bounds,
//type
//})
}
const welcome = <Welcome onSearch={onSearch} />
render(welcome, root)
if (
Object.keys (initialState).length === 2 &&
window.localStorage.getItem ('lastLoad') == null
) {
const onSearch = ({adType}) => {
console.log("onSearch()");
//window.location = `/?adType=${adType}`;
renderMain({adType})
};
const welcome = <Welcome onSearch={onSearch} />;
render (welcome, root);
} else {
renderMain()
renderMain ();
}
*/