Files
SatsFaucet/frontend/src/ErrorBoundary.tsx
Michaël 5b516f02cb Production-ready overhaul: backend fixes, claim flow polish, SEO, mobile, nginx
Backend:
- Fix activity score (followersCount check), NIP-98 URL proto, wallet balance guard
- Add payment_hash to confirm response, spentTodaySats to stats
- Add idx_claims_ip_hash; security headers, graceful shutdown, periodic nonce cleanup

Frontend:
- Remove 8 legacy components; polish wizard (rules summary, profile card, confetti, share)
- Stats budget bar uses spentTodaySats; ErrorBoundary with reload

SEO & production:
- Full meta/OG/Twitter, favicon, JSON-LD, robots.txt, sitemap.xml
- Mobile CSS fixes; nginx static dist + gzip + cache + security headers
- Vite manualChunks; aria-labels, dynamic page titles

Made-with: Cursor
2026-02-27 16:29:37 -03:00

88 lines
2.5 KiB
TypeScript

import { Component, ErrorInfo, ReactNode } from "react";
interface Props {
children: ReactNode;
}
interface State {
hasError: boolean;
error: Error | null;
}
export class ErrorBoundary extends Component<Props, State> {
state: State = { hasError: false, error: null };
static getDerivedStateFromError(error: Error): State {
return { hasError: true, error };
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
console.error("App error:", error, errorInfo);
}
render() {
if (this.state.hasError && this.state.error) {
return (
<div
style={{
minHeight: "100vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
padding: "2rem",
fontFamily: "system-ui, -apple-system, sans-serif",
background: "#0c1222",
color: "#f1f5f9",
textAlign: "center",
}}
>
<div style={{ fontSize: "3rem", marginBottom: "1rem" }}>&#9889;</div>
<h1 style={{ fontSize: "1.5rem", fontWeight: 600, marginBottom: "0.75rem" }}>
Something went wrong
</h1>
<p style={{ color: "#94a3b8", maxWidth: 420, marginBottom: "1.5rem", lineHeight: 1.6 }}>
The app encountered an unexpected error. This has been logged.
You can try reloading the page.
</p>
<div style={{ display: "flex", gap: "12px" }}>
<button
type="button"
onClick={() => window.location.reload()}
style={{
padding: "10px 24px",
background: "#f97316",
color: "#fff",
border: "none",
borderRadius: "8px",
fontSize: "14px",
fontWeight: 500,
cursor: "pointer",
}}
>
Reload page
</button>
<button
type="button"
onClick={() => this.setState({ hasError: false, error: null })}
style={{
padding: "10px 24px",
background: "transparent",
color: "#94a3b8",
border: "1px solid #334155",
borderRadius: "8px",
fontSize: "14px",
fontWeight: 500,
cursor: "pointer",
}}
>
Try again
</button>
</div>
</div>
);
}
return this.props.children;
}
}