Fix ClientConfig async loading --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
23 lines
662 B
TypeScript
23 lines
662 B
TypeScript
import { useRecoilValue } from 'recoil';
|
|
|
|
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
|
|
import { AppFullScreenErrorFallback } from '@/error-handler/components/AppFullScreenErrorFallback';
|
|
|
|
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
|
|
children,
|
|
}) => {
|
|
const { isErrored, error } = useRecoilValue(clientConfigApiStatusState);
|
|
|
|
return isErrored && error instanceof Error ? (
|
|
<AppFullScreenErrorFallback
|
|
error={error}
|
|
resetErrorBoundary={() => {
|
|
window.location.reload();
|
|
}}
|
|
title="Unable to Reach Back-end"
|
|
/>
|
|
) : (
|
|
children
|
|
);
|
|
};
|