
* Bump macaw version * Add changeset * CRM update spacing mapping * Update spacing mapping for invoices app * Update products feed spacing mapping * Fix accordion in webhook status, add trigger button * Update search spacing mapping * Improve the changelog message * Update spacing mapping in EAM app
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import "@saleor/macaw-ui/next/style";
|
|
import "../styles/globals.css";
|
|
|
|
import { AppBridge, AppBridgeProvider } from "@saleor/app-sdk/app-bridge";
|
|
import { RoutePropagator } from "@saleor/app-sdk/app-bridge/next";
|
|
import React, { ReactElement } from "react";
|
|
import { AppProps } from "next/app";
|
|
|
|
import { NoSSRWrapper } from "@saleor/apps-shared";
|
|
import { trpcClient } from "../modules/trpc/trpc-client";
|
|
import { Box, ThemeProvider } from "@saleor/macaw-ui/next";
|
|
|
|
import { NextPage } from "next";
|
|
import { ThemeSynchronizer } from "../lib/theme-synchronizer";
|
|
|
|
/**
|
|
* Ensure instance is a singleton.
|
|
* TODO: This is React 18 issue, consider hiding this workaround inside app-sdk
|
|
*/
|
|
export let appBridgeInstance: AppBridge | undefined;
|
|
|
|
if (typeof window !== "undefined" && !appBridgeInstance) {
|
|
appBridgeInstance = new AppBridge();
|
|
}
|
|
|
|
/**
|
|
* Implementation of layout pattern
|
|
* https://nextjs.org/docs/basic-features/layouts#per-page-layouts
|
|
*
|
|
* In this app, there are pages inside the iframe, which will not use AppBridge etc, so they need
|
|
* to provider custom tree of wrappers
|
|
*/
|
|
export type NextPageWithLayoutOverwrite<P = {}, IP = P> = NextPage<P, IP> & {
|
|
overwriteLayout?: (page: ReactElement) => ReactElement;
|
|
};
|
|
|
|
type AppPropsWithLayout = AppProps & {
|
|
Component: NextPageWithLayoutOverwrite;
|
|
};
|
|
|
|
function NextApp({ Component, pageProps: { session, ...pageProps } }: AppPropsWithLayout) {
|
|
if (Component.overwriteLayout) {
|
|
return Component.overwriteLayout(<Component {...pageProps} />);
|
|
}
|
|
|
|
return (
|
|
<NoSSRWrapper>
|
|
<AppBridgeProvider appBridgeInstance={appBridgeInstance}>
|
|
<ThemeProvider defaultTheme="defaultLight">
|
|
<ThemeSynchronizer />
|
|
<RoutePropagator />
|
|
<Box padding={5} __maxWidth={1440}>
|
|
<Component {...pageProps} />
|
|
</Box>
|
|
</ThemeProvider>
|
|
</AppBridgeProvider>
|
|
</NoSSRWrapper>
|
|
);
|
|
}
|
|
|
|
export default trpcClient.withTRPC(NextApp);
|