@bytebrand/fe-ui-core-autobahn 1.0.210 → 1.0.212
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/cards/CarCard.tsx +8 -1
- package/cards/CarCardSkeleton.tsx +103 -0
- package/cards/CarRow.tsx +5 -1
- package/cards/CarRowSkeleton.tsx +152 -0
- package/cards/cardParts.tsx +1368 -1363
- package/cards/index.ts +6 -0
- package/cards/types.ts +182 -182
- package/chrome/AccountMenuIcon.tsx +109 -0
- package/chrome/Footer.tsx +16 -3
- package/chrome/TopBar.tsx +139 -266
- package/compat/CookieModal/CookieModal.tsx +20 -6
- package/compat/CookieModal/Modal.tsx +6 -3
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +43 -15
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +4 -3
- package/compat/CookieModal/useModal.ts +5 -1
- package/compat/Loader/Loader.tsx +1 -7
- package/compat/MdField/MdField.tsx +28 -4
- package/compat/TimePicker/TimePicker.tsx +12 -2
- package/data/toAutobahnCar.ts +600 -586
- package/iconsvg/IconSVG.tsx +1 -5
- package/locales/de/autobahn.json +891 -857
- package/locales/en/autobahn.json +891 -857
- package/package.json +2 -2
- package/theme/md3.css +15678 -11743
- package/ui/CreditCostNotice.tsx +44 -44
- package/ui/CreditKeyFigures.tsx +244 -244
- package/ui/Dropdown.tsx +29 -10
- package/ui/FormCheckbox.tsx +22 -2
- package/ui/FormField.tsx +2 -1
- package/ui/Icon.tsx +6 -0
- package/ui/MfieldCheckIcon.tsx +13 -0
- package/ui/Modal.tsx +84 -6
- package/ui/Skeleton.tsx +79 -20
- package/ui/index.ts +96 -94
- package/ui/scrollFieldIntoView.ts +41 -0
- package/ui/usePortalMenuPosition.ts +27 -15
- package/utils/cookieConsent.ts +84 -0
- package/utils/index.ts +10 -0
- package/vdp/FinanceCalculator.tsx +1148 -1134
- package/vdp/VdpModules.tsx +3869 -4437
- package/vdp/index.ts +0 -3
- package/vdp/types.ts +7 -17
- package/vehiclesProps/accidentDisclosure.ts +25 -0
- package/vehiclesProps/decoratedLightProps.tsx +4 -0
- package/vehiclesProps/decoratedProps.tsx +4 -0
|
@@ -8,19 +8,43 @@ import MaterialAccordionGroup from '../../../MdAccordionGroup/MdAccordionGroup';
|
|
|
8
8
|
import MaterialSwitch from '../../../MdSwitch/MdSwitch';
|
|
9
9
|
import { COOKIE_SCHEMA, COOKIE_SCHEMA_LINKS } from '../../../../constants/common';
|
|
10
10
|
import { updateCookieList } from '../../../../utils/CommonUtils';
|
|
11
|
+
import { saveCookieConfig } from '../../../../utils/cookieConsent';
|
|
12
|
+
import { TranslationFunction } from '../../../../types';
|
|
11
13
|
|
|
12
14
|
import styles from './ManageCookieModal.styl';
|
|
13
15
|
|
|
14
16
|
interface IManageCookieModal {
|
|
15
17
|
toggleModal: () => void;
|
|
16
18
|
handleSentryInit?: () => void;
|
|
19
|
+
/** the host's `t` with the `autobahn` namespace loaded; without it the dialog stays German (fe-landing) */
|
|
20
|
+
t?: TranslationFunction;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
interface IMarketingSwitches {
|
|
20
24
|
[key: string]: any;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
// the German copy (locales/de/autobahn.json `cookieModal`), used as is when the host passes no `t`
|
|
28
|
+
const DE: Record<string, string> = {
|
|
29
|
+
title: 'Nach den Cookies geht die Fahrt weiter.',
|
|
30
|
+
manageText: 'Für ein bestmögliches Nutzererlebnis setzen wir Cookies und andere Technologien ein. Diese können Sie hier verwalten.',
|
|
31
|
+
'necessary.title': 'Notwendig',
|
|
32
|
+
'necessary.text': 'Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert. Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen können, wenn Sie auf unsere Website zurückkehren. Sie können diese Cookies in den Einstellungen Ihres Browsers deaktivieren, aber wenn Sie dies tun, funktioniert die Website möglicherweise nicht wie vorgesehen.',
|
|
33
|
+
'analytics.title': 'Analytisch',
|
|
34
|
+
'analytics.text': 'Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen, damit wir Ihnen relevantere Informationen präsentieren können.',
|
|
35
|
+
'marketing.title': 'Marketing',
|
|
36
|
+
'marketing.text': 'Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites. Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der von Ihnen besuchten Seiten auf unserer Website anzeigen.',
|
|
37
|
+
privacyPolicy: 'Datenschutzbestimmungen',
|
|
38
|
+
saveSelection: 'Auswahl speichern',
|
|
39
|
+
acceptAll: 'Alles akzeptieren'
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const ManageCookieModal = ({ toggleModal, handleSentryInit, t } : IManageCookieModal) => {
|
|
43
|
+
// a key the host can't resolve (namespace not loaded) comes back as the key itself
|
|
44
|
+
const tr = (key: string) => {
|
|
45
|
+
const text = t ? t(`autobahn:cookieModal.${key}`) : '';
|
|
46
|
+
return text && !text.endsWith(`cookieModal.${key}`) ? text : DE[key];
|
|
47
|
+
};
|
|
24
48
|
const [analytcisMasterSwitch, setAnalyticsMasterSwitch] = useState(false);
|
|
25
49
|
const [marketingMasterSwitch, setMarketingMasterSwitch] = useState(false);
|
|
26
50
|
const [analyticsSwitches, setAnalyticsSwitches] = useState<IMarketingSwitches>({});
|
|
@@ -44,6 +68,10 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
44
68
|
.reduce((acc, item) => ({ ...acc, [item]: !!savedConfig && !savedDisabledMarketing.includes(item) }), {});
|
|
45
69
|
setAnalyticsSwitches(newAnalyticsSwitches);
|
|
46
70
|
setMarketingSwitches(newMarketingSwitches);
|
|
71
|
+
// ADV-268: reopened from the account page, a category whose cookies are all allowed shows
|
|
72
|
+
// its master switch on (it always started off)
|
|
73
|
+
setAnalyticsMasterSwitch(Object.values(newAnalyticsSwitches).every(Boolean));
|
|
74
|
+
setMarketingMasterSwitch(Object.values(newMarketingSwitches).every(Boolean));
|
|
47
75
|
},
|
|
48
76
|
[]
|
|
49
77
|
);
|
|
@@ -86,7 +114,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
86
114
|
marketing: Object.keys(marketingSwitches).filter(i => !marketingSwitches[i]) || [],
|
|
87
115
|
analytics: Object.keys(analyticsSwitches).filter(i => !analyticsSwitches[i]) || []
|
|
88
116
|
};
|
|
89
|
-
|
|
117
|
+
saveCookieConfig(cookieConfig);
|
|
90
118
|
updateCookieList(handleSentryInit);
|
|
91
119
|
toggleModal();
|
|
92
120
|
};
|
|
@@ -110,34 +138,34 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
110
138
|
return (
|
|
111
139
|
<div className={styles.modalWrapper}>
|
|
112
140
|
<IconSVG name='autodeLogo' customDimensions />
|
|
113
|
-
<div className={styles.modalTitle}>
|
|
114
|
-
<div className={styles.modalContent}>
|
|
141
|
+
<div className={styles.modalTitle}>{tr('title')}</div>
|
|
142
|
+
<div className={styles.modalContent}>{tr('manageText')}</div>
|
|
115
143
|
<div className={styles.accordions}>
|
|
116
144
|
<MaterialAccordionGroup
|
|
117
|
-
title='
|
|
145
|
+
title={tr('necessary.title')}
|
|
118
146
|
// tooltipText='Notwendig'
|
|
119
147
|
withSwitch
|
|
120
148
|
switchProps={necessarySwitchProps}
|
|
121
149
|
>
|
|
122
|
-
<span className={styles.accordionDescription}>
|
|
150
|
+
<span className={styles.accordionDescription}>{tr('necessary.text')}</span>
|
|
123
151
|
{Object.keys(COOKIE_SCHEMA.necessary).map(cookie => {
|
|
124
152
|
const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
|
|
125
153
|
return (
|
|
126
154
|
<div className={styles.switchBlock} key={cookie} >
|
|
127
155
|
<span className={styles.switchBlockTitle}>{cookie}</span>
|
|
128
|
-
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>
|
|
156
|
+
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
|
|
129
157
|
<MaterialSwitch sx={{ marginLeft: 'auto' }} disabled={true} value={true} onChange={() => {}} />
|
|
130
158
|
</div>
|
|
131
159
|
);
|
|
132
160
|
})}
|
|
133
161
|
</MaterialAccordionGroup>
|
|
134
162
|
<MaterialAccordionGroup
|
|
135
|
-
title='
|
|
163
|
+
title={tr('analytics.title')}
|
|
136
164
|
withSwitch
|
|
137
165
|
// tooltipText='Analytisch'
|
|
138
166
|
switchProps={analyticsSwitchProps}
|
|
139
167
|
>
|
|
140
|
-
<span className={styles.accordionDescription}>
|
|
168
|
+
<span className={styles.accordionDescription}>{tr('analytics.text')}</span>
|
|
141
169
|
{Object.keys(COOKIE_SCHEMA.analytics).map(cookie => {
|
|
142
170
|
const getItemsFromCategory = _get(COOKIE_SCHEMA, `analytics['${cookie}']`, null);
|
|
143
171
|
const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
|
|
@@ -145,7 +173,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
145
173
|
return (
|
|
146
174
|
<div className={styles.switchBlock} key={cookie} >
|
|
147
175
|
<span className={styles.switchBlockTitle}>{cookie}</span>
|
|
148
|
-
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>
|
|
176
|
+
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
|
|
149
177
|
<MaterialSwitch
|
|
150
178
|
sx={{ marginLeft: 'auto' }}
|
|
151
179
|
value={isChecked}
|
|
@@ -156,12 +184,12 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
156
184
|
})}
|
|
157
185
|
</MaterialAccordionGroup>
|
|
158
186
|
<MaterialAccordionGroup
|
|
159
|
-
title='
|
|
187
|
+
title={tr('marketing.title')}
|
|
160
188
|
withSwitch
|
|
161
189
|
// tooltipText='Marketing'
|
|
162
190
|
switchProps={marketingSwitchProps}
|
|
163
191
|
>
|
|
164
|
-
<span className={styles.accordionDescription}>
|
|
192
|
+
<span className={styles.accordionDescription}>{tr('marketing.text')}</span>
|
|
165
193
|
{Object.keys(COOKIE_SCHEMA.marketing).map(cookie => {
|
|
166
194
|
const getItemsFromCategory = _get(COOKIE_SCHEMA, `marketing['${cookie}']`, null);
|
|
167
195
|
const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
|
|
@@ -169,7 +197,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
169
197
|
return (
|
|
170
198
|
<div className={styles.switchBlock} key={cookie} >
|
|
171
199
|
<span className={styles.switchBlockTitle}>{cookie}</span>
|
|
172
|
-
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>
|
|
200
|
+
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
|
|
173
201
|
<MaterialSwitch
|
|
174
202
|
sx={{ marginLeft: 'auto' }}
|
|
175
203
|
value={isChecked}
|
|
@@ -181,8 +209,8 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
181
209
|
</MaterialAccordionGroup>
|
|
182
210
|
</div>
|
|
183
211
|
<div className={styles.buttonsContainer}>
|
|
184
|
-
<Button onClick={() => onAccept()} className={classNames(styles.modalBtn, styles.outlinedBtn, styles.zustimmenBtn)} >
|
|
185
|
-
<Button onClick={() => onAccept({ marketing: [], analytics: [] })} className={classNames(styles.modalBtn, styles.zustimmenBtn)}>
|
|
212
|
+
<Button onClick={() => onAccept()} className={classNames(styles.modalBtn, styles.outlinedBtn, styles.zustimmenBtn)} >{tr('saveSelection')}</Button>
|
|
213
|
+
<Button onClick={() => onAccept({ marketing: [], analytics: [] })} className={classNames(styles.modalBtn, styles.zustimmenBtn)}>{tr('acceptAll')}</Button>
|
|
186
214
|
</div>
|
|
187
215
|
</div>
|
|
188
216
|
);
|
|
@@ -3,6 +3,7 @@ import IconSVG from '../../../../iconsvg/IconSVG';
|
|
|
3
3
|
import Button from '../../../Button/Button';
|
|
4
4
|
import styles from './PreviewCookieModal.styl';
|
|
5
5
|
import { updateCookieList } from '../../../../utils/CommonUtils';
|
|
6
|
+
import { saveCookieConfig } from '../../../../utils/cookieConsent';
|
|
6
7
|
import { COOKIE_SCHEMA } from '../../../../constants/common';
|
|
7
8
|
|
|
8
9
|
interface IPreviewCookieModal {
|
|
@@ -14,16 +15,16 @@ interface IPreviewCookieModal {
|
|
|
14
15
|
const PreviewCookieModal = ({ toggleModal, setModal, handleSentryInit } : IPreviewCookieModal) => {
|
|
15
16
|
const environment = window.location.origin;
|
|
16
17
|
const onAcceptAll = () => {
|
|
17
|
-
|
|
18
|
+
saveCookieConfig({ marketing: [], analytics: [] });
|
|
18
19
|
updateCookieList(handleSentryInit);
|
|
19
20
|
toggleModal();
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const onDisableAll = () => {
|
|
23
|
-
|
|
24
|
+
saveCookieConfig({
|
|
24
25
|
marketing: Object.values(COOKIE_SCHEMA.marketing).reduce((acc: string[], val: string[]) => acc.concat(val), []),
|
|
25
26
|
analytics: Object.values(COOKIE_SCHEMA.analytics).reduce((acc: string[], val: string[]) => acc.concat(val), [])
|
|
26
|
-
})
|
|
27
|
+
});
|
|
27
28
|
updateCookieList(handleSentryInit);
|
|
28
29
|
toggleModal();
|
|
29
30
|
};
|
package/compat/Loader/Loader.tsx
CHANGED
|
@@ -10,7 +10,7 @@ export interface ILoaderProps {
|
|
|
10
10
|
fluid?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const Loader: React.FC<ILoaderProps> = ({ className, size, fluid }) => {
|
|
13
|
+
const Loader: React.FC<ILoaderProps> = ({ className = '', size = 'medium', fluid = false }) => {
|
|
14
14
|
const classNames = classnames(
|
|
15
15
|
styles.loader,
|
|
16
16
|
{ [styles[size]]: !fluid },
|
|
@@ -23,10 +23,4 @@ const Loader: React.FC<ILoaderProps> = ({ className, size, fluid }) => {
|
|
|
23
23
|
);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
Loader.defaultProps = {
|
|
27
|
-
className: '',
|
|
28
|
-
size: 'medium',
|
|
29
|
-
fluid: false
|
|
30
|
-
};
|
|
31
|
-
|
|
32
26
|
export default Loader;
|
|
@@ -8,6 +8,7 @@ import * as React from 'react';
|
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
|
|
10
10
|
import Icon from '../../ui/Icon';
|
|
11
|
+
import MfieldCheckIcon from '../../ui/MfieldCheckIcon';
|
|
11
12
|
|
|
12
13
|
export interface MdFieldProps {
|
|
13
14
|
className?: string;
|
|
@@ -32,12 +33,21 @@ export interface MdFieldProps {
|
|
|
32
33
|
* when empty and unfocused, then floats up to the normal small-label spot on focus
|
|
33
34
|
* or once a value is typed. Defaults to false — the static above-field label. */
|
|
34
35
|
floatingLabel?: boolean;
|
|
36
|
+
/** opt-in: show a green check + green border when the field is filled and valid (checkout).
|
|
37
|
+
* Same contract/markup as FormField's own showValid (.mfield--valid/.mfield-ok, md3.css). */
|
|
38
|
+
showValid?: boolean;
|
|
35
39
|
onChange: (value: string, name?: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
40
|
+
/** fires after the field's own internal blur handling (floating-label state). Callers use
|
|
41
|
+
* this to trigger `field.validate()` (mobx-react-form) on blur — this component only owns
|
|
42
|
+
* the `error` prop's display, not when validation actually runs, so without a caller wiring
|
|
43
|
+
* this in, `field.error` never populates from blur and a required-but-empty field never
|
|
44
|
+
* shows its error text/red border until some other validate() call happens to run. */
|
|
45
|
+
onBlur?: () => void;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
39
49
|
className, error, sx, required, disabled, multiline, autoComplete,
|
|
40
|
-
value, type, name, rows, label, placeholder, floatingLabel, maxLength, onChange
|
|
50
|
+
value, type, name, rows, label, placeholder, floatingLabel, maxLength, showValid, onChange, onBlur
|
|
41
51
|
}) => {
|
|
42
52
|
const [reveal, setReveal] = React.useState(false);
|
|
43
53
|
const [focused, setFocused] = React.useState(false);
|
|
@@ -54,6 +64,7 @@ const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
|
54
64
|
// a value is typed, the real <label> appears in its normal static spot above the
|
|
55
65
|
// field and the native placeholder goes quiet — the two never show at the same time.
|
|
56
66
|
const hasValue = value != null && value !== '';
|
|
67
|
+
const isValid = !!showValid && !disabled && !isPassword && !hasError && hasValue;
|
|
57
68
|
const resting = !!floatingLabel && !focused && !hasValue;
|
|
58
69
|
const effectivePlaceholder = floatingLabel ? (resting ? (label || placeholder || '') : '') : (placeholder || '');
|
|
59
70
|
// The real <label> is skipped entirely while resting (see above), leaving the input with
|
|
@@ -71,7 +82,9 @@ const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
|
71
82
|
|
|
72
83
|
return (
|
|
73
84
|
<div className={classnames('mfield-group', className)} style={sx as React.CSSProperties}>
|
|
74
|
-
{
|
|
85
|
+
{/* Non-floating fields (FormField's own call sites don't set floatingLabel) keep the
|
|
86
|
+
plain label-above-the-box row — unchanged, still a .mfield-group flex child. */}
|
|
87
|
+
{label && !resting && !floatingLabel ? (
|
|
75
88
|
<label className='md-label-sm mfield-label' htmlFor={generatedId}>
|
|
76
89
|
{label}{required ? ' *' : ''}
|
|
77
90
|
</label>
|
|
@@ -87,8 +100,18 @@ const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
|
87
100
|
+ (hasError ? ' mfield--error' : '')
|
|
88
101
|
+ (disabled ? ' mfield--disabled' : '')
|
|
89
102
|
+ (floatingLabel ? ' mfield--floating' : '')
|
|
103
|
+
+ (isValid ? ' mfield--valid' : '')
|
|
90
104
|
}
|
|
91
105
|
>
|
|
106
|
+
{/* floatingLabel + floated (focused or has a value): the Material "notched outline"
|
|
107
|
+
treatment — label sits ON the border line, not stacked above it in its own row.
|
|
108
|
+
Lives INSIDE .mfield (not .mfield-group) so it can position against .mfield's own
|
|
109
|
+
edge (.mfield is position:relative already, md3.css) via .mfield-label--notch. */}
|
|
110
|
+
{label && !resting && floatingLabel ? (
|
|
111
|
+
<label className='md-label-sm mfield-label mfield-label--notch' htmlFor={generatedId}>
|
|
112
|
+
{label}{required ? ' *' : ''}
|
|
113
|
+
</label>
|
|
114
|
+
) : null}
|
|
92
115
|
{multiline ? (
|
|
93
116
|
<textarea
|
|
94
117
|
id={generatedId}
|
|
@@ -96,7 +119,7 @@ const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
|
96
119
|
value={value == null ? '' : value}
|
|
97
120
|
onChange={handleChange}
|
|
98
121
|
onFocus={() => setFocused(true)}
|
|
99
|
-
onBlur={() => setFocused(false)}
|
|
122
|
+
onBlur={() => { setFocused(false); onBlur?.(); }}
|
|
100
123
|
disabled={disabled}
|
|
101
124
|
rows={rows || 3}
|
|
102
125
|
maxLength={maxLength}
|
|
@@ -115,7 +138,7 @@ const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
|
115
138
|
value={value == null ? '' : value}
|
|
116
139
|
onChange={handleChange}
|
|
117
140
|
onFocus={() => setFocused(true)}
|
|
118
|
-
onBlur={() => setFocused(false)}
|
|
141
|
+
onBlur={() => { setFocused(false); onBlur?.(); }}
|
|
119
142
|
disabled={disabled}
|
|
120
143
|
maxLength={maxLength}
|
|
121
144
|
placeholder={effectivePlaceholder}
|
|
@@ -137,6 +160,7 @@ const MdField: React.FunctionComponent<MdFieldProps> = ({
|
|
|
137
160
|
<Icon name={reveal ? 'eye-off' : 'eye'} size={18} />
|
|
138
161
|
</button>
|
|
139
162
|
) : null}
|
|
163
|
+
{isValid ? <span className="mfield-ok"><MfieldCheckIcon /></span> : null}
|
|
140
164
|
</div>
|
|
141
165
|
{hasError ? (
|
|
142
166
|
// role="alert" announces this to screen readers the moment it enters the DOM (e.g.
|
|
@@ -41,9 +41,17 @@ const TimePicker = ({
|
|
|
41
41
|
|
|
42
42
|
const endOfTheDayTime = currentDay > 5 || currentDay < 1 ? '17:30:00' : '19:30:00';
|
|
43
43
|
const startOfTheDayTime = currentDay > 5 || currentDay < 1 ? '09:00:00' : '08:30:00';
|
|
44
|
-
const setNewDay = new Date(`${date.toDateString()} ${endOfTheDayTime}`) > date ? 0 : 86400000;
|
|
45
44
|
const interval = 30 * 60 * 1000;
|
|
46
45
|
const roundedTime = new Date(Math.ceil(date / interval) * interval);
|
|
46
|
+
// Today is open while a slot is left: the next half hour must not be past the last one (16:30 on
|
|
47
|
+
// weekends, 19:30 on weekdays). Weekends 16:31–17:29 were still before closing but had no slot
|
|
48
|
+
// left, which crashed the picker on an empty list. A closed today is left out of the dates, as
|
|
49
|
+
// after hours. Today's own weekday decides, not the selected day's.
|
|
50
|
+
const isTodayWeekend = date.getDay() > 5 || date.getDay() < 1;
|
|
51
|
+
const todayEnd = new Date(`${date.toDateString()} ${isTodayWeekend ? '17:30:00' : '19:30:00'}`);
|
|
52
|
+
const todayLastSlot = new Date(`${date.toDateString()} ${isTodayWeekend ? '16:30:00' : '19:30:00'}`);
|
|
53
|
+
const isTodayOpen = todayEnd > date && roundedTime <= todayLastSlot;
|
|
54
|
+
const setNewDay = isTodayOpen ? 0 : 86400000;
|
|
47
55
|
const nextWeekDays = [...Array(7).keys()].map((days, index) => (
|
|
48
56
|
{
|
|
49
57
|
value: index,
|
|
@@ -87,7 +95,9 @@ const TimePicker = ({
|
|
|
87
95
|
dayRanges.push({ time, value: dayRanges.length, label: `${time} - ${rangeTime}` });
|
|
88
96
|
} // time ranges for full day
|
|
89
97
|
|
|
90
|
-
|
|
98
|
+
// today's remaining slots only for today's date: the same weekday a week later gets the full day
|
|
99
|
+
const isTodaySelected = new Date(nextWeekDaysFull[day]).toDateString() === new Date().toDateString();
|
|
100
|
+
return isTodaySelected && isWorkingHours() ? currentDayRanges : dayRanges;
|
|
91
101
|
};
|
|
92
102
|
|
|
93
103
|
useEffect(
|