final QA: code review fixes
Remove dead code per project rules: - Delete unused ErrorBoundary component (never imported) - Delete unused AmbientGlow component (never imported) - Remove unused eiaPaginationSchema export - Remove unused SuperJSON re-export
This commit is contained in:
parent
7d20d4b484
commit
f05dc6fa68
@ -1,48 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { cn } from '@/lib/utils.js';
|
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
|
|
||||||
type StressLevel = 'low' | 'moderate' | 'high' | 'critical';
|
|
||||||
|
|
||||||
interface AmbientGlowProps {
|
|
||||||
stressLevel: StressLevel;
|
|
||||||
children: ReactNode;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const GLOW_COLORS: Record<StressLevel, string> = {
|
|
||||||
low: '34, 197, 94', // green
|
|
||||||
moderate: '234, 179, 8', // yellow
|
|
||||||
high: '249, 115, 22', // orange
|
|
||||||
critical: '239, 68, 68', // red
|
|
||||||
};
|
|
||||||
|
|
||||||
const GLOW_ANIMATION: Record<StressLevel, string> = {
|
|
||||||
low: 'ambient-glow-slow',
|
|
||||||
moderate: 'ambient-glow-medium',
|
|
||||||
high: 'ambient-glow-fast',
|
|
||||||
critical: 'ambient-glow-pulse',
|
|
||||||
};
|
|
||||||
|
|
||||||
export function getStressLevel(utilizationPercent: number): StressLevel {
|
|
||||||
if (utilizationPercent >= 90) return 'critical';
|
|
||||||
if (utilizationPercent >= 80) return 'high';
|
|
||||||
if (utilizationPercent >= 65) return 'moderate';
|
|
||||||
return 'low';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AmbientGlow({ stressLevel, children, className }: AmbientGlowProps) {
|
|
||||||
const rgb = GLOW_COLORS[stressLevel];
|
|
||||||
const animationClass = GLOW_ANIMATION[stressLevel];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={cn('rounded-lg', animationClass, className)}
|
|
||||||
style={{
|
|
||||||
boxShadow: `0 0 20px rgba(${rgb}, 0.3), 0 0 40px rgba(${rgb}, 0.1)`,
|
|
||||||
}}>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { Component, type ErrorInfo, type ReactNode } from 'react';
|
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button.js';
|
|
||||||
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/components/ui/card.js';
|
|
||||||
|
|
||||||
interface ErrorBoundaryProps {
|
|
||||||
children: ReactNode;
|
|
||||||
fallback?: ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ErrorBoundaryState {
|
|
||||||
hasError: boolean;
|
|
||||||
error: Error | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
||||||
constructor(props: ErrorBoundaryProps) {
|
|
||||||
super(props);
|
|
||||||
this.state = { hasError: false, error: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
||||||
return { hasError: true, error };
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error: Error, info: ErrorInfo): void {
|
|
||||||
console.error('ErrorBoundary caught an error:', error, info.componentStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleRetry = () => {
|
|
||||||
this.setState({ hasError: false, error: null });
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.state.hasError) {
|
|
||||||
if (this.props.fallback) {
|
|
||||||
return this.props.fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center p-8">
|
|
||||||
<Card className="max-w-md">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="text-destructive">Something went wrong</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
{this.state.error?.message ?? 'An unexpected error occurred while rendering this section.'}
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
<CardFooter>
|
|
||||||
<Button variant="outline" onClick={this.handleRetry}>
|
|
||||||
Try again
|
|
||||||
</Button>
|
|
||||||
</CardFooter>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.props.children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -108,16 +108,6 @@ export interface FuelTypeDataPoint {
|
|||||||
valueUnits: string;
|
valueUnits: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* EIA API pagination metadata.
|
|
||||||
* Note: `total` comes back as a string from EIA.
|
|
||||||
*/
|
|
||||||
export const eiaPaginationSchema = z.object({
|
|
||||||
offset: z.number(),
|
|
||||||
length: z.number(),
|
|
||||||
total: z.union([z.string(), z.number()]).transform(Number),
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic EIA API response wrapper.
|
* Generic EIA API response wrapper.
|
||||||
* All EIA v2 responses share this structure.
|
* All EIA v2 responses share this structure.
|
||||||
|
|||||||
@ -7,5 +7,3 @@ export function serialize<T>(data: T) {
|
|||||||
export function deserialize<T>(data: ReturnType<typeof SuperJSON.serialize>): T {
|
export function deserialize<T>(data: ReturnType<typeof SuperJSON.serialize>): T {
|
||||||
return SuperJSON.deserialize<T>(data);
|
return SuperJSON.deserialize<T>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SuperJSON };
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user