diff --git a/client/cms/src/lib/types.ts b/client/cms/src/lib/types.ts new file mode 100644 index 0000000..fa81fc9 --- /dev/null +++ b/client/cms/src/lib/types.ts @@ -0,0 +1,6 @@ +export interface RawError { + code: number; + status: string; + error_id: string; + data: null; +} diff --git a/client/cms/src/routes/_workbenchLayout/profile.$userId.tsx b/client/cms/src/routes/_workbenchLayout/profile.$userId.tsx index f502805..73e352a 100644 --- a/client/cms/src/routes/_workbenchLayout/profile.$userId.tsx +++ b/client/cms/src/routes/_workbenchLayout/profile.$userId.tsx @@ -1,28 +1,26 @@ +import type { RawError } from '@/lib/types'; import { createFileRoute } from '@tanstack/react-router'; import { Suspense } from 'react'; -import { ErrorBoundary } from 'react-error-boundary'; import { ProfileContainer } from '@/components/profile/profile.container'; import { ProfileError } from '@/components/profile/profile.error'; import { ProfileSkeleton } from '@/components/profile/profile.skeleton'; export const Route = createFileRoute('/_workbenchLayout/profile/$userId')({ component: RouteComponent, + errorComponent: ({ error }) => { + if ((error as unknown as RawError).code === 403) + return ; + else return ; + }, }); function RouteComponent() { const { userId } = Route.useParams(); return (
- { - if ((error.error as { code: number }).code === 403) - return ; - else return ; - }} - > - }> - - - + }> + +
); } diff --git a/client/cms/src/routes/_workbenchLayout/profile.index.tsx b/client/cms/src/routes/_workbenchLayout/profile.index.tsx index c4add66..db4ea2d 100644 --- a/client/cms/src/routes/_workbenchLayout/profile.index.tsx +++ b/client/cms/src/routes/_workbenchLayout/profile.index.tsx @@ -1,21 +1,21 @@ import { createFileRoute, Navigate } from '@tanstack/react-router'; import { Suspense } from 'react'; -import { ErrorBoundary } from 'react-error-boundary'; import { ProfileError } from '@/components/profile/profile.error'; import { ProfileSkeleton } from '@/components/profile/profile.skeleton'; import { useUserInfo } from '@/hooks/data/useUserInfo'; export const Route = createFileRoute('/_workbenchLayout/profile/')({ component: RouteComponent, + errorComponent: () => { + return ; + }, }); function RouteComponent() { const { data } = useUserInfo(); return ( - }> - }> - - - + }> + + ); }