forked from cartsnitch/app
fix: address critical and major PR review issues
- Lazy-load Recharts via SparklineChart component with React.lazy + Suspense - Gate mock auth fallback behind VITE_MOCK_AUTH env var in Login and Register - Add ProtectedRoute component to guard authenticated routes - Fix touch target size on New Alert button (min-h-10 -> min-h-12) - Replace invalid safe-area-pb class with pb-[env(safe-area-inset-bottom)] - Fix theme toggle button touch targets (min-h-10 -> min-h-12) Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -10,7 +10,7 @@ const navItems = [
|
||||
|
||||
export function BottomNav() {
|
||||
return (
|
||||
<nav className="fixed bottom-0 left-0 right-0 z-50 border-t border-gray-200 bg-white safe-area-pb">
|
||||
<nav className="fixed bottom-0 left-0 right-0 z-50 border-t border-gray-200 bg-white pb-[env(safe-area-inset-bottom)]">
|
||||
<div className="mx-auto flex max-w-lg items-center justify-around">
|
||||
{navItems.map(({ to, label, icon: Icon }) => (
|
||||
<NavLink
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Navigate, Outlet } from 'react-router-dom'
|
||||
import { useAuthStore } from '../stores/auth.ts'
|
||||
|
||||
export function ProtectedRoute() {
|
||||
const isAuthenticated = useAuthStore((s) => s.isAuthenticated)
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <Navigate to="/login" replace />
|
||||
}
|
||||
|
||||
return <Outlet />
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { LineChart, Line, ResponsiveContainer } from 'recharts'
|
||||
|
||||
export function SparklineCard({
|
||||
label,
|
||||
data,
|
||||
current,
|
||||
}: {
|
||||
label: string
|
||||
data: { date: string; price: number }[]
|
||||
current: string
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-4 rounded-xl bg-white p-4 shadow-sm">
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium text-gray-900">{label}</p>
|
||||
<p className="text-lg font-bold text-gray-900">{current}</p>
|
||||
</div>
|
||||
<div className="h-10 w-24">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={data}>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="price"
|
||||
stroke="#1e40af"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user