mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-25 01:45:23 +08:00
fix(web): unify load error states and retry actions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import LoadErrorState from '@/components/LoadErrorState';
|
||||
|
||||
export default function EntityLoadState({
|
||||
error = false,
|
||||
@@ -10,27 +10,15 @@ export default function EntityLoadState({
|
||||
onRetry?: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
if (error) return <LoadErrorState onRetry={onRetry} className="flex-1" />;
|
||||
return (
|
||||
<div
|
||||
role={error ? 'alert' : 'status'}
|
||||
aria-busy={!error}
|
||||
role="status"
|
||||
aria-busy="true"
|
||||
className="flex min-h-40 flex-1 flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground"
|
||||
>
|
||||
{error ? (
|
||||
<>
|
||||
<p>{t('common.loadFailed')}</p>
|
||||
{onRetry && (
|
||||
<Button type="button" variant="outline" onClick={onRetry}>
|
||||
{t('common.retry')}
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Loader2 aria-hidden="true" className="size-5 animate-spin" />
|
||||
<p>{t('common.loading')}</p>
|
||||
</>
|
||||
)}
|
||||
<Loader2 aria-hidden="true" className="size-5 animate-spin" />
|
||||
<p>{t('common.loading')}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user