Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #219 [Show proper message when Raw data API is down] #265

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions frontend/src/components/Layout/TrainingDS/DatasetEditor/AOI.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const AOI = (props) => {
const [openSnack, setOpenSnack] = useState(false);
const [fileError, setFileError] = useState(null);
const [geoJsonFile, setGeoJsonFile] = useState(null);
const [fetchError, setFetchError] = useState(null);

let _DATA = usePagination(
props.mapLayers.filter((e) => e.type === "aoi"),
PER_PAGE
Expand All @@ -80,6 +82,7 @@ const AOI = (props) => {

const { accessToken } = useContext(AuthContext);
const fetchOSMLebels = async (aoiId) => {
setFetchError(null);
try {
const headers = {
"access-token": accessToken,
Expand All @@ -91,15 +94,21 @@ const AOI = (props) => {

if (res.error) {
console.log(res.error.response.statusText);
setFetchError("Failed to fetch OSM data. Please try again.");
} else {
return res.data;
}
} catch (e) {
console.log("isError", e);
setFetchError("Failed to fetch OSM data. Please check your connection.");
}
};
const { mutate: mutateFetch, data: fetchResult } =
useMutation(fetchOSMLebels);

const { mutate: mutateFetch } = useMutation(fetchOSMLebels, {
onError: () => {
setFetchError("Failed to fetch OSM data. Please try again.");
},
});

const DeleteAOI = async (id, leafletId) => {
try {
Expand Down Expand Up @@ -408,6 +417,11 @@ const AOI = (props) => {
))}
</List>
</Demo>
{fetchError && (
<Typography variant="body2">
{fetchError}
</Typography>
)}
{props.mapLayers && props.mapLayers.length === 0 && (
<Typography variant="body1" component="h2">
No TAs yet, start creating one by clicking Draw a rectangle, 3rd
Expand Down