homeflowjs 0.10.9 → 0.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,10 @@
1
1
  import BranchesActionTypes from './branches.types';
2
2
 
3
+ export const setBranches = (payload) => ({
4
+ type: BranchesActionTypes.SET_BRANCHES,
5
+ payload,
6
+ });
7
+
3
8
  export const setBranchesSearch = (payload) => ({
4
9
  type: BranchesActionTypes.SET_BRANCHES_SEARCH,
5
10
  payload,
@@ -1,4 +1,5 @@
1
1
  const BranchesActionTypes = {
2
+ SET_BRANCHES: 'SET_BRANCHES',
2
3
  SET_BRANCHES_SEARCH: 'SET_BRANCHES_SEARCH',
3
4
  };
4
5
 
@@ -13,7 +13,7 @@ import ReactLeafletGoogleLayer from 'react-leaflet-google-layer';
13
13
  import 'leaflet/dist/leaflet.css';
14
14
 
15
15
  const BranchesMap = ({
16
- CustomPopup, google, gmapsKey, iconConfig, fallbackLatLng,
16
+ CustomPopup, google, gmapsKey, iconConfig, fallbackLatLng, scrollWheelZoom
17
17
  }) => {
18
18
  let branches = Homeflow.get('branches');
19
19
  let showMarkers = true;
@@ -30,12 +30,24 @@ const BranchesMap = ({
30
30
  shadowUrl: '/assets/marker-shadow.png',
31
31
  };
32
32
 
33
- const icon = L.icon(iconConfig || defaultIconConfig);
33
+ let icon = L.icon(iconConfig || defaultIconConfig);
34
34
 
35
35
  const bounds = latLngBounds([branches[0].lat, branches[0].lng]);
36
36
 
37
37
  const markers = branches.map((branch) => {
38
38
  bounds.extend([branch.lat, branch.lng]);
39
+ // check if branch object have mapIcon payload, example:
40
+ // mapIcon: {
41
+ // iconUrl: 'specific-path.png' || 'data:image/svg+xml;utf8,<svg></svg>',
42
+ // iconSize: [149, 66],
43
+ // }
44
+ if ('mapIcon' in branch) icon = L.icon(branch.mapIcon);
45
+ // check if branch object have mapDivIcon payload, example:
46
+ // mapDivIcon: {
47
+ // html: 'html string',
48
+ // iconSize: [149, 66],
49
+ // }
50
+ if ('mapDivIcon' in branch) icon = L.divIcon(branch.mapDivIcon);
39
51
 
40
52
  return (
41
53
  <Marker
@@ -77,7 +89,7 @@ const BranchesMap = ({
77
89
  <MapContainer
78
90
  center={[branches[0].lat, branches[0].lng]}
79
91
  bounds={bounds}
80
- scrollWheelZoom={false}
92
+ scrollWheelZoom={scrollWheelZoom}
81
93
  style={{ height: '100%' }}
82
94
  >
83
95
  {google ? (
@@ -99,6 +111,7 @@ BranchesMap.propTypes = {
99
111
  gmapsKey: PropTypes.string,
100
112
  iconConfig: PropTypes.object,
101
113
  fallbackLatLng: PropTypes.object,
114
+ scrollWheelZoom: PropTypes.bool,
102
115
  };
103
116
 
104
117
  BranchesMap.defaultProps = {
@@ -107,6 +120,7 @@ BranchesMap.defaultProps = {
107
120
  gmapsKey: null,
108
121
  iconConfig: null,
109
122
  fallbackLatLng: { lat: 51.509865, lng: -0.118092 },
123
+ scrollWheelZoom: false,
110
124
  };
111
125
 
112
126
  const mapStateToProps = (state) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.10.9",
3
+ "version": "0.10.11",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -58,10 +58,10 @@ const PropertiesDisplay = ({
58
58
  */
59
59
  if (inserts && (index % inserts[0].frequency) === 0 && index !== 0) {
60
60
  return (
61
- <>
61
+ <React.Fragment key={property.property_id}>
62
62
  {inserts[0].component}
63
- <Item key={property.property_id} property={property} {...other} />
64
- </>
63
+ <Item property={property} {...other} />
64
+ </React.Fragment>
65
65
  );
66
66
  }
67
67
  return (
@@ -31,7 +31,7 @@ const DefaultCalculator = ({ purchasePrice, setPurchasePrice, firstTimeBuyer, ad
31
31
  }
32
32
 
33
33
  const {
34
- rate1,
34
+ rate1,
35
35
  rate2,
36
36
  rate3,
37
37
  rate4,
@@ -56,7 +56,7 @@ const DefaultCalculator = ({ purchasePrice, setPurchasePrice, firstTimeBuyer, ad
56
56
  setPurchasePrice(property.price_value);
57
57
  calculateStampDuty(property.price_value);
58
58
  }
59
- }, []);
59
+ }, [firstTimeBuyer, additionalProperty]);
60
60
 
61
61
  const handlePriceInputChange = ({ target: { value } }) => {
62
62
  const numberString = value.substring(1);
@@ -102,7 +102,7 @@ const DefaultCalculator = ({ purchasePrice, setPurchasePrice, firstTimeBuyer, ad
102
102
  </p>
103
103
 
104
104
  {(firstTimeBuyer && property.price_value >= 625000) && (
105
- <p id='first_time_buyer_info'>First time buyers purchasing property for more than £625,000 will not be entitled to any relief and will pay SDLT at the standard rates.</p>
105
+ <p id="first_time_buyer_info">First time buyers purchasing property for more than £625,000 will not be entitled to any relief and will pay SDLT at the standard rates.</p>
106
106
  )}
107
107
 
108
108
  <div className="results-table-wrap">
@@ -7,7 +7,7 @@ import './stamp-duty-calculator.styles.scss';
7
7
 
8
8
  const StampDutyCalculator = ({ scotland, themePreferences }) => {
9
9
  const [type, setType] = useState('residential');
10
- const [purchaseType, setPurchaseType] = useState('additional')
10
+ const [purchaseType, setPurchaseType] = useState('firstTimeBuyer')
11
11
  const [purchasePrice, setPurchasePrice] = useState();
12
12
 
13
13
  const renderCalculator = () => {
@@ -62,19 +62,19 @@ const StampDutyCalculator = ({ scotland, themePreferences }) => {
62
62
  <div className="form-group">
63
63
  <button
64
64
  type="button"
65
- className={`stamp-duty-cal__type ${purchaseType === 'additional' ? 'selected' : ''}`}
66
- onClick={() => setPurchaseType('additional')}
65
+ className={`stamp-duty-cal__type ${purchaseType === 'firstTimeBuyer' ? 'selected' : ''}`}
66
+ onClick={() => setPurchaseType('firstTimeBuyer')}
67
67
  >
68
- Additional Property
68
+ First Time Buyer
69
69
  </button>
70
70
  </div>
71
71
  <div className="form-group">
72
72
  <button
73
73
  type="button"
74
- className={`stamp-duty-cal__type ${purchaseType === 'firstTimeBuyer' ? 'selected' : ''}`}
75
- onClick={() => setPurchaseType('firstTimeBuyer')}
74
+ className={`stamp-duty-cal__type ${purchaseType === 'additional' ? 'selected' : ''}`}
75
+ onClick={() => setPurchaseType('additional')}
76
76
  >
77
- First Time Buyer
77
+ Additional Property
78
78
  </button>
79
79
  </div>
80
80
  </div>
@@ -1,11 +1,17 @@
1
1
  import BranchesActionTypes from '../actions/branches.types';
2
2
 
3
3
  const INITIAL_STATE = {
4
+ branches: [],
4
5
  branchesSearch: '',
5
6
  };
6
7
 
7
8
  const branchesReducer = (state = INITIAL_STATE, action) => {
8
9
  switch (action.type) {
10
+ case BranchesActionTypes.SET_BRANCHES:
11
+ return {
12
+ ...state,
13
+ branches: action.payload,
14
+ };
9
15
  case BranchesActionTypes.SET_BRANCHES_SEARCH:
10
16
  return {
11
17
  ...state,
@@ -0,0 +1,10 @@
1
+ import branchesReducer from './branches.reducer';
2
+
3
+ describe('branchesReducer', () => {
4
+ it('Sets the branches when it receives the SET_BRANCHES action', () => {
5
+ const state = { branches: [] };
6
+ const reducedState = branchesReducer(state, { type: 'SET_BRANCHES', payload: [1, 2, 3] });
7
+
8
+ expect(reducedState.branches).toEqual([1, 2, 3]);
9
+ });
10
+ });