diff --git a/src/App.tsx b/src/App.tsx index d2393ce..e2171af 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,12 +5,13 @@ import { useEffect, Suspense, lazy } from 'react' import { supabase } from './lib/supabase' import { ThemeProvider } from './contexts/ThemeContext' import LoadingSpinner from './components/common/LoadingSpinner' +import PasscodeGuard from './components/common/PasscodeGuard' // Layout import Layout from './components/layout/Layout' // Lazy load pages -const Login = lazy(() => import('./pages/Login')) +const Login = lazy(() => import('./pages/Login')) // Manter caso queiram voltar no futuro const Dashboard = lazy(() => import('./pages/Dashboard')) const Templates = lazy(() => import('./pages/Templates')) const TemplateCreate = lazy(() => import('./pages/TemplateCreate')) @@ -38,77 +39,52 @@ const queryClient = new QueryClient({ }, }) -function ProtectedRoute({ children }: { children: React.ReactNode }) { - const user = useAuthStore((state) => state.user) - - if (!user) { - return - } - - return <>{children} -} - +// Bypassing Auth for development phase function App() { const setUser = useAuthStore((state) => state.setUser) const logout = useAuthStore((state) => state.logout) - // Verificar sessão ao carregar + // Opcional: manter uma sessão "fantasma" do admin fixo enquanto o login está desativado useEffect(() => { - const checkSession = async () => { - const { data } = await supabase.auth.getSession() - if (data.session?.user) { - setUser(data.session.user as any) - } - } - - checkSession() - - // Escutar mudanças de autenticação - const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session) => { - if (session?.user) { - setUser(session.user as any) - } else { - logout() - } - }) - - return () => subscription?.unsubscribe() - }, [setUser, logout]) + // Definimos um usuário fake para não quebrar componentes que dependem de useAuthStore + setUser({ id: 'dev-user', email: 'admin@tracksteel.com.br' } as any) + }, [setUser]) return ( - - - }> - - } /> - - + + + + }> + + {/* Redirecionamos tudo para o dashboard diretamente */} + } /> + + - - } - > - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - - - - + } + > + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + + + + ) } diff --git a/src/components/common/PasscodeGuard.tsx b/src/components/common/PasscodeGuard.tsx new file mode 100644 index 0000000..37e59d5 --- /dev/null +++ b/src/components/common/PasscodeGuard.tsx @@ -0,0 +1,112 @@ +import { useState, useEffect } from 'react' +import { motion, AnimatePresence } from 'framer-motion' +import { Lock, ChevronRight, AlertCircle } from 'lucide-react' + +interface PasscodeGuardProps { + children: React.ReactNode +} + +const CORRECT_PASSCODE = '@@Gi05Br;;' + +export default function PasscodeGuard({ children }: PasscodeGuardProps) { + const [passcode, setPasscode] = useState('') + const [isAuthenticated, setIsAuthenticated] = useState(false) + const [error, setError] = useState(false) + const [isLoading, setIsLoading] = useState(true) + + useEffect(() => { + const saved = localStorage.getItem('app_access_granted') + if (saved === 'true') { + setIsAuthenticated(true) + } + setIsLoading(false) + }, []) + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + if (passcode === CORRECT_PASSCODE) { + localStorage.setItem('app_access_granted', 'true') + setIsAuthenticated(true) + setError(false) + } else { + setError(true) + setPasscode('') + // Shake animation effect could be added here + } + } + + if (isLoading) return null + + if (isAuthenticated) return <>{children} + + return ( +
+ {/* Background Glow */} +
+
+
+
+ + +
+
+ +
+ + + +

Acesso Restrito

+

O aplicativo está em fase de desenvolvimento.

+
+ +
+
+ setPasscode(e.target.value)} + autoFocus + className={`w-full bg-slate-800/50 border ${error ? 'border-red-500/50 ring-2 ring-red-500/10' : 'border-slate-700/50 group-hover/input:border-slate-600 focus:border-blue-500'} h-14 rounded-2xl px-6 outline-none text-white text-lg transition-all duration-300 placeholder:text-slate-600`} + /> + + + {error && ( + + + Senha incorreta + + )} + +
+ + +
+ +
+ TrackSteel DBMaker v1.0 +
+
+ +
+ ) +}