import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { getRouterBasename } from '@dukang/weixin-sdk';
import { StoreSessionProvider } from './contexts/StoreSessionContext';
import { installClientErrorReporting } from '@dukang/client-logging';
import App from './App';
import { apiBase } from './lib/api';
import './styles.css';
import './styles/legal.css';

installClientErrorReporting({
  apiBase,
  clientApp: 'SHOP_H5',
  getToken: () => localStorage.getItem('shopAccessToken'),
});

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <BrowserRouter basename={getRouterBasename()}>
      <StoreSessionProvider>
        <App />
      </StoreSessionProvider>
    </BrowserRouter>
  </React.StrictMode>,
);
