Files
plane/apps/web/core/lib/wrappers/instance-wrapper.tsx
T
Prateek ShouryaandGitHub 9cfde896b3 [WEB-5134] refactor: update web ESLint configuration and refactor imports to use type imports (#7957)
* [WEB-5134] refactor: update `web` ESLint configuration and refactor imports to use type imports

- Enhanced ESLint configuration by adding new rules for import consistency and type imports.
- Refactored multiple files to replace regular imports with type imports for better clarity and performance.
- Ensured consistent use of type imports across the application to align with TypeScript best practices.

* refactor: standardize type imports across components

- Updated multiple files to replace regular imports with type imports for improved clarity and consistency.
- Ensured adherence to TypeScript best practices in the rich filters and issue layouts components.
2025-10-14 16:45:07 +05:30

43 lines
1.3 KiB
TypeScript

import type { FC, ReactNode } from "react";
import { observer } from "mobx-react";
import useSWR from "swr";
// components
import { LogoSpinner } from "@/components/common/logo-spinner";
import { InstanceNotReady, MaintenanceView } from "@/components/instance";
// hooks
import { useInstance } from "@/hooks/store/use-instance";
type TInstanceWrapper = {
children: ReactNode;
};
export const InstanceWrapper: FC<TInstanceWrapper> = observer((props) => {
const { children } = props;
// store
const { isLoading, instance, error, fetchInstanceInfo } = useInstance();
const { isLoading: isInstanceSWRLoading, error: instanceSWRError } = useSWR(
"INSTANCE_INFORMATION",
async () => await fetchInstanceInfo(),
{ revalidateOnFocus: false }
);
// loading state
if ((isLoading || isInstanceSWRLoading) && !instance)
return (
<div className="relative flex h-screen w-full items-center justify-center">
<LogoSpinner />
</div>
);
if (instanceSWRError) return <MaintenanceView />;
// something went wrong while in the request
if (error && error?.status === "error") return <>{children}</>;
// instance is not ready and setup is not done
if (instance?.is_setup_done === false) return <InstanceNotReady />;
return <>{children}</>;
});