import { BrowserRouter, Routes, Route } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ThemeProvider, createTheme } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import { itIT } from "@mui/material/locale";
import Layout from "./components/Layout";
import {
  Dashboard,
  EventiPage,
  EventoDetailPage,
  CalendarioPage,
  ClientiPage,
  LocationPage,
  ArticoliPage,
  RisorsePage,
} from "./pages";

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      refetchOnWindowFocus: false,
      retry: 1,
    },
  },
});

const theme = createTheme(
  {
    palette: {
      primary: {
        main: "#1976d2",
      },
      secondary: {
        main: "#dc004e",
      },
      background: {
        default: "#f5f5f5",
      },
    },
    typography: {
      fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
    },
    components: {
      MuiTableCell: {
        styleOverrides: {
          head: {
            fontWeight: 600,
          },
        },
      },
      MuiButton: {
        styleOverrides: {
          root: {
            textTransform: "none",
          },
        },
      },
    },
  },
  itIT,
);

function App() {
  return (
    <QueryClientProvider client={queryClient}>
      <ThemeProvider theme={theme}>
        <CssBaseline />
        <BrowserRouter>
          <Routes>
            <Route path="/" element={<Layout />}>
              <Route index element={<Dashboard />} />
              <Route path="calendario" element={<CalendarioPage />} />
              <Route path="eventi" element={<EventiPage />} />
              <Route path="eventi/:id" element={<EventoDetailPage />} />
              <Route path="clienti" element={<ClientiPage />} />
              <Route path="location" element={<LocationPage />} />
              <Route path="articoli" element={<ArticoliPage />} />
              <Route path="risorse" element={<RisorsePage />} />
            </Route>
          </Routes>
        </BrowserRouter>
      </ThemeProvider>
    </QueryClientProvider>
  );
}

export default App;
