@nnc-digital/nnc-design-system 0.4.30 → 0.4.31
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.
- package/build/index.esm.js +19 -6
- package/build/index.esm.js.map +1 -1
- package/build/index.js +19 -6
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -4358,12 +4358,25 @@ var BinCollection = function (_a) {
|
|
|
4358
4358
|
setErrorText('No addresses found for the provided postcode.');
|
|
4359
4359
|
return;
|
|
4360
4360
|
}
|
|
4361
|
-
//
|
|
4362
|
-
var
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4361
|
+
// Separate numeric and named addresses
|
|
4362
|
+
var numericAddresses = [];
|
|
4363
|
+
var namedAddresses = [];
|
|
4364
|
+
response.data.data.forEach(function (item) {
|
|
4365
|
+
var address = "".concat(item.Address);
|
|
4366
|
+
if (/^\d/.test(address)) { // Address starts with a number
|
|
4367
|
+
numericAddresses.push({ value: item.UPRN, title: address });
|
|
4368
|
+
}
|
|
4369
|
+
else {
|
|
4370
|
+
namedAddresses.push({ value: item.UPRN, title: address });
|
|
4371
|
+
}
|
|
4372
|
+
});
|
|
4373
|
+
// Sort numeric addresses by the whole number
|
|
4374
|
+
numericAddresses.sort(function (a, b) { return parseInt(a.title, 10) - parseInt(b.title, 10); });
|
|
4375
|
+
// Sort named addresses alphabetically
|
|
4376
|
+
namedAddresses.sort(function (a, b) { return a.title.localeCompare(b.title); });
|
|
4377
|
+
// Combine the sorted arrays
|
|
4378
|
+
var sortedAddresses = numericAddresses.concat(namedAddresses);
|
|
4379
|
+
setAddressOptions(sortedAddresses);
|
|
4367
4380
|
})
|
|
4368
4381
|
.catch(function (error) {
|
|
4369
4382
|
setIsLoading(false);
|