@civicactions/cmsds-open-data-components 4.1.6 → 4.1.7-alpha.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/dist/main.js +47 -4
- package/dist/main.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3474,7 +3474,18 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
|
|
|
3474
3474
|
}, {
|
|
3475
3475
|
encode: true
|
|
3476
3476
|
})}&format=csv`;
|
|
3477
|
-
|
|
3477
|
+
const useDatastoreErrorMessages = {
|
|
3478
|
+
400: {
|
|
3479
|
+
title: 'Data unavailable',
|
|
3480
|
+
message: 'This data is not available for preview at this time. Please try again later.'
|
|
3481
|
+
},
|
|
3482
|
+
500: {
|
|
3483
|
+
title: 'Something went wrong',
|
|
3484
|
+
message: 'Something went wrong on our end. Please try again later.'
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
// Data loaded successfully
|
|
3488
|
+
if (!resource.error && Object.keys(resource).length && columns.length && resource.schema && Object.keys(distribution).length) return /*#__PURE__*/ (0, $hgUW1$jsxs)((0, $hgUW1$Fragment), {
|
|
3478
3489
|
children: [
|
|
3479
3490
|
/*#__PURE__*/ (0, $hgUW1$jsx)("div", {
|
|
3480
3491
|
className: isModal ? 'dkan-datatable-fullscreen-mode' : '',
|
|
@@ -3525,7 +3536,28 @@ const $a35cf16d1488f54e$var$DatasetTable = ({ isModal: isModal = false, showCopy
|
|
|
3525
3536
|
})
|
|
3526
3537
|
]
|
|
3527
3538
|
});
|
|
3528
|
-
else
|
|
3539
|
+
else if (resource.error && !resource.loading) {
|
|
3540
|
+
const resourceErrorStatus = resource.error.status in useDatastoreErrorMessages ? resource.error.status : 500;
|
|
3541
|
+
return /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
|
|
3542
|
+
children: [
|
|
3543
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("h2", {
|
|
3544
|
+
className: "ds-text-heading--lg ds-u-margin--0 ds-u-color--primary",
|
|
3545
|
+
children: useDatastoreErrorMessages[resourceErrorStatus].title
|
|
3546
|
+
}),
|
|
3547
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)("p", {
|
|
3548
|
+
className: "ds-u-padding-bottom--2 ds-u-margin-bottom--7",
|
|
3549
|
+
children: useDatastoreErrorMessages[resourceErrorStatus].message
|
|
3550
|
+
}),
|
|
3551
|
+
/*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Button), {
|
|
3552
|
+
href: "/",
|
|
3553
|
+
variation: "solid",
|
|
3554
|
+
className: "",
|
|
3555
|
+
children: "Go to home"
|
|
3556
|
+
})
|
|
3557
|
+
]
|
|
3558
|
+
});
|
|
3559
|
+
// Data loading
|
|
3560
|
+
} else return /*#__PURE__*/ (0, $hgUW1$jsx)((0, $hgUW1$Spinner), {
|
|
3529
3561
|
"aria-valuetext": "Dataset loading",
|
|
3530
3562
|
role: "status",
|
|
3531
3563
|
className: "ds-u-margin--3"
|
|
@@ -6034,13 +6066,23 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
6034
6066
|
}
|
|
6035
6067
|
// Change whether distribution API or dataset API is used based on option
|
|
6036
6068
|
const queryID = useDatasetAPI && datasetID ? `${datasetID}/0` : id;
|
|
6069
|
+
async function fetchJson(url) {
|
|
6070
|
+
const res = await fetch(url);
|
|
6071
|
+
const body = await res.json().catch(()=>({}));
|
|
6072
|
+
if (!res.ok) {
|
|
6073
|
+
const err = new Error(body.message || body.error || res.statusText);
|
|
6074
|
+
err.status = res.status;
|
|
6075
|
+
throw err;
|
|
6076
|
+
}
|
|
6077
|
+
return body;
|
|
6078
|
+
}
|
|
6037
6079
|
const { data: data, isPending: isPending, error: error } = (0, $hgUW1$useQuery)({
|
|
6038
6080
|
queryKey: [
|
|
6039
6081
|
"datastore" + id + paramsString
|
|
6040
6082
|
],
|
|
6041
6083
|
queryFn: ()=>{
|
|
6042
6084
|
setCount(null);
|
|
6043
|
-
return
|
|
6085
|
+
return fetchJson(`${rootUrl}/datastore/query/${queryID}?${paramsString}`);
|
|
6044
6086
|
},
|
|
6045
6087
|
enabled: enabled
|
|
6046
6088
|
});
|
|
@@ -6054,7 +6096,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
6054
6096
|
count: true,
|
|
6055
6097
|
schema: true
|
|
6056
6098
|
};
|
|
6057
|
-
return
|
|
6099
|
+
return fetchJson(`${rootUrl}/datastore/query/${queryID}?${(0, $hgUW1$qs).stringify((0, $6d5c0212e738499b$export$34e95918366a058e)(unfilteredParams, ACA))}`);
|
|
6058
6100
|
}
|
|
6059
6101
|
});
|
|
6060
6102
|
(0, $hgUW1$useEffect)(()=>{
|
|
@@ -6077,6 +6119,7 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
|
|
|
6077
6119
|
]);
|
|
6078
6120
|
return {
|
|
6079
6121
|
loading: enabled ? isPending : false,
|
|
6122
|
+
error: error,
|
|
6080
6123
|
values: values,
|
|
6081
6124
|
count: count,
|
|
6082
6125
|
columns: columns,
|