papayu/desktop/ui/src/components/ErrorDisplay.tsx
2026-02-11 22:00:43 +03:00

34 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect } from 'react';
import { useAppStore } from '../store/app-store';
export function ErrorDisplay() {
const error = useAppStore((s) => s.error);
const setError = useAppStore((s) => s.setError);
useEffect(() => {
if (error) {
const t = setTimeout(() => setError(null), 10000);
return () => clearTimeout(t);
}
}, [error, setError]);
if (!error) return null;
return (
<div className="fixed top-4 right-4 z-50 max-w-md animate-fade-in">
<div className="bg-destructive text-destructive-foreground p-4 rounded-lg shadow-lg border border-destructive/50">
<div className="flex items-start gap-3">
<span className="text-xl"></span>
<div className="flex-1">
<h3 className="font-semibold mb-1">Ошибка</h3>
<p className="text-sm">{error}</p>
</div>
<button onClick={() => setError(null)} className="hover:opacity-80" aria-label="Закрыть">
</button>
</div>
</div>
</div>
);
}