@autobusal/common 1.27.1 → 1.27.3
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/CHANGELOG.md +33 -0
- package/Calendar/Calendar.tsx +23 -2
- package/Calendar/utilities/settings.ts +17 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.27.3
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **The birth-date picker offered today, which the API refuses.** obtapi
|
|
8
|
+
validates with `before:today`, so the calendar was letting you choose an
|
|
9
|
+
answer and then calling it wrong. It now stops at yesterday.
|
|
10
|
+
|
|
11
|
+
The year steps back too when yesterday fell in the previous one: the
|
|
12
|
+
maximum is built from `today.getFullYear() + limits.max.year`, so on 1
|
|
13
|
+
January a month/day of 31 December would otherwise have resolved to the
|
|
14
|
+
coming 31 December rather than the one just gone. Checked against 1
|
|
15
|
+
January, 1 March and a leap year.
|
|
16
|
+
|
|
17
|
+
## 1.27.2
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **A birth date no longer defaults to today.** `Calendar` pre-fills with
|
|
22
|
+
today when given no value, which is right for every other use of it — a
|
|
23
|
+
departure, a report range, a broadcast day — and wrong for exactly one:
|
|
24
|
+
nobody is born today. On the profile-completion form it meant anybody who
|
|
25
|
+
filled in the fields that *looked* empty saved a date of birth of today,
|
|
26
|
+
silently, and that is the field a passenger's age is judged by when they
|
|
27
|
+
book. Reproduced end to end: the row saved `dob = <today>`.
|
|
28
|
+
|
|
29
|
+
`type="dob"` now starts empty so the field reads as unanswered. The picker
|
|
30
|
+
still opens on the current month — `createDate('')` is an Invalid Date and
|
|
31
|
+
the grid built from it renders as nothing — but that anchor is display
|
|
32
|
+
only; what the form submits stays empty until a day is clicked, and
|
|
33
|
+
obtapi's new `required|date_format:d/m/Y|before:today` says so if it is
|
|
34
|
+
left that way.
|
|
35
|
+
|
|
3
36
|
|
|
4
37
|
## 1.27.1
|
|
5
38
|
|
package/Calendar/Calendar.tsx
CHANGED
|
@@ -32,7 +32,24 @@ interface Props {
|
|
|
32
32
|
|
|
33
33
|
const Calendar = ({ type, name, defaultValue, t, validation, minDate, refs, onUpdate, onChange }: Props): JSX.Element => {
|
|
34
34
|
const [ show, setShow ] = useState<boolean>(false);
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-06
|
|
38
|
+
* A BIRTH DATE does not default to today.
|
|
39
|
+
*
|
|
40
|
+
* Defaulting to today is right for every other use of this picker - a
|
|
41
|
+
* departure, a report range, a broadcast day - and wrong for exactly one:
|
|
42
|
+
* nobody is born today. On the profile-completion form it meant anybody
|
|
43
|
+
* who filled in the fields that LOOKED empty saved a date of birth of
|
|
44
|
+
* today, silently, and that is the field a passenger's age is judged by
|
|
45
|
+
* when they book. Reproduced end to end: the row saved dob = today.
|
|
46
|
+
*
|
|
47
|
+
* Empty instead, so the field reads as unanswered and the API's
|
|
48
|
+
* `required|date_format:d/m/Y|before:today` says so if it is left that way.
|
|
49
|
+
*/
|
|
50
|
+
const [ prepared, setPrepared ] = useState<string>(
|
|
51
|
+
defaultValue ?? (type === 'dob' ? '' : prepareDate(new Date()))
|
|
52
|
+
);
|
|
36
53
|
const [ selected, setSelected ] = useState<string>(prepared);
|
|
37
54
|
|
|
38
55
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -57,7 +74,11 @@ const Calendar = ({ type, name, defaultValue, t, validation, minDate, refs, onUp
|
|
|
57
74
|
{ show && (
|
|
58
75
|
<Picker
|
|
59
76
|
type={ type }
|
|
60
|
-
|
|
77
|
+
// An empty birth date still needs a month to OPEN on: createDate('')
|
|
78
|
+
// is an Invalid Date and the grid built from it renders as nothing.
|
|
79
|
+
// The anchor is display only - what the form submits stays empty
|
|
80
|
+
// until a day is actually clicked.
|
|
81
|
+
value={ prepared || prepareDate(new Date()) }
|
|
61
82
|
selected={ selected }
|
|
62
83
|
minDate={ minDate }
|
|
63
84
|
t={ t }
|
|
@@ -82,8 +82,23 @@ export const getLimits = (type: ('picker' | 'dob' | 'date')): CalendarLimit => {
|
|
|
82
82
|
if (type === 'dob') {
|
|
83
83
|
limits.min.year = 100;
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
// Edited: Ferjolt Ozuni - Date: 2026-08-06
|
|
86
|
+
// Up to YESTERDAY, not today. obtapi validates a birth date with
|
|
87
|
+
// `before:today`, and somebody filling in this form was not born this
|
|
88
|
+
// morning - offering a day the API will refuse is a calendar that lets
|
|
89
|
+
// you choose an answer and then calls it wrong.
|
|
90
|
+
//
|
|
91
|
+
// The year is stepped back too when yesterday fell in the previous one,
|
|
92
|
+
// because max.time below is built from `today.getFullYear() +
|
|
93
|
+
// limits.max.year`: on 1 January, month 11 / day 31 without this would
|
|
94
|
+
// resolve to the coming 31 December rather than the one just gone.
|
|
95
|
+
const yesterday = new Date(today.getTime());
|
|
96
|
+
|
|
97
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
98
|
+
|
|
99
|
+
limits.max.year = yesterday.getFullYear() - today.getFullYear();
|
|
100
|
+
limits.max.month = yesterday.getMonth();
|
|
101
|
+
limits.max.day = yesterday.getDate();
|
|
87
102
|
}
|
|
88
103
|
|
|
89
104
|
if (type === 'picker') {
|