Skip to content

Commit

Permalink
back to default with just pageContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
harshrajeevsingh committed Nov 4, 2024
1 parent edd8151 commit 4b53746
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,8 @@ import { ErrorInfo, ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

import { GenericErrorFallback } from '@/error-handler/components/GenericErrorFallback';
import { RecordIndexErrorFallback } from '@/error-handler/components/RecordIndexErrorFallback';
import { RecordShowErrorFallback } from '@/error-handler/components/RecordShowErrorFallback';
import { SettingsErrorFallback } from '@/error-handler/components/SettingsErrorFallback';
import { ErrorFallbackType } from '@/error-handler/utils/errorFallbackType';

type AppErrorBoundaryProps = {
children: ReactNode;
errorFallbackType?: ErrorFallbackType;
};

const getFallbackComponent = (type: ErrorFallbackType) => {
switch (type) {
case ErrorFallbackType.Settings:
return SettingsErrorFallback;
case ErrorFallbackType.RecordShow:
return RecordShowErrorFallback;
case ErrorFallbackType.RecordIndex:
return RecordIndexErrorFallback;
default:
return GenericErrorFallback;
}
};

export const AppErrorBoundary = ({
children,
errorFallbackType = ErrorFallbackType.Default,
}: AppErrorBoundaryProps) => {
export const AppErrorBoundary = ({ children }: { children: ReactNode }) => {
const handleError = (_error: Error, _info: ErrorInfo) => {
Sentry.captureException(_error, (scope) => {
scope.setExtras({ _info });
Expand All @@ -39,7 +14,7 @@ export const AppErrorBoundary = ({

return (
<ErrorBoundary
FallbackComponent={getFallbackComponent(errorFallbackType)}
FallbackComponent={GenericErrorFallback}
onError={handleError}
>
{children}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ThemeProvider, useTheme } from '@emotion/react';
import isEmpty from 'lodash.isempty';
import { PageBody } from '@/ui/layout/page/components/PageBody';
import { PageContainer } from '@/ui/layout/page/components/PageContainer';
import { PageHeader } from '@/ui/layout/page/components/PageHeader';
import { useEffect, useState } from 'react';
import { FallbackProps } from 'react-error-boundary';
import { useLocation } from 'react-router-dom';
Expand All @@ -11,7 +12,6 @@ import {
AnimatedPlaceholderEmptyTitle,
Button,
IconRefresh,
THEME_LIGHT,
} from 'twenty-ui';
import { isDeeplyEqual } from '~/utils/isDeeplyEqual';

Expand All @@ -31,27 +31,28 @@ export const GenericErrorFallback = ({
}
}, [previousLocation, location, resetErrorBoundary]);

const theme = useTheme();

return (
<ThemeProvider theme={isEmpty(theme) ? THEME_LIGHT : theme}>
<AnimatedPlaceholderEmptyContainer>
<AnimatedPlaceholder type="errorIndex" />
<AnimatedPlaceholderEmptyTextContainer>
<AnimatedPlaceholderEmptyTitle>
Server’s on a coffee break
</AnimatedPlaceholderEmptyTitle>
<AnimatedPlaceholderEmptySubTitle>
{error.message}
</AnimatedPlaceholderEmptySubTitle>
</AnimatedPlaceholderEmptyTextContainer>
<Button
Icon={IconRefresh}
title="Reload"
variant={'secondary'}
onClick={() => resetErrorBoundary()}
/>
</AnimatedPlaceholderEmptyContainer>
</ThemeProvider>
<PageContainer>
<PageHeader />
<PageBody>
<AnimatedPlaceholderEmptyContainer>
<AnimatedPlaceholder type="errorIndex" />
<AnimatedPlaceholderEmptyTextContainer>
<AnimatedPlaceholderEmptyTitle>
Server’s on a coffee break
</AnimatedPlaceholderEmptyTitle>
<AnimatedPlaceholderEmptySubTitle>
{error.message}
</AnimatedPlaceholderEmptySubTitle>
</AnimatedPlaceholderEmptyTextContainer>
<Button
Icon={IconRefresh}
title="Reload"
variant={'secondary'}
onClick={() => resetErrorBoundary()}
/>
</AnimatedPlaceholderEmptyContainer>
</PageBody>
</PageContainer>
);
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4b53746

Please sign in to comment.