const text = ` 300 400 500 700
1800 1830 1850 300
1900 1930 1940 1950 `;
let arr = text.split('\n');
console.log(console);
arr = arr.map(el => {
console.log(el);
el.replace('\t\t', ' 0 ');
console.log('new el ', el);
return el.replace(/\s+/g, ' ').trim();
});
console.log(arr);
import {applyMiddleware, createStore} from 'redux';
import {composeWithDevTools} from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import reducer from '../reducers';
const store = createStore(
reducer,
composeWithDevTools(applyMiddleware(...[thunk])),
);
const priceSum = () => console.log(store.getState());
store.subscribe(() => {
priceSum();
});
export class WindowCalculator {
constructor() {
this.$casement = $('.js-calculator-window');
this.store = store;
}
priceSum() {
console.log('sum ', this.store.getState());
}
export const getPriceColor = obj => dispatch => {
const res = getPriceColorApi(obj);
dispatch({
type: obj.name,
payload: res,
});
};
mosquitoNet({
name: !$stvorkaBox.hasClass('is-mosquito-grid')
? AppConstants.ADD_MOSQUITO
: AppConstants.REMOVE_MOSQUITO,
options: {
[mosquitoId]: {type: 'standart'},
},
})(this.dispatch);
export default (state = initialState, {type, payload}) => {
console.log('mosquito ', type);
switch (type) {
case AppConstants.ADD_MOSQUITO:
return {...state, ...payload};
case AppConstants.REMOVE_MOSQUITO:
delete state[Object.keys(payload)];
return state;
default:
return state;
}
};
this.store = createStore(
reducer(),
composeWithDevTools(applyMiddleware(...[thunk])),
);
import {combineReducers} from 'redux';
import priceColor from './color-scheme';
import includeMosquitoInPrice from './includeMosquitoInPrice';
import mosquitos from './masquitos';
export default () =>
combineReducers({
priceColor,
includeMosquitoInPrice,
mosquitos,
});
import AppConstants from '../actionTypes';
const initialState = {};
export default (state = initialState, {type, payload}) => {
switch (type) {
case AppConstants.ADD_MOSQUITO:
return {...state, ...payload};
case AppConstants.REMOVE_MOSQUITO:
delete state[Object.keys(payload)];
return state;
default:
return state;
}
};
import AppConstants from '../actionTypes';
const initialState = {sill: 0, otkos: 0};
export default (state = initialState, {type, payload}) => {
switch (type) {
case AppConstants.GET_COLOR_PRICE_OTKOS:
return {...state, otkos: payload};
case AppConstants.GET_COLOR_PRICE_SILL:
return {...state, sill: payload};
default:
return state;
}
};
export const getPriceColor = obj => dispatch => {
const res = getPriceColorApi(obj);
dispatch({
type: obj.name,
payload: res,
});
};
export const mosquitoNet = obj => dispatch => {
dispatch({
type: obj.name,
payload: obj.options,
});
};
getPriceColor(this.options)(dispatch);
mosquitoNet({
name: !$stvorkaBox.hasClass('is-mosquito-grid')
? AppConstants.ADD_MOSQUITO
: AppConstants.REMOVE_MOSQUITO,
options: {
[mosquitoId]: {type: 'standart'},
},
})(dispatch);
export class ColorSheme {
constructor(selector, store) {
this.$select = $(selector);
console.log('js');
store.dispatch({
type: 'ADD_TRACK',
payload: 'Simple like spirit !!!!!!!!!!',
});
}
}
import {ColorSheme} from '../blocks/calculator/color-scheme/color-scheme';
(() => new ColorSheme('.js-color-scheme', store))();
0: {image: undefined}
1: {image: undefined}
2: {image: undefined}
3: {image: undefined}
4: {image: undefined}
import React from 'react';
import {connect} from 'react-redux';
import {compose} from 'redux';
import {NavLink, withRouter} from 'react-router-dom';
import PropTypes from 'prop-types';
const Categories = ({categories}) => {
console.log(categories);
return (
<div className="categories-wrap">
<div className="">categories</div>
<ul className="categories-list">
{categories &&
categories.map((category, index) => {
if (index === 1) {
return (
<li key={index}>
<NavLink
activeClassName="active"
exact
to={`/category/${category.id}`}
>
{category.name}
</NavLink>
</li>
);
}
return (
<li key={index}>
<NavLink to={`/category/${category.id}`}>
{category.name}
</NavLink>
</li>
);
})}
</ul>
</div>
);
};
const mapStateToProps = state => ({
categories: state.categories,
});
export default compose(
withRouter,
connect(
mapStateToProps,
null,
),
)(Categories);
Categories.propTypes = {
categories: PropTypes.array,
props: PropTypes.object,
};
import React from 'react';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import {fetchPhones, fetchCategories} from '../actions';
import {renderPhone} from './renderPhone';
const Phones = props => {
props.fetchPhones();
props.fetchCategories();
const {phones} = props;
return (
<div className="container-phones">
{phones.map((phone, index) => renderPhone(phone, index))}
</div>
);
};
const mapStateToProps = (state, ownProps) => {
console.log(ownProps);
return {
phones: state.phones,
};
};
const mapDispatchToProps = {
fetchPhones,
fetchCategories,
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Phones);
Phones.propTypes = {
fetchCategories: PropTypes.func,
fetchPhones: PropTypes.func,
phones: PropTypes.array,
};
const mapStateToProps = (state, ownProps) => {console.log(ownProps); return({
categories: getCategories(state),
activeCategoryId: getActiveCategoryId(ownProps)
})}
export const getActiveCategoryId = ownProps => R.path(['params', 'id'], ownProps)