@nnc-digital/nnc-design-system 0.4.23 → 0.4.25
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 +15 -7
- package/build/index.esm.js.map +1 -1
- package/build/index.js +15 -7
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -4414,12 +4414,18 @@ var BinCollection = function (_a) {
|
|
|
4414
4414
|
var handleAddressChange = function (e) {
|
|
4415
4415
|
var selectedUPRN = e.target.value;
|
|
4416
4416
|
if (selectedUPRN) {
|
|
4417
|
-
var
|
|
4418
|
-
var
|
|
4417
|
+
var startDate_1 = getFormattedDate();
|
|
4418
|
+
var endDate_1 = getFormattedDate(28);
|
|
4419
4419
|
// Fetch calendar events for the selected UPRN
|
|
4420
|
-
axios__default["default"].get("".concat(CalendarEventsApiUrl).concat(selectedUPRN, "/").concat(
|
|
4420
|
+
axios__default["default"].get("".concat(CalendarEventsApiUrl).concat(selectedUPRN, "/").concat(startDate_1, "/").concat(endDate_1))
|
|
4421
4421
|
.then(function (response) {
|
|
4422
|
-
|
|
4422
|
+
// Filter the data based on the date range
|
|
4423
|
+
var filteredData = response.data.filter(function (event) {
|
|
4424
|
+
var eventDate = parseDate(event.start);
|
|
4425
|
+
var eventDateString = eventDate.toISOString().split('T')[0];
|
|
4426
|
+
return eventDateString >= startDate_1 && eventDateString <= endDate_1;
|
|
4427
|
+
});
|
|
4428
|
+
var groupedData = groupByTitle(filteredData);
|
|
4423
4429
|
if (Object.keys(groupedData).length === 0) {
|
|
4424
4430
|
setNoResultsFound(true);
|
|
4425
4431
|
}
|
|
@@ -4516,11 +4522,13 @@ var BinCollection = function (_a) {
|
|
|
4516
4522
|
}
|
|
4517
4523
|
return sortedTitles.map(function (title, index) {
|
|
4518
4524
|
var apiTitlesForThisType = Object.keys(calendarEvents).filter(function (apiTitle) { return formatTitle(apiTitle) === title; });
|
|
4525
|
+
var dates = apiTitlesForThisType.flatMap(function (apiTitle) { return calendarEvents[apiTitle]; })
|
|
4526
|
+
.map(function (date) { return new Date(date).toISOString().split('T')[0]; })
|
|
4527
|
+
.filter(function (date, index, array) { return array.indexOf(date) === index; })
|
|
4528
|
+
.sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); });
|
|
4519
4529
|
return (React__default["default"].createElement(React__default["default"].Fragment, { key: "".concat(title, "-").concat(index) },
|
|
4520
4530
|
React__default["default"].createElement(Heading, { level: 3, text: title }),
|
|
4521
|
-
|
|
4522
|
-
.sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); })
|
|
4523
|
-
.map(function (date) { return (React__default["default"].createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4531
|
+
dates.map(function (date, index) { return (React__default["default"].createElement("p", { key: index }, new Date(date).toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4524
4532
|
});
|
|
4525
4533
|
})()),
|
|
4526
4534
|
Object.keys(calendarEvents).length > 0 && (React__default["default"].createElement(FormButton, { size: "small", type: "button", "aria-label": "Reset", text: "Find a different address", onClick: resetForm }))));
|