App.jsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
  2. import { LanguageProvider } from './context/LanguageContext';
  3. import Navbar from './components/Navbar';
  4. import Footer from './components/Footer';
  5. import ScrollToTop from './components/ScrollToTop';
  6. import Home from './pages/Home';
  7. import Pricing from './pages/Pricing';
  8. import Login from './pages/Login';
  9. import Register from './pages/Register';
  10. import VerifyEmail from './pages/VerifyEmail';
  11. import RegistrationSuccess from './pages/RegistrationSuccess';
  12. import Payment from './pages/Payment';
  13. import PaymentSuccess from './pages/PaymentSuccess';
  14. import PaymentCancel from './pages/PaymentCancel';
  15. import About from './pages/About';
  16. import AiTrends from './pages/AiTrends';
  17. import ImageGeneration from './pages/ImageGeneration';
  18. import Analytics from './pages/Analytics';
  19. import BrandGrowth from './pages/BrandGrowth';
  20. import Contact from './pages/Contact';
  21. import Terms from './pages/Terms';
  22. import Privacy from './pages/Privacy';
  23. import { useState, useEffect } from 'react';
  24. import { API_HOST } from './config';
  25. function App() {
  26. const [pricingData, setPricingData] = useState(null);
  27. const [isLoading, setIsLoading] = useState(true);
  28. useEffect(() => {
  29. const fetchPricingData = async () => {
  30. try {
  31. const response = await fetch(`${API_HOST}/api/v1/onboard/products`);
  32. if (!response.ok) throw new Error('Failed to fetch products');
  33. const data = await response.json();
  34. // Transform API data to match UI requirements
  35. const transformedProducts = data.map(product => ({
  36. name: product.name,
  37. prices: {
  38. monthly: product.prices.monthly,
  39. yearly: product.prices.yearly,
  40. monthlyPriceId: product.prices.monthly_price_id,
  41. yearlyPriceId: product.prices.yearly_price_id
  42. },
  43. features: product.features,
  44. description: product.description,
  45. popular: product.metadata?.is_popular === "true",
  46. maxUsers: product.max_users,
  47. storageLimit: product.storage_limit,
  48. apiRateLimit: product.api_rate_limit,
  49. supportTier: product.support_tier,
  50. customDomain: product.custom_domain
  51. }));
  52. setPricingData(transformedProducts);
  53. } catch (error) {
  54. console.error('Error fetching products:', error);
  55. // Set fallback pricing data
  56. setPricingData([
  57. {
  58. name: 'Starter',
  59. prices: { monthly: 29, yearly: 290 },
  60. features: [
  61. 'Basic AI trend analysis',
  62. '25 AI image generations/month',
  63. 'Basic analytics dashboard',
  64. 'Content calendar',
  65. 'Email support',
  66. 'Single user'
  67. ],
  68. },
  69. // ... other fallback plans
  70. ]);
  71. } finally {
  72. setIsLoading(false);
  73. }
  74. };
  75. fetchPricingData();
  76. }, []);
  77. return (
  78. <LanguageProvider>
  79. <Router>
  80. <ScrollToTop />
  81. <div className="min-h-screen bg-white">
  82. <Navbar />
  83. <Routes>
  84. <Route path="/" element={<Home />} />
  85. <Route path="/pricing" element={<Pricing pricingData={pricingData} isLoading={isLoading} />} />
  86. <Route path="/login" element={<Login />} />
  87. <Route path="/register" element={<Register pricingData={pricingData} />} />
  88. <Route path="/verify-email" element={<VerifyEmail />} />
  89. <Route path="/registration-success" element={<RegistrationSuccess />} />
  90. <Route path="/payment" element={<Payment pricingData={pricingData} />} />
  91. <Route path="/payment/success" element={<PaymentSuccess />} />
  92. <Route path="/payment/cancel" element={<PaymentCancel />} />
  93. <Route path="/about" element={<About />} />
  94. <Route path="/ai-trends" element={<AiTrends />} />
  95. <Route path="/image-generation" element={<ImageGeneration />} />
  96. <Route path="/analytics" element={<Analytics />} />
  97. <Route path="/brand-growth" element={<BrandGrowth />} />
  98. <Route path="/contact" element={<Contact />} />
  99. <Route path="/terms" element={<Terms />} />
  100. <Route path="/privacy" element={<Privacy />} />
  101. </Routes>
  102. </div>
  103. </Router>
  104. </LanguageProvider>
  105. );
  106. }
  107. export default App;