2023-02-07 18:11:39 +00:00
|
|
|
import { NextPage } from "next";
|
|
|
|
import { useAppBridge } from "@saleor/app-sdk/app-bridge";
|
|
|
|
import { useEffect } from "react";
|
|
|
|
import { useIsMounted } from "usehooks-ts";
|
|
|
|
import { useRouter } from "next/router";
|
2023-02-09 17:41:23 +00:00
|
|
|
import { isInIframe } from "@saleor/apps-shared";
|
2023-02-07 18:11:39 +00:00
|
|
|
import { LinearProgress } from "@material-ui/core";
|
|
|
|
|
|
|
|
const IndexPage: NextPage = () => {
|
|
|
|
const { appBridgeState } = useAppBridge();
|
|
|
|
const isMounted = useIsMounted();
|
|
|
|
const { replace } = useRouter();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (isMounted() && appBridgeState?.ready) {
|
|
|
|
replace("/importer");
|
|
|
|
}
|
|
|
|
}, [isMounted, appBridgeState?.ready, replace]);
|
|
|
|
|
|
|
|
if (isInIframe()) {
|
|
|
|
return <LinearProgress />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1>Saleor Data Importer</h1>
|
|
|
|
<p>This is Saleor App that allows importing data from CSV</p>
|
|
|
|
<p>Install app in your Saleor instance and open in with Dashboard</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IndexPage;
|