fix(frontend): Error Boundary, HomePage error state, HLS catch — quick wins pre-Bloc-B
This commit is contained in:
31
frontend/src/components/ErrorBoundary.tsx
Normal file
31
frontend/src/components/ErrorBoundary.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Component, type ReactNode } from 'react';
|
||||
|
||||
interface Props { children: ReactNode; }
|
||||
interface State { hasError: boolean; }
|
||||
|
||||
export default class ErrorBoundary extends Component<Props, State> {
|
||||
state: State = { hasError: false };
|
||||
|
||||
static getDerivedStateFromError(): State {
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-od-bg">
|
||||
<div className="rounded border border-od-crit/40 bg-od-surface p-8 text-center">
|
||||
<p className="font-mono text-sm text-od-crit">Une erreur inattendue s'est produite.</p>
|
||||
<button
|
||||
className="mt-4 rounded border border-od-border px-4 py-2 text-xs text-od-muted hover:border-od-accent/40"
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
Recharger
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ function NativePlayer({ url }: { url: string }) {
|
||||
hls = new Hls();
|
||||
hls.loadSource(url);
|
||||
hls.attachMedia(video);
|
||||
});
|
||||
}).catch(() => { /* HLS non disponible — dégradation silencieuse */ });
|
||||
}
|
||||
|
||||
return () => { hls?.destroy(); };
|
||||
|
||||
Reference in New Issue
Block a user