App.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import React from "react";
  2. import { Routes, Route, useLocation, Navigate } from "react-router-dom";
  3. import Header from "./components/Header";
  4. import Footer from "./components/Footer";
  5. import HomeView from "./pages/home/HomeView";
  6. import Sidebar from "./components/Sidebar";
  7. import ProductDetailView from "./pages/product-detail/ProductDetailView";
  8. import BuySimView from "./pages/buy-sim/BuySimView";
  9. import SupportView from "./pages/support/SupportView";
  10. import NewsView from "./pages/news/NewsView";
  11. import ArticleDetailView from "./pages/news/NewsDetailView";
  12. import LoginView from "./pages/login/LoginView";
  13. import ContactView from "./pages/contact/ContactView";
  14. import TopLoader from "./components/TopLoader";
  15. import CheckoutView from "./pages/checkout/CheckoutView";
  16. import Popup from "./components/Popup";
  17. import OrderHistoryView from "./pages/order-history/OrderHistoryView";
  18. import OrderDetailView from "./pages/order-detail/OrderDetailView";
  19. import CompatibilityModal from "./components/CompatibilityModal";
  20. import QRCodeModal from "./components/QRCodeModal";
  21. const App: React.FC = () => {
  22. const location = useLocation();
  23. const path = location.pathname;
  24. const isAiView = path.startsWith("/ai");
  25. const isPlainView = path === "/login";
  26. // Helper to determine if footer should be shown
  27. const showFooter = !isAiView && !isPlainView;
  28. return (
  29. <div
  30. className={`flex flex-col min-h-screen bg-white selection:bg-red-100 ${
  31. isAiView ? "h-screen overflow-hidden" : ""
  32. }`}
  33. >
  34. {!isPlainView && <Header />}
  35. <Popup />
  36. <CompatibilityModal />
  37. <QRCodeModal />
  38. <div className={`flex flex-1 ${isAiView ? "overflow-hidden" : ""}`}>
  39. {isAiView && <Sidebar />}
  40. <main
  41. className={`flex-1 relative flex flex-col ${
  42. isAiView ? "overflow-y-auto bg-slate-50" : "bg-white"
  43. }`}
  44. >
  45. {isAiView && (
  46. <div className="h-14 border-b border-slate-200 bg-white/50 backdrop-blur-md flex items-center justify-between px-6 shrink-0 z-10">
  47. <div className="flex items-center space-x-2">
  48. <span className="w-2 h-2 rounded-full bg-red-500 animate-pulse"></span>
  49. <span className="text-[10px] font-black text-slate-400 uppercase tracking-widest">
  50. Assistant Active
  51. </span>
  52. </div>
  53. <a
  54. href="/"
  55. className="text-[10px] font-bold text-[#EE0434] hover:underline"
  56. >
  57. Back to Store
  58. </a>
  59. </div>
  60. )}
  61. <TopLoader visible={true} />
  62. <div className="flex-1">
  63. <Routes>
  64. <Route path="/" element={<HomeView />} />
  65. <Route path="/buy-sim" element={<BuySimView />} />
  66. <Route path="/product/:country" element={<ProductDetailView />} />
  67. <Route path="/checkout" element={<CheckoutView />} />
  68. <Route path="/support" element={<SupportView />} />
  69. <Route path="/news" element={<NewsView />} />
  70. <Route path="/news/:id" element={<ArticleDetailView />} />
  71. <Route path="/contact" element={<ContactView />} />
  72. <Route path="/login" element={<LoginView />} />
  73. <Route path="/order-history" element={<OrderHistoryView />} />
  74. <Route
  75. path="/order-history-detail/:id"
  76. element={<OrderDetailView />}
  77. />
  78. {/* Fallback */}
  79. <Route path="*" element={<Navigate to="/" replace />} />
  80. </Routes>
  81. </div>
  82. {showFooter && <Footer />}
  83. </main>
  84. </div>
  85. </div>
  86. );
  87. };
  88. export default App;