mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-01 03:03:28 -05:00
cac02c77a1
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
21 lines
480 B
TypeScript
21 lines
480 B
TypeScript
import { ReactNode } from "react";
|
|
import { ErrorComponent } from "../ErrorComponent";
|
|
import LoadingSpinner from "../LoadingSpinner";
|
|
|
|
type AccessWrapperProps = {
|
|
isLoading: boolean;
|
|
children: ReactNode;
|
|
error: string;
|
|
};
|
|
|
|
export const LoadingWrapper = ({ isLoading, children, error }: AccessWrapperProps) => {
|
|
if (isLoading) return <LoadingSpinner />;
|
|
|
|
if (error.length > 0) {
|
|
console.error(error);
|
|
return <ErrorComponent />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
};
|