25 lines
812 B
TypeScript
25 lines
812 B
TypeScript
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
|
|
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
|
|
import { AppFullScreenErrorFallback } from '@/error-handler/components/AppFullScreenErrorFallback';
|
|
import { useLingui } from '@lingui/react/macro';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
export const ClientConfigErrorGate: React.FC<React.PropsWithChildren> = ({
|
|
children,
|
|
}) => {
|
|
const { error } = useAtomStateValue(clientConfigApiStatusState);
|
|
const { t } = useLingui();
|
|
|
|
return isDefined(error) ? (
|
|
<AppFullScreenErrorFallback
|
|
error={error}
|
|
resetErrorBoundary={() => {
|
|
window.location.reload();
|
|
}}
|
|
title={t`Unable to Reach Back-end`}
|
|
/>
|
|
) : (
|
|
children
|
|
);
|
|
};
|