@nnc-digital/nnc-design-system 0.4.7 → 0.4.14
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 +26 -20
- package/build/index.esm.js.map +1 -1
- package/build/index.js +25 -19
- package/build/index.js.map +1 -1
- package/build/library/components/BinCollection/BinCollection.styles.d.ts +0 -3
- package/build/library/components/BinCollection/BinCollection.types.d.ts +2 -2
- package/package.json +1 -2
package/build/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Component, cloneElement, useState, useContext, useEffect,
|
|
1
|
+
import React, { Component, cloneElement, useState, useContext, useEffect, useRef, useId, createContext } from 'react';
|
|
2
2
|
import styled, { css, ThemeContext, ThemeProvider, createGlobalStyle } from 'styled-components';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import require$$0 from 'tty';
|
|
@@ -4037,12 +4037,9 @@ var ErrorTextWrapper = styled.div(templateObject_5 || (templateObject_5 = __make
|
|
|
4037
4037
|
var DropDownSelectContainer = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-bottom: 20px;\n"], ["\n padding-bottom: 20px;\n"])));
|
|
4038
4038
|
var FormInnerContainer = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n"], ["\n display: flex;\n align-items: center;\n justify-content: flex-start;\n"])));
|
|
4039
4039
|
styled.label(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin-right: ", ";\n"], ["\n display: flex;\n align-items: center;\n margin-right: ", ";\n"])), function (props) { return props.theme.theme_vars.spacingSizes.small; });
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
var
|
|
4043
|
-
var UPRNPageUPRNTitle = styled.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-size: 1.5em;\n"], ["\n font-size: 1.5em;\n"])));
|
|
4044
|
-
styled.input(templateObject_13 || (templateObject_13 = __makeTemplateObject([""], [""])));
|
|
4045
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13;
|
|
4040
|
+
styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n justify-content: left;\n margin-bottom: .5em;\n width: 100%;\n"], ["\n display: flex;\n justify-content: left;\n margin-bottom: .5em;\n width: 100%;\n"])));
|
|
4041
|
+
styled.input(templateObject_10 || (templateObject_10 = __makeTemplateObject([""], [""])));
|
|
4042
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
4046
4043
|
|
|
4047
4044
|
const Container$16 = styled.div`
|
|
4048
4045
|
display: flex;
|
|
@@ -4308,14 +4305,15 @@ var Heading = function (_a) {
|
|
|
4308
4305
|
* Returns the Bin Collection Checker form component to conduct search by postcode.
|
|
4309
4306
|
*/
|
|
4310
4307
|
var BinCollection = function (_a) {
|
|
4311
|
-
var _b = _a.formError, formError = _b === void 0 ? false : _b, _c = _a.
|
|
4312
|
-
var BinCollectionApiUrl = "".concat(
|
|
4313
|
-
var CalendarEventsApiUrl = "".concat(
|
|
4308
|
+
var _b = _a.formError, formError = _b === void 0 ? false : _b, _c = _a.graphqlApiEndpoint, graphqlApiEndpoint = _c === void 0 ? process.env.NEXT_PUBLIC_DRUPAL_APP_API_BASE_URL : _c;
|
|
4309
|
+
var BinCollectionApiUrl = "".concat(graphqlApiEndpoint, "bin-collection-search/premiselist/");
|
|
4310
|
+
var CalendarEventsApiUrl = "".concat(graphqlApiEndpoint, "bin-collection-search/calendarevents/");
|
|
4314
4311
|
var themeContext = useContext(ThemeContext);
|
|
4315
4312
|
var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
4316
4313
|
var _e = useState(formError), isError = _e[0], setError = _e[1];
|
|
4317
4314
|
var _f = useState(''), errorText = _f[0], setErrorText = _f[1];
|
|
4318
4315
|
var _g = useState([]), addressOptions = _g[0], setAddressOptions = _g[1];
|
|
4316
|
+
var seenTitles = useRef(new Set());
|
|
4319
4317
|
var handleSubmit = function (e) {
|
|
4320
4318
|
e.preventDefault();
|
|
4321
4319
|
var enteredPostcode = e.target.elements.postcode.value;
|
|
@@ -4409,13 +4407,14 @@ var BinCollection = function (_a) {
|
|
|
4409
4407
|
setCalendarEvents({});
|
|
4410
4408
|
setError(false);
|
|
4411
4409
|
setErrorText('');
|
|
4410
|
+
seenTitles.current.clear();
|
|
4412
4411
|
};
|
|
4413
4412
|
var formatTitle = function (apiTitle) {
|
|
4414
4413
|
var mappings = [
|
|
4415
|
-
{ keyword: '
|
|
4416
|
-
{ keyword: '
|
|
4417
|
-
{ keyword: '
|
|
4418
|
-
{ keyword: '
|
|
4414
|
+
{ keyword: 'Refuse', replacement: 'General refuse bin' },
|
|
4415
|
+
{ keyword: 'Recycling', replacement: 'Recycling bin' },
|
|
4416
|
+
{ keyword: 'Garden', replacement: 'Garden bin' },
|
|
4417
|
+
{ keyword: 'Food', replacement: 'Food caddy' },
|
|
4419
4418
|
];
|
|
4420
4419
|
for (var _i = 0, mappings_1 = mappings; _i < mappings_1.length; _i++) {
|
|
4421
4420
|
var mapping = mappings_1[_i];
|
|
@@ -4423,12 +4422,15 @@ var BinCollection = function (_a) {
|
|
|
4423
4422
|
return mapping.replacement;
|
|
4424
4423
|
}
|
|
4425
4424
|
}
|
|
4426
|
-
return
|
|
4425
|
+
return null;
|
|
4427
4426
|
};
|
|
4427
|
+
useEffect(function () {
|
|
4428
|
+
seenTitles.current.clear();
|
|
4429
|
+
}, [calendarEvents]);
|
|
4428
4430
|
return (React.createElement(Container$17, { "data-testid": "BinCollection" },
|
|
4429
4431
|
React.createElement(FormWithLine, { onSubmit: handleSubmit, isError: isError, lineColour: themeContext.theme_vars.colours.grey_dark, hideLine: true },
|
|
4430
4432
|
React.createElement(FormContainer$1, { isLoading: isLoading },
|
|
4431
|
-
React.createElement(Heading, { level: 2, text: "Bin
|
|
4433
|
+
React.createElement(Heading, { level: 2, text: "Bin collection checker" }),
|
|
4432
4434
|
React.createElement(ErrorTextWrapper, null, errorText && React.createElement(ErrorText$1, null, errorText)),
|
|
4433
4435
|
React.createElement(FormInnerContainer, null,
|
|
4434
4436
|
React.createElement(Input$6, { type: "text", placeholder: "Enter a postcode", name: "postcode", isErrored: isError, maxLength: 10 }),
|
|
@@ -4439,13 +4441,17 @@ var BinCollection = function (_a) {
|
|
|
4439
4441
|
React.createElement("div", null, Object.entries(calendarEvents).map(function (_a) {
|
|
4440
4442
|
var apiTitle = _a[0], dates = _a[1];
|
|
4441
4443
|
var title = formatTitle(apiTitle);
|
|
4444
|
+
// If we've seen this title before, or if title is null, we skip rendering it
|
|
4445
|
+
if (seenTitles.current.has(title) || title === null) {
|
|
4446
|
+
return null;
|
|
4447
|
+
}
|
|
4448
|
+
// Mark the title as seen
|
|
4449
|
+
seenTitles.current.add(title);
|
|
4442
4450
|
return (React.createElement(React.Fragment, { key: title },
|
|
4443
|
-
React.createElement(
|
|
4444
|
-
React.createElement(UPRNPageSectionTitle, null, title)),
|
|
4451
|
+
React.createElement(Heading, { level: 3, text: title }),
|
|
4445
4452
|
dates
|
|
4446
4453
|
.sort(function (a, b) { return new Date(a).getTime() - new Date(b).getTime(); })
|
|
4447
|
-
.map(function (date) { return (React.createElement(
|
|
4448
|
-
React.createElement(UPRNPageUPRNTitle, null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })))); })));
|
|
4454
|
+
.map(function (date) { return (React.createElement("p", null, date.toLocaleDateString('en-GB', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }))); })));
|
|
4449
4455
|
})),
|
|
4450
4456
|
Object.keys(calendarEvents).length > 0 && (React.createElement(FormButton, { size: "small", type: "button", "aria-label": "Reset", text: "Find a different address", onClick: resetForm }))));
|
|
4451
4457
|
};
|