import {StrictMode} from 'react'
import {createRoot} from 'react-dom/client'
import './index.css'
import {BrowserRouter} from 'react-router-dom'
import {QueryClient, QueryClientProvider} from '@tanstack/react-query'
import Router from './router/router.tsx'
import SelectedDrinkProvider from './context/selectedDrinkProvider.tsx'

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      refetchOnWindowFocus: import.meta.env.PROD,
    },
  },
})

const root = createRoot(document.getElementById('root')!)
root.render(
  <StrictMode>
    <QueryClientProvider client={queryClient}>
      <BrowserRouter>
        <SelectedDrinkProvider>
          <Router />
        </SelectedDrinkProvider>
      </BrowserRouter>
    </QueryClientProvider>
  </StrictMode>,
)
