@autobusal/providers 1.30.1 → 1.31.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,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.31.1
4
+
5
+ ### Fixed
6
+
7
+ - **A 422 no longer stacks one toast per query.** The search results page
8
+ asks three endpoints the same question, so a malformed URL rejected three
9
+ times and showed three identical messages. De-duplicated by the first
10
+ field error rather than by the message: Laravel's summary appends "(and N
11
+ more errors)" and each endpoint validates a different rule set, so the
12
+ three strings differ in that count alone while describing one problem.
13
+
14
+ ## 1.31.0
15
+
16
+ ### Added
17
+
18
+ - **`PopularRoutesData`** - the city pairs behind the home page's route
19
+ columns. `from` and `to` arrive localised and `link` is built server-side,
20
+ so the search URL's date and slug rules live in one place.
21
+
3
22
  ## 1.30.1
4
23
 
5
24
  ### Fixed
@@ -116,9 +116,30 @@ apiClient.interceptors.response.use(response => (
116
116
  window.location.href = '/account/documents';
117
117
  }
118
118
 
119
- // if we have a 422 error, we display the message
119
+ /*
120
+ * if we have a 422 error, we display the message
121
+ *
122
+ * Edited: Ferjolt Ozuni - Date: 2026-08-07
123
+ *
124
+ * De-duplicated by the FIRST field error rather than by the message.
125
+ *
126
+ * The results page asks three endpoints (dates, departure, alternatives)
127
+ * the same question, so a malformed URL rejects three times and used to
128
+ * raise three identical toasts. The obvious key - the message itself -
129
+ * does not collapse them: Laravel's summary appends "(and N more
130
+ * errors)", each endpoint validates a different rule set, and so the
131
+ * three strings differ in that count alone while describing one problem.
132
+ *
133
+ * The first entry of `errors` is the same across all three, because it
134
+ * is the same field the visitor got wrong. That is the cause, and the
135
+ * cause is what should be shown once.
136
+ */
120
137
  if (error.response.status === 422) {
121
- systemError(error.response.data.message);
138
+ const first = Object.values(
139
+ (error.response.data.errors ?? {}) as Record<string, string[]>
140
+ )[0]?.[0];
141
+
142
+ systemError(error.response.data.message, first);
122
143
  }
123
144
 
124
145
  // if we have a 500 error, we display a generic error message
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/providers",
3
- "version": "1.30.1",
3
+ "version": "1.31.1",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"
@@ -98,4 +98,22 @@ export interface StopData {
98
98
  id: number
99
99
  name: string
100
100
  location: string[]
101
- }
101
+ }
102
+ /**
103
+ * A city pair people buy, for the home page's route columns.
104
+ *
105
+ * Ferjolt Ozuni - Date: 2026-08-07
106
+ * `from` and `to` are already localised city names, and `link` is a search
107
+ * built server-side - the client renders it and never assembles one, so the
108
+ * date and slug rules live in exactly one place (Traits\Orderable).
109
+ */
110
+ export interface PopularRouteData {
111
+ from: string
112
+ to: string
113
+ link: string
114
+ }
115
+
116
+ export interface PopularRoutesData {
117
+ top: PopularRouteData[]
118
+ trending: PopularRouteData[]
119
+ }