import { useEffect } from 'react';
import { AppRoutes } from './app/Routes';
import './App.css';
import { isTestMode } from './conf/config';

const BaseTag = () => {
  useEffect(() => {
    if (isTestMode) {
      const baseTag = document.createElement('base');
      baseTag.href = process.env.REACT_APP_BASE_URL || window.location.origin;
      document.head.prepend(baseTag);

      return () => {
        const existingBase = document.querySelector('base');
        if (existingBase) {
          existingBase.remove();
        }
      };
    }
  }, []);

  return null;
};

function App() {
  return (
    <div className="App">
      <BaseTag />
      <AppRoutes />
    </div>
  );
}

export default App;
