homeflowjs 0.10.10 → 0.10.12

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
 
package/index.js CHANGED
@@ -7,6 +7,7 @@ import notify from './app/notify';
7
7
  import Loader from './shared/loader.component';
8
8
  import AuthenticityTokenField from './shared/authenticity-token-field.component';
9
9
  import { uniqueKey } from './utils';
10
+ import SingleLocationMap from './shared/single-location-map';
10
11
 
11
12
  export {
12
13
  withHomeflowState,
@@ -18,4 +19,5 @@ export {
18
19
  Loader,
19
20
  AuthenticityTokenField,
20
21
  uniqueKey,
22
+ SingleLocationMap,
21
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.10.10",
3
+ "version": "0.10.12",
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">
@@ -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
+ });
@@ -2,7 +2,7 @@
2
2
  export const simpleBW = [
3
3
  {
4
4
  stylers: [
5
- { saturation: -90 }
5
+ { saturation: -90 },
6
6
  ],
7
7
  },
8
8
  {
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import {
3
+ MapContainer, TileLayer,
4
+ } from 'react-leaflet';
5
+ import PropTypes from 'prop-types';
6
+
7
+ const SingleLocationMap = ({
8
+ lat, lng, zoomLvl, ...otherProps
9
+ }) => {
10
+ if (!lat || !lng) return null;
11
+
12
+ return (
13
+ <MapContainer
14
+ center={[lat, lng]}
15
+ zoom={zoomLvl}
16
+ scrollWheelZoom={false}
17
+ {...otherProps}
18
+ >
19
+ <TileLayer
20
+ attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
21
+ url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
22
+ />
23
+ </MapContainer>
24
+ );
25
+ };
26
+
27
+ SingleLocationMap.propTypes = {
28
+ lat: PropTypes.number.isRequired,
29
+ lng: PropTypes.number.isRequired,
30
+ zoomLvl: PropTypes.number,
31
+ };
32
+
33
+ SingleLocationMap.defaultProps = {
34
+ zoomLvl: 12,
35
+ };
36
+
37
+ export default SingleLocationMap;