Add error handling to non-existent apps (#1723)
This commit is contained in:
parent
d4a28fedf2
commit
ed262f913d
2 changed files with 32 additions and 12 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
||||||
import useNavigator from "@saleor/hooks/useNavigator";
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
import useNotifier from "@saleor/hooks/useNotifier";
|
import useNotifier from "@saleor/hooks/useNotifier";
|
||||||
import getAppErrorMessage from "@saleor/utils/errors/app";
|
import getAppErrorMessage from "@saleor/utils/errors/app";
|
||||||
|
@ -31,6 +32,9 @@ export const AppDetails: React.FC<AppDetailsProps> = ({ id, params }) => {
|
||||||
displayLoader: true,
|
displayLoader: true,
|
||||||
variables: { id }
|
variables: { id }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const appExists = data?.app !== null;
|
||||||
|
|
||||||
const navigate = useNavigator();
|
const navigate = useNavigator();
|
||||||
const notify = useNotifier();
|
const notify = useNotifier();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
@ -49,12 +53,14 @@ export const AppDetails: React.FC<AppDetailsProps> = ({ id, params }) => {
|
||||||
refetch();
|
refetch();
|
||||||
closeModal();
|
closeModal();
|
||||||
} else {
|
} else {
|
||||||
errors.forEach(error =>
|
if (appExists) {
|
||||||
notify({
|
errors.forEach(error =>
|
||||||
status: "error",
|
notify({
|
||||||
text: getAppErrorMessage(error, intl)
|
status: "error",
|
||||||
})
|
text: getAppErrorMessage(error, intl)
|
||||||
);
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -72,12 +78,14 @@ export const AppDetails: React.FC<AppDetailsProps> = ({ id, params }) => {
|
||||||
refetch();
|
refetch();
|
||||||
closeModal();
|
closeModal();
|
||||||
} else {
|
} else {
|
||||||
errors.forEach(error =>
|
if (appExists) {
|
||||||
notify({
|
errors.forEach(error =>
|
||||||
status: "error",
|
notify({
|
||||||
text: getAppErrorMessage(error, intl)
|
status: "error",
|
||||||
})
|
text: getAppErrorMessage(error, intl)
|
||||||
);
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -94,6 +102,10 @@ export const AppDetails: React.FC<AppDetailsProps> = ({ id, params }) => {
|
||||||
deactivateApp(mutationOpts);
|
deactivateApp(mutationOpts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!appExists) {
|
||||||
|
return <NotFoundPage onBack={() => navigate(appsListPath)} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AppActivateDialog
|
<AppActivateDialog
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
||||||
import useNavigator from "@saleor/hooks/useNavigator";
|
import useNavigator from "@saleor/hooks/useNavigator";
|
||||||
import useNotifier from "@saleor/hooks/useNotifier";
|
import useNotifier from "@saleor/hooks/useNotifier";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -18,10 +19,17 @@ export const AppDetailsSettings: React.FC<AppDetailsSetttingsProps> = ({
|
||||||
displayLoader: true,
|
displayLoader: true,
|
||||||
variables: { id }
|
variables: { id }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const appExists = data?.app !== null;
|
||||||
|
|
||||||
const navigate = useNavigator();
|
const navigate = useNavigator();
|
||||||
const notify = useNotifier();
|
const notify = useNotifier();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
|
if (!appExists) {
|
||||||
|
return <NotFoundPage onBack={() => navigate(appsListPath)} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppDetailsSettingsPage
|
<AppDetailsSettingsPage
|
||||||
data={data?.app}
|
data={data?.app}
|
||||||
|
|
Loading…
Reference in a new issue