import React from 'react';
import { createRoot } from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';
import reportWebVitals from './reportWebVitals';
import App from './App';
import './index.css';
import { Toaster } from 'react-hot-toast';

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      retry: 1
    }
  }
});
const container = document.getElementById('root') as Element;
const root = createRoot(container);

root.render(
  <QueryClientProvider client={queryClient}>
    <Router basename={process.env.PUBLIC_URL}>
      <React.StrictMode>
        <App />
        <Toaster position='bottom-center' toastOptions={{ duration: 3000 }} />
      </React.StrictMode>
    </Router>
    <ReactQueryDevtools initialIsOpen={false} />
  </QueryClientProvider>
);

// Start the mocking conditionally.
// if (process.env.NODE_ENV === 'development') {
//   const {worker} = require('./mocks/browser');
//   worker.start();
// }

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
