diff --git a/src/apps/views/AppDetails/AppDetails.tsx b/src/apps/views/AppDetails/AppDetails.tsx index 6ab1138ec..edfb00ffd 100644 --- a/src/apps/views/AppDetails/AppDetails.tsx +++ b/src/apps/views/AppDetails/AppDetails.tsx @@ -1,3 +1,4 @@ +import NotFoundPage from "@saleor/components/NotFoundPage"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; import getAppErrorMessage from "@saleor/utils/errors/app"; @@ -31,6 +32,9 @@ export const AppDetails: React.FC = ({ id, params }) => { displayLoader: true, variables: { id } }); + + const appExists = data?.app !== null; + const navigate = useNavigator(); const notify = useNotifier(); const intl = useIntl(); @@ -49,12 +53,14 @@ export const AppDetails: React.FC = ({ id, params }) => { refetch(); closeModal(); } else { - errors.forEach(error => - notify({ - status: "error", - text: getAppErrorMessage(error, intl) - }) - ); + if (appExists) { + errors.forEach(error => + notify({ + status: "error", + text: getAppErrorMessage(error, intl) + }) + ); + } } } }); @@ -72,12 +78,14 @@ export const AppDetails: React.FC = ({ id, params }) => { refetch(); closeModal(); } else { - errors.forEach(error => - notify({ - status: "error", - text: getAppErrorMessage(error, intl) - }) - ); + if (appExists) { + errors.forEach(error => + notify({ + status: "error", + text: getAppErrorMessage(error, intl) + }) + ); + } } } }); @@ -94,6 +102,10 @@ export const AppDetails: React.FC = ({ id, params }) => { deactivateApp(mutationOpts); }; + if (!appExists) { + return navigate(appsListPath)} />; + } + return ( <> = ({ displayLoader: true, variables: { id } }); + + const appExists = data?.app !== null; + const navigate = useNavigator(); const notify = useNotifier(); const intl = useIntl(); + if (!appExists) { + return navigate(appsListPath)} />; + } + return (