homeflowjs 0.10.13 → 0.10.15

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.
@@ -30,6 +30,8 @@ export const fetchUser = () => (dispatch) => {
30
30
  // if the user is logged in, fetch saved searches and properties
31
31
  dispatch(fetchSavedProperties());
32
32
  dispatch(fetchSavedSearches());
33
+
34
+ Homeflow.kickEvent('user_signed_in');
33
35
  } else {
34
36
  // load saved properties and searches from localStorage
35
37
  const serializedSavedSearches = localStorage.getItem('savedSearches');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.10.13",
3
+ "version": "0.10.15",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -30,6 +30,7 @@ const SavePropertyButton = (props) => {
30
30
  notify(notificationMessage || 'Saved property removed.', 'success');
31
31
  } else {
32
32
  addSavedProperty(propertyId);
33
+ Homeflow.kickEvent('saved_property_added', propertyId);
33
34
  notify(notificationMessage || 'Property saved.', 'success');
34
35
  }
35
36
  };
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
3
3
 
4
4
  import './stamp-duty-calculator.styles.scss';
5
5
 
6
- const BTLCalculator = ({ purchasePrice, setPurchasePrice }) => {
6
+ const BTLCalculator = ({ purchasePrice, setPurchasePrice, firstTimeBuyer }) => {
7
7
  const [effectiveRate, setEffectiveRate] = useState();
8
8
  const [totalRate, setTotalRate] = useState();
9
9
  const [rate0, setRate0] = useState();
@@ -31,45 +31,66 @@ const BTLCalculator = ({ purchasePrice, setPurchasePrice }) => {
31
31
  let rate1 = 0;
32
32
  let rate2 = 0;
33
33
  let rate3 = 0;
34
- let rate4 = 0;
35
-
36
- if (price - 40000 > 0) {
37
- rate0 = price;
38
- rate0 *= 0.03;
39
- if (rate0 > 125000 * 0.03) {
40
- rate0 = 125000 * 0.03;
34
+
35
+ if (firstTimeBuyer) {
36
+ if (price - 250000 > 0) {
37
+ rate0 = price;
38
+ rate0 *= 0;
39
+ if (rate0 > 250000 * 0) {
40
+ rate0 = 250000 * 0;
41
+ }
41
42
  }
42
- }
43
- if (price - 125000 > 0) {
44
- rate1 = (price - 125000);
45
- rate1 *= 0.05;
46
- if (rate1 > 125000 * 0.05) {
47
- rate1 = 125000 * 0.05;
43
+ if (price - 250000 > 0) {
44
+ rate1 = (price - 250000);
45
+ rate1 *= 0.05;
46
+ if (rate1 > 675000 * 0.05) {
47
+ rate1 = 675000 * 0.05;
48
+ }
48
49
  }
49
- }
50
50
 
51
- if (price - 250000 > 0) {
52
- rate2 = (price - 250000);
53
- rate2 *= 0.08;
54
- if (rate2 > 675000 * 0.08) {
55
- rate2 = 675000 * 0.08;
51
+ if (price - 925000 > 0) {
52
+ rate2 = (price - 925000);
53
+ rate2 *= 0.10;
54
+ if (rate2 > 575000 * 0.10) {
55
+ rate2 = 575000 * 0.10;
56
+ }
56
57
  }
57
- }
58
58
 
59
- if (price - 925000 > 0) {
60
- rate3 = (price - 925000);
61
- rate3 *= 0.13;
62
- if (rate3 > 575000 * 0.13) {
63
- rate3 = 575000 * 0.13;
59
+ if (price - 1500000 > 0) {
60
+ rate3 = (price - 1500000);
61
+ rate3 *= 0.12;
62
+ }
63
+ } else {
64
+ if (price - 250000 > 0) {
65
+ rate0 = price;
66
+ rate0 *= 0.03;
67
+ if (rate0 > 250000 * 0.03) {
68
+ rate0 = 250000 * 0.03;
69
+ }
70
+ }
71
+ if (price - 250000 > 0) {
72
+ rate1 = (price - 250000);
73
+ rate1 *= 0.08;
74
+ if (rate1 > 675000 * 0.08) {
75
+ rate1 = 675000 * 0.08;
76
+ }
77
+ }
78
+
79
+ if (price - 925000 > 0) {
80
+ rate2 = (price - 925000);
81
+ rate2 *= 0.13;
82
+ if (rate2 > 575000 * 0.13) {
83
+ rate2 = 575000 * 0.13;
84
+ }
64
85
  }
65
- }
66
86
 
67
- if (price - 1500000 > 0) {
68
- rate4 = (price - 1500000);
69
- rate4 *= 0.15;
87
+ if (price - 1500000 > 0) {
88
+ rate3 = (price - 1500000);
89
+ rate3 *= 0.15;
90
+ }
70
91
  }
71
92
 
72
- totalRate = rate0 + rate1 + rate2 + rate3 + rate4;
93
+ totalRate = rate0 + rate1 + rate2 + rate3;
73
94
  effectiveRate = totalRate / price;
74
95
  effectiveRate *= 100;
75
96
 
@@ -90,7 +111,7 @@ const BTLCalculator = ({ purchasePrice, setPurchasePrice }) => {
90
111
  setPurchasePrice(property.price_value);
91
112
  calculateStampDuty(property.price_value);
92
113
  }
93
- }, []);
114
+ }, [firstTimeBuyer]);
94
115
 
95
116
  const handlePriceInputChange = ({ target: { value } }) => {
96
117
  const numberString = value.substring(1);
@@ -146,57 +167,100 @@ const BTLCalculator = ({ purchasePrice, setPurchasePrice }) => {
146
167
  </tr>
147
168
  </thead>
148
169
  <tbody>
149
- <tr>
150
- <td>Between £0 and £125,000</td>
151
- <td>3%</td>
152
- <td className="rate0">
153
- £
154
- {Number(rate0).toLocaleString()}
155
- </td>
156
- </tr>
157
- <tr>
158
- <td>Between £125,000 and £250,000</td>
159
- <td>5%</td>
160
- <td className="rate1">
161
- £
162
- {Number(rate1).toLocaleString()}
163
- </td>
164
- </tr>
165
- <tr>
166
- <td>Between £250,000 and £925,000</td>
167
- <td>8%</td>
168
- <td className="rate2">
169
- £
170
- {Number(rate2).toLocaleString()}
171
- </td>
172
- </tr>
173
- <tr>
174
- <td>Between £925,000 and £1,500,000</td>
175
- <td>13%</td>
176
- <td className="rate3">
177
- £
178
- {Number(rate3).toLocaleString()}
179
- </td>
180
- </tr>
181
- <tr>
182
- <td>Over £1,500,000</td>
183
- <td>15%</td>
184
- <td className="rate4">
185
- £
186
- {Number(rate4).toLocaleString()}
187
- </td>
188
- </tr>
189
- <tr className="totals">
190
- <td>Total</td>
191
- <td className="effectiveRate">
192
- {effectiveRate}
193
- %
194
- </td>
195
- <td className="totalRate">
196
- £
197
- {Number(totalRate).toLocaleString()}
198
- </td>
199
- </tr>
170
+ {(firstTimeBuyer ? (
171
+ <>
172
+ <tr>
173
+ <td>Between £0 and 250,000</td>
174
+ <td>0%</td>
175
+ <td className="rate0">
176
+ £
177
+ {Number(rate0).toLocaleString()}
178
+ </td>
179
+ </tr>
180
+ <tr>
181
+ <td>Between £250,000 and £925,000</td>
182
+ <td>5%</td>
183
+ <td className="rate1">
184
+ £
185
+ {Number(rate1).toLocaleString()}
186
+ </td>
187
+ </tr>
188
+ <tr>
189
+ <td>Between £925,000 and £1,500,000</td>
190
+ <td>10%</td>
191
+ <td className="rate2">
192
+ £
193
+ {Number(rate2).toLocaleString()}
194
+ </td>
195
+ </tr>
196
+ <tr>
197
+ <td>Over £1,500,000</td>
198
+ <td>12%</td>
199
+ <td className="rate3">
200
+ £
201
+ {Number(rate3).toLocaleString()}
202
+ </td>
203
+ </tr>
204
+ <tr className="totals">
205
+ <td>Total</td>
206
+ <td className="effectiveRate">
207
+ {effectiveRate}
208
+ %
209
+ </td>
210
+ <td className="totalRate">
211
+ £
212
+ {Number(totalRate).toLocaleString()}
213
+ </td>
214
+ </tr>
215
+ </>
216
+ ) : (
217
+ <>
218
+ <tr>
219
+ <td>Between £0 and 250,000</td>
220
+ <td>3%</td>
221
+ <td className="rate0">
222
+ £
223
+ {Number(rate0).toLocaleString()}
224
+ </td>
225
+ </tr>
226
+ <tr>
227
+ <td>Between £250,000 and £925,000</td>
228
+ <td>8%</td>
229
+ <td className="rate1">
230
+ £
231
+ {Number(rate1).toLocaleString()}
232
+ </td>
233
+ </tr>
234
+ <tr>
235
+ <td>Between £925,000 and £1,500,000</td>
236
+ <td>13%</td>
237
+ <td className="rate3">
238
+ £
239
+ {Number(rate2).toLocaleString()}
240
+ </td>
241
+ </tr>
242
+ <tr>
243
+ <td>Over £1,500,000</td>
244
+ <td>15%</td>
245
+ <td className="rate4">
246
+ £
247
+ {Number(rate3).toLocaleString()}
248
+ </td>
249
+ </tr>
250
+ <tr className="totals">
251
+ <td>Total</td>
252
+ <td className="effectiveRate">
253
+ {effectiveRate}
254
+ %
255
+ </td>
256
+ <td className="totalRate">
257
+ £
258
+ {Number(totalRate).toLocaleString()}
259
+ </td>
260
+ </tr>
261
+ </>
262
+ ))}
263
+
200
264
  </tbody>
201
265
  </table>
202
266
  </div>
@@ -28,6 +28,7 @@ const StampDutyCalculator = ({ scotland, themePreferences }) => {
28
28
  <BTLCalculator
29
29
  purchasePrice={purchasePrice}
30
30
  setPurchasePrice={setPurchasePrice}
31
+ firstTimeBuyer={purchaseType === 'firstTimeBuyer'}
31
32
  />
32
33
  );
33
34
  }
@@ -77,9 +77,10 @@ const ReactSelect = (props) => {
77
77
  bedOptionText,
78
78
  } = props;
79
79
 
80
- const bedOptions = bedValues.map((bedValue) => (
81
- { value: bedValue, label: `${bedValue} ${bedOptionText}` }
82
- ));
80
+ const bedOptions = bedValues.map((bedValue) => ({
81
+ value: bedValue,
82
+ label: `${bedValue} ${bedOptionText}${bedValue > 1 ? 's' : ''}`,
83
+ }));
83
84
 
84
85
  if (value) bedOptions.unshift({ value: '', label: `No ${type} beds` });
85
86
 
@@ -31,6 +31,7 @@ const SaveSearchButton = (props) => {
31
31
  notify((showNotification && notificationMessage) ? notificationMessage : 'Saved search removed.', 'success');
32
32
  } else {
33
33
  addSavedSearchAsync(search);
34
+ Homeflow.kickEvent('saved_search_added');
34
35
  notify(notificationMessage || 'Search saved.', 'success');
35
36
  }
36
37
  };