@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.
@@ -4399,12 +4399,18 @@ var BinCollection = function (_a) {
4399
4399
  var handleAddressChange = function (e) {
4400
4400
  var selectedUPRN = e.target.value;
4401
4401
  if (selectedUPRN) {
4402
- var startDate = getFormattedDate();
4403
- var endDate = getFormattedDate(28);
4402
+ var startDate_1 = getFormattedDate();
4403
+ var endDate_1 = getFormattedDate(28);
4404
4404
  // Fetch calendar events for the selected UPRN
4405
- axios.get("".concat(CalendarEventsApiUrl).concat(selectedUPRN, "/").concat(startDate, "/").concat(endDate))
4405
+ axios.get("".concat(CalendarEventsApiUrl).concat(selectedUPRN, "/").concat(startDate_1, "/").concat(endDate_1))
4406
4406
  .then(function (response) {
4407
- var groupedData = groupByTitle(response.data);
4407
+ // Filter the data based on the date range
4408
+ var filteredData = response.data.filter(function (event) {
4409
+ var eventDate = parseDate(event.start);
4410
+ var eventDateString = eventDate.toISOString().split('T')[0];
4411
+ return eventDateString >= startDate_1 && eventDateString <= endDate_1;
4412
+ });
4413
+ var groupedData = groupByTitle(filteredData);
4408
4414
  if (Object.keys(groupedData).length === 0) {
4409
4415
  setNoResultsFound(true);
4410
4416
  }
@@ -4501,11 +4507,13 @@ var BinCollection = function (_a) {
4501
4507
  }
4502
4508
  return sortedTitles.map(function (title, index) {
4503
4509
  var apiTitlesForThisType = Object.keys(calendarEvents).filter(function (apiTitle) { return formatTitle(apiTitle) === title; });
4510
+ var dates = apiTitlesForThisType.flatMap(function (apiTitle) { return calendarEvents[apiTitle]; })
4511
+ .map(function (date) { return new Date(date).toISOString().split('T')[0]; })
4512
+ .filter(function (date, index, array) { return array.indexOf(date) === index; })
4513
+ .sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); });
4504
4514
  return (React.createElement(React.Fragment, { key: "".concat(title, "-").concat(index) },
4505
4515
  React.createElement(Heading, { level: 3, text: title }),
4506
- apiTitlesForThisType.flatMap(function (apiTitle) { return calendarEvents[apiTitle]; })
4507
- .sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); })
4508
- .map(function (date) { return (React.createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
4516
+ dates.map(function (date, index) { return (React.createElement("p", { key: index }, new Date(date).toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
4509
4517
  });
4510
4518
  })()),
4511
4519
  Object.keys(calendarEvents).length > 0 && (React.createElement(FormButton, { size: "small", type: "button", "aria-label": "Reset", text: "Find a different address", onClick: resetForm }))));