fix(web): unify load error states and retry actions

This commit is contained in:
Hyu
2026-10-09 21:00:27 +08:00
parent cdc4086dea
commit ce3a9020af
19 changed files with 141 additions and 130 deletions
+6 -18
View File
@@ -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>
);
}