From 6ff68731644f5877a7ede3dd67d5549e5c78be53 Mon Sep 17 00:00:00 2001 From: Aurora Scharff Date: Fri, 25 Sep 2026 08:30:44 +0200 Subject: [PATCH 1/2] Show loading state while retrying errors --- components/ui/error-state.tsx | 36 +++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/components/ui/error-state.tsx b/components/ui/error-state.tsx index c9381c8..ea10be0 100644 --- a/components/ui/error-state.tsx +++ b/components/ui/error-state.tsx @@ -1,9 +1,37 @@ 'use client'; +import { useTransition } from 'react'; import { BrandMark } from '@/components/ui/brand-mark'; import { Button } from '@/components/ui/button'; +import { Spinner } from '@/components/ui/spinner'; import { cn } from '@/lib/utils'; +function RetryButton({ + className, + onRetry, + size, +}: { + className?: string; + onRetry: () => void; + size?: 'sm'; +}) { + const [isPending, startTransition] = useTransition(); + + return ( + + ); +} + export function ErrorState({ body, className, @@ -24,9 +52,7 @@ export function ErrorState({

{title}

{body}

- + ); @@ -42,9 +68,7 @@ export function ErrorState({

{title}

{body}

- + ); } From b07cfd45553d820d12b41353c667606549fe21de Mon Sep 17 00:00:00 2001 From: Aurora Scharff Date: Fri, 25 Sep 2026 08:35:42 +0200 Subject: [PATCH 2/2] Inline retry pending state --- app/(travel)/book/[flightId]/[step]/error.tsx | 19 +++++++++- app/(travel)/error.tsx | 19 +++++++++- app/error.tsx | 19 +++++++++- components/ui/error-boundary.tsx | 19 +++++++++- components/ui/error-state.tsx | 38 +++---------------- 5 files changed, 73 insertions(+), 41 deletions(-) diff --git a/app/(travel)/book/[flightId]/[step]/error.tsx b/app/(travel)/book/[flightId]/[step]/error.tsx index 627d0a2..1c72928 100644 --- a/app/(travel)/book/[flightId]/[step]/error.tsx +++ b/app/(travel)/book/[flightId]/[step]/error.tsx @@ -1,13 +1,28 @@ 'use client'; +import { useTransition } from 'react'; +import { Button } from '@/components/ui/button'; import { ErrorState } from '@/components/ui/error-state'; +import { Spinner } from '@/components/ui/spinner'; export default function Error({ retry }: { error: Error & { digest?: string }; retry: () => void }) { + const [isPending, startTransition] = useTransition(); + return ( + > + + ); } diff --git a/app/(travel)/error.tsx b/app/(travel)/error.tsx index 0bbe5fc..b543864 100644 --- a/app/(travel)/error.tsx +++ b/app/(travel)/error.tsx @@ -1,15 +1,30 @@ 'use client'; +import { useTransition } from 'react'; +import { Button } from '@/components/ui/button'; import { ErrorState } from '@/components/ui/error-state'; +import { Spinner } from '@/components/ui/spinner'; export default function Error({ retry }: { error: Error & { digest?: string }; retry: () => void }) { + const [isPending, startTransition] = useTransition(); + return ( + > + + ); } diff --git a/app/error.tsx b/app/error.tsx index fd2a627..8a521e9 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -1,15 +1,30 @@ 'use client'; +import { useTransition } from 'react'; +import { Button } from '@/components/ui/button'; import { ErrorState } from '@/components/ui/error-state'; +import { Spinner } from '@/components/ui/spinner'; export default function Error({ retry }: { error: Error & { digest?: string }; retry: () => void }) { + const [isPending, startTransition] = useTransition(); + return ( + > + + ); } diff --git a/components/ui/error-boundary.tsx b/components/ui/error-boundary.tsx index 1bc4425..88c5e94 100644 --- a/components/ui/error-boundary.tsx +++ b/components/ui/error-boundary.tsx @@ -1,15 +1,30 @@ 'use client'; import { catchError, type ErrorInfo } from 'next/error'; +import { useTransition } from 'react'; +import { Button } from '@/components/ui/button'; import { ErrorState } from '@/components/ui/error-state'; +import { Spinner } from '@/components/ui/spinner'; function ErrorFallback(props: { title?: string }, { retry }: ErrorInfo) { + const [isPending, startTransition] = useTransition(); + return ( + > + + ); } diff --git a/components/ui/error-state.tsx b/components/ui/error-state.tsx index ea10be0..043ab56 100644 --- a/components/ui/error-state.tsx +++ b/components/ui/error-state.tsx @@ -1,47 +1,19 @@ 'use client'; -import { useTransition } from 'react'; +import type { ReactNode } from 'react'; import { BrandMark } from '@/components/ui/brand-mark'; -import { Button } from '@/components/ui/button'; -import { Spinner } from '@/components/ui/spinner'; import { cn } from '@/lib/utils'; -function RetryButton({ - className, - onRetry, - size, -}: { - className?: string; - onRetry: () => void; - size?: 'sm'; -}) { - const [isPending, startTransition] = useTransition(); - - return ( - - ); -} - export function ErrorState({ body, + children, className, - onRetry, title, variant = 'section', }: { body: string; + children: ReactNode; className?: string; - onRetry: () => void; title: string; variant?: 'page' | 'section'; }) { @@ -52,7 +24,7 @@ export function ErrorState({

{title}

{body}

- +
{children}
); @@ -68,7 +40,7 @@ export function ErrorState({

{title}

{body}

- + {children} ); }