import React from "react";
import ReactDOM from "react-dom/client";
import reportWebVitals from "./reportWebVitals";
import "antd/dist/antd.min.css";
import "react-image-gallery/styles/css/image-gallery.css";
import { BrowserRouter as Router, Route, Routes, Navigate } from "react-router-dom";
import App from "./App.js";
import News from "./component/news/news";
import NewsDetail from "./component/news/news_detail";
import ProductHome from "./component/Product";
import Solution from "./component/Solution";
import Case from "./component/Case";
import CaseDetail from "./component/CaseDetail";
import AboutUs from "./component/aboutus";
import ContactUs from "./component/contact";
import ContactUsForm from "./component/Form";
import Mobile from "./mobile/Mobile";
import "./index.css";

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
  const root = ReactDOM.createRoot(document.getElementById("root"));
  root.render(
    <React.StrictMode>
      <Router>
        <Routes>
          <Route path="/home" exact element={<Mobile />} />
          <Route path="*" element={<Navigate to="/home" />} />
        </Routes>
      </Router>
    </React.StrictMode>
  );
} else {
  const root = ReactDOM.createRoot(document.getElementById("root"));
  root.render(
    <React.StrictMode>
      <Router>
        <Routes>
          <Route path="/home" exact element={<App />} />
          <Route path="/product" exact element={<ProductHome />} />
          <Route path="/solution" exact element={<Solution />} />
          <Route path="/case" exact element={<Case />} />
          <Route path="/case/detail" exact element={<CaseDetail />} />
          <Route path="/news" exact element={<News />} />
          <Route path="/news/detail" exact element={<NewsDetail />} />
          <Route path="/about_us" exact element={<AboutUs />} />
          <Route path="/contact_us" exact element={<ContactUs />} />
          <Route path="/contact_us_form" exact element={<ContactUsForm />} />
          <Route path="*" element={<Navigate to="/home" />} />
        </Routes>
      </Router>
    </React.StrictMode>
  );
}

// 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();
