@autobusal/utilities 1.4.0 → 1.4.1

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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## 1.4.1
5
+
6
+ ### Changed
7
+
8
+ - **Gender can be "not declared".** `getOptionsSex` gains it as the first
9
+ option and `getSex` reports it, instead of treating everything that is not
10
+ `1` as male — which is what three existing rows with no value were already
11
+ rendering as.
12
+
13
+ Carried by `null`: the `visitors`.`sex` column has always been nullable, so
14
+ nothing migrated. The option's id is `''`, which Laravel's
15
+ `ConvertEmptyStringsToNull` turns into a real null on the way in, so "not
16
+ declared" is the *absence* of a value at every layer rather than a magic
17
+ number each one has to learn.
18
+
19
+ Deliberately not shared with the checkout passenger forms — those build
20
+ their own field, and gender there is a per-route requirement a carrier can
21
+ insist on. A profile is the person; a passenger record is what a carrier
22
+ demands in order to board them.
23
+
3
24
  ## 1.4.0
4
25
 
5
26
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/utilities",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/passengers.ts CHANGED
@@ -1,15 +1,45 @@
1
1
  import { TFunction } from 'i18next';
2
2
 
3
- export const getSex = (value: number): string => (
4
- value === 1 ? 'female' : 'male'
5
- );
3
+ /**
4
+ * Edited: Ferjolt Ozuni - Date: 2026-08-06
5
+ *
6
+ * Gender is OPTIONAL on a profile, and "not declared" is a real answer
7
+ * rather than a missing one.
8
+ *
9
+ * `null` carries it - `visitors`.`sex` has always been nullable and already
10
+ * held rows with no value, so nothing needed migrating. What was missing was
11
+ * any way to SAY it: the select offered Male and Female, the profile form
12
+ * defaulted to Male, and anybody who never touched the field was recorded as
13
+ * male. Three such rows existed already and rendered as "male" here, because
14
+ * this treated everything that was not 1 as male.
15
+ *
16
+ * Deliberately NOT shared with the passenger forms at checkout: those build
17
+ * their own field (routes-order's Gender), and gender there is a per-route
18
+ * requirement a carrier can insist on. A profile is the person; a passenger
19
+ * record is what a carrier demands in order to board them, and those are
20
+ * different questions.
21
+ */
22
+ export const getSex = (value?: number | null): string => {
23
+ if (value === null || value === undefined) {
24
+ return 'undeclared';
25
+ }
26
+
27
+ return value === 1 ? 'female' : 'male';
28
+ };
6
29
 
7
30
  export const getOptionsSex = (t: TFunction<'common'>) => ([
8
31
  {
32
+ // Empty rather than a third numeric code: Laravel's
33
+ // ConvertEmptyStringsToNull turns it into a real null on the way in, so
34
+ // "not declared" is the ABSENCE of a value at every layer rather than a
35
+ // magic number each of them has to learn.
36
+ id: '',
37
+ name: t('data.gender.undeclared', { ns: 'common' })
38
+ }, {
9
39
  id: 0,
10
40
  name: t('data.gender.male', { ns: 'common' })
11
41
  }, {
12
42
  id: 1,
13
43
  name: t('data.gender.female', { ns: 'common' })
14
44
  }
15
- ]);
45
+ ]);