2022-01-11 12:34:48 +00:00
|
|
|
import NotFoundPage from "@saleor/components/NotFoundPage";
|
2020-07-22 10:54:15 +00:00
|
|
|
import useNavigator from "@saleor/hooks/useNavigator";
|
|
|
|
import useNotifier from "@saleor/hooks/useNotifier";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
|
|
|
import AppDetailsSettingsPage from "../../components/AppDetailsSettingsPage";
|
|
|
|
import { useAppDetails } from "../../queries";
|
|
|
|
import { appsListPath, appUrl } from "../../urls";
|
|
|
|
|
|
|
|
interface AppDetailsSetttingsProps {
|
|
|
|
id: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const AppDetailsSettings: React.FC<AppDetailsSetttingsProps> = ({
|
|
|
|
id
|
|
|
|
}) => {
|
|
|
|
const { data } = useAppDetails({
|
|
|
|
displayLoader: true,
|
|
|
|
variables: { id }
|
|
|
|
});
|
2022-01-11 12:34:48 +00:00
|
|
|
|
|
|
|
const appExists = data?.app !== null;
|
|
|
|
|
2020-07-22 10:54:15 +00:00
|
|
|
const navigate = useNavigator();
|
|
|
|
const notify = useNotifier();
|
|
|
|
const intl = useIntl();
|
|
|
|
|
2022-01-11 12:34:48 +00:00
|
|
|
if (!appExists) {
|
|
|
|
return <NotFoundPage onBack={() => navigate(appsListPath)} />;
|
|
|
|
}
|
|
|
|
|
2020-07-22 10:54:15 +00:00
|
|
|
return (
|
|
|
|
<AppDetailsSettingsPage
|
|
|
|
data={data?.app}
|
|
|
|
navigateToDashboard={() => navigate(appUrl(id))}
|
|
|
|
onBack={() => navigate(appsListPath)}
|
|
|
|
onError={() =>
|
|
|
|
notify({
|
|
|
|
status: "error",
|
|
|
|
text: intl.formatMessage({
|
|
|
|
defaultMessage: "Failed to fetch app settings",
|
|
|
|
description: "app settings error"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AppDetailsSettings;
|