import React from 'react';
import { Auth0Provider } from '@auth0/auth0-react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import Navigation from './components/Navigation';
import Deployments from './components/Deployments';
import Profile from './components/Profile';
import { ProtectedRoute } from './components/ProtectedRoute';
import './App.css';

function App() {
  const onRedirectCallback = (appState) => {
    window.history.replaceState(
      {},
      document.title,
      appState?.returnTo || window.location.pathname
    );
  };

  return (
    <Auth0Provider
      domain="dev-a3o2jif0.us.auth0.com"
      clientId="H1FcujzHs76LB99W7KcKQOEO9ThtlyLh"
      authorizationParams={{
        redirect_uri: window.location.origin,
        audience: "https://dev-a3o2jif0.us.auth0.com/api/v2/"
      }}
      onRedirectCallback={onRedirectCallback}
    >
      <BrowserRouter>
        <div className="app">
          <Navigation />
          <Routes>
            <Route path="/" element={
              <ProtectedRoute>
                <Deployments />
              </ProtectedRoute>
            } />
            <Route path="/profile" element={
              <ProtectedRoute>
                <Profile />
              </ProtectedRoute>
            } />
          </Routes>
        </div>
      </BrowserRouter>
    </Auth0Provider>
  );
}

export default App; 