@autobusal/providers 1.31.0 → 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,16 @@
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
+
3
14
  ## 1.31.0
4
15
 
5
16
  ### Added
@@ -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.31.0",
3
+ "version": "1.31.1",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"