import { useState } from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import HomePage from "./pages/HomePage";
import SearchPage from "./pages/SearchPage";
import AuthModal from "./components/Auth/AuthModal";
import "./index.css";

function App() {
  const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
  const [user, setUser] = useState(null);

  return (
    <Router>
      <main className="min-h-screen">
        <Routes>
          <Route 
            path="/" 
            element={
              <HomePage 
                onLoginClick={() => setIsAuthModalOpen(true)} 
                user={user} 
              />
            } 
          />
          <Route 
            path="/search" 
            element={
              <SearchPage 
                onLoginClick={() => setIsAuthModalOpen(true)} 
                user={user} 
              />
            } 
          />
        </Routes>

        <AuthModal 
          isOpen={isAuthModalOpen} 
          onClose={() => setIsAuthModalOpen(false)} 
          user={user}
          setUser={setUser}
        />
      </main>
    </Router>
  );
}

export default App;
