2023-03-16 10:17:00 +00:00
|
|
|
import { useAppBridge } from "@saleor/app-sdk/app-bridge";
|
|
|
|
import { NextPage } from "next";
|
|
|
|
import { useRouter } from "next/router";
|
2023-04-06 10:56:44 +00:00
|
|
|
import { useEffect } from "react";
|
2023-03-16 10:17:00 +00:00
|
|
|
import { useIsMounted } from "usehooks-ts";
|
2023-04-06 10:56:44 +00:00
|
|
|
import { isInIframe } from "@saleor/apps-shared";
|
2023-03-16 10:17:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is page publicly accessible from your app.
|
|
|
|
* You should probably remove it.
|
|
|
|
*/
|
|
|
|
const IndexPage: NextPage = () => {
|
|
|
|
const { appBridgeState } = useAppBridge();
|
|
|
|
const isMounted = useIsMounted();
|
|
|
|
const { replace } = useRouter();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (isMounted() && appBridgeState?.ready) {
|
2023-04-06 10:56:44 +00:00
|
|
|
replace("/home");
|
2023-03-16 10:17:00 +00:00
|
|
|
}
|
2023-04-06 10:56:44 +00:00
|
|
|
}, [isMounted, appBridgeState?.ready, replace]);
|
|
|
|
|
|
|
|
if (isInIframe()) {
|
|
|
|
return null;
|
|
|
|
}
|
2023-03-16 10:17:00 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1>Saleor CMS Hub</h1>
|
|
|
|
<p>This is Saleor App that allows to use external cms providers to sync products data.</p>
|
|
|
|
<p>Install the app in your Saleor instance and open it in Dashboard.</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IndexPage;
|