Commit fe17a36
Pass datasetId into ChartView and guard its data fetch (#183)
* Pass datasetId into ChartView and guard its data fetch
Closes #181, #182.
ChartView previously parsed the dataset id out of `window.location.pathname`,
bypassing React Router and assuming the route shape stays `/dataset/:id`.
Pass `datasetId` from MainDatasetView (already in scope via `useParams`)
as a prop instead, and don't mount the charts until the param is known.
The `/api/${apiCall}` data-fetch in the same effect had no `response.ok`
gate, so a 4xx/5xx body got handed to `response.json()` and either threw
on the HTML or fed nonsense into `setInputsData` / `createChart`. Throw
on non-2xx so the existing catch branch flips loading off and logs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Show an inline error in ChartView when the data fetch fails
Surface the backend error in the chart panel instead of leaving the
spinner up + a silent console.error. Also reset loading and clear any
prior error when the effect re-runs on apiCall / datasetId change, and
refresh the deps comment to mention datasetId.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* encodeURIComponent dataset_id in ChartView fetch
Aligns with MainDatasetView's dataset-metadata fetch and avoids a latent
issue if an ID ever contains URL-special characters.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Abort ChartView's in-flight fetch on dataset change
Without this, navigating between two datasets while the first fetch is
still in flight can let the stale response resolve after the new one,
overwriting setInputsData with data from the wrong dataset. Cancel via
AbortController and swallow the resulting AbortError.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f08d69e commit fe17a36
3 files changed
Lines changed: 69 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
196 | | - | |
197 | | - | |
198 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
199 | 203 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
204 | 217 | | |
205 | 218 | | |
206 | 219 | | |
207 | 220 | | |
208 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
209 | 224 | | |
| 225 | + | |
210 | 226 | | |
211 | | - | |
| 227 | + | |
| 228 | + | |
212 | 229 | | |
213 | 230 | | |
214 | 231 | | |
| |||
230 | 247 | | |
231 | 248 | | |
232 | 249 | | |
233 | | - | |
| 250 | + | |
234 | 251 | | |
235 | 252 | | |
236 | 253 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
243 | 264 | | |
244 | 265 | | |
245 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
0 commit comments