From 05fa87c638b50d4a08755bfaa1f9ecf72b42e8da Mon Sep 17 00:00:00 2001 From: donpat1to Date: Fri, 24 Oct 2025 17:52:47 +0200 Subject: [PATCH] added routing in app.tsx --- frontend/package.json | 7 +- frontend/src/App.tsx | 167 +++++++++++++++++++--------------------- frontend/tsconfig.json | 21 ++--- frontend/vite.config.ts | 6 +- premium | 2 +- 5 files changed, 98 insertions(+), 105 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 2d6c8b2..a016e5e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -22,10 +22,11 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "vite", + "dev": "vite", "build": "tsc --noEmit && vite build", - "preview": "vite preview", - "type-check": "tsc --noEmit" + "build:community": "vite build", + "build:commercial": "git submodule update --init --recursive && ENABLE_PRO=true vite build", + "preview": "vite preview" }, "devDependencies": { "@types/react": "^18.0.27", diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 464781e..1f29e18 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -// frontend/src/App.tsx - UPDATED WITH FOOTER LINKS +// frontend/src/App.tsx - ONE-REPO SAFE WITHOUT DYNAMIC IMPORTS import React from 'react'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { AuthProvider, useAuth } from './contexts/AuthContext'; @@ -16,16 +16,67 @@ import Settings from './pages/Settings/Settings'; import Help from './pages/Help/Help'; import Setup from './pages/Setup/Setup'; -// Footer Link Pages +// Free Footer Link Pages (always available) import FAQ from './components/Layout/FooterLinks/FAQ/FAQ'; import About from './components/Layout/FooterLinks/About/About'; import Features from './components/Layout/FooterLinks/Features/Features'; -// PREMIUM Footer Link Pages -import { Contact } from '@premium-frontend/componentsPRO/FooterLinksPro/Contact/Contact'; -import { Privacy } from '@premium-frontend/componentsPRO/FooterLinksPro/Privacy/Privacy'; -import Imprint from '../../premium/frontendPRO/src/componentsPRO/FooterLinksPro/Imprint/Imprint'; -import Terms from '../../premium/frontendPRO/src/componentsPRO/FooterLinksPro/Terms/Terms'; +// Feature flag from environment +const ENABLE_PRO = process.env.ENABLE_PRO === 'true'; + +// Community fallback components (always available) +const CommunityContact: React.FC = () => ( +
+

📞 Kontakt

+
+

Community Edition

+

Kontaktfunktionen sind in der Premium Edition verfügbar.

+

+ + ➡️ Zu den Features + +

+
+
+); + +const CommunityLegalPage: React.FC<{ title: string }> = ({ title }) => ( +
+

📄 {title}

+
+

Community Edition

+

Rechtliche Dokumentation ist in der Premium Edition verfügbar.

+

+ + ➡️ Erfahren Sie mehr über Premium + +

+
+
+); + +// Conditional Premium Components +let PremiumContact: React.FC = CommunityContact; +let PremiumPrivacy: React.FC = () => ; +let PremiumImprint: React.FC = () => ; +let PremiumTerms: React.FC = () => ; + +// Load premium components only when ENABLE_PRO is true +if (ENABLE_PRO) { + try { + // Use require with type assertions to avoid dynamic import issues + const premiumModule = require('@premium-frontend/components/FooterLinks'); + + if (premiumModule.Contact) PremiumContact = premiumModule.Contact; + if (premiumModule.Privacy) PremiumPrivacy = premiumModule.Privacy; + if (premiumModule.Imprint) PremiumImprint = premiumModule.Imprint; + if (premiumModule.Terms) PremiumTerms = premiumModule.Terms; + + console.log('✅ Premium components loaded successfully'); + } catch (error) { + console.warn('⚠️ Premium components not available, using community fallbacks:', error); + } +} // Protected Route Component const ProtectedRoute: React.FC<{ children: React.ReactNode; roles?: string[] }> = ({ @@ -72,7 +123,6 @@ const PublicRoute: React.FC<{ children: React.ReactNode }> = ({ children }) => { ); } - // If user is logged in, show with layout, otherwise without return user ? {children} : <>{children}; }; @@ -81,6 +131,7 @@ const AppContent: React.FC = () => { const { loading, needsSetup, user } = useAuth(); console.log('🏠 AppContent rendering - loading:', loading, 'needsSetup:', needsSetup, 'user:', user); + console.log('🎯 Premium features enabled:', ENABLE_PRO); // Während des Ladens if (loading) { @@ -108,93 +159,31 @@ const AppContent: React.FC = () => { return ( {/* Protected Routes (require login) */} - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> - {/* Public Footer Link Pages (accessible without login, but show layout if logged in) */} - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> - - - - } /> + {/* Public Footer Link Pages (always available) */} + } /> + } /> + } /> + + {/* PREMIUM Footer Link Pages (conditionally available) */} + } /> + } /> + } /> + } /> {/* Auth Routes */} } /> {/* Catch-all Route */} - - - - } /> + } /> ); }; diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index ed4b05a..956c5c5 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,21 +1,22 @@ +// frontend/tsconfig.json - SO FUNKTIONIERT ES { - "extends": "../tsconfig.base.json", "compilerOptions": { - "lib": [ - "ES2022", - "DOM", - "DOM.Iterable" - ], + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], "jsx": "react-jsx", "noEmit": true, "allowImportingTsExtensions": true, "skipLibCheck": true, - "moduleResolution": "bundler" + "moduleResolution": "bundler", + "strict": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "isolatedModules": true, + "paths": { + "@premium-frontend/*": ["../premium/frontendPRO/src/*"] + } }, "include": [ "src/**/*" - ], - "references": [ - { "path": "../premium" } ] } \ No newline at end of file diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 4ed1ec9..0726e2f 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -8,8 +8,10 @@ export default defineConfig({ resolve: { alias: { '@': resolve(__dirname, './src'), - '@premium-frontend': resolve(__dirname, '../premium/frontendPRO/src'), - '@premium-backend': resolve(__dirname, '../premium/backendPRO/src') + '@premium-frontend': resolve(__dirname, '../premium/frontendPRO/src') } + }, + define: { + 'process.env.ENABLE_PRO': JSON.stringify(process.env.ENABLE_PRO === 'true') } }); \ No newline at end of file diff --git a/premium b/premium index 21a4671..6da71ae 160000 --- a/premium +++ b/premium @@ -1 +1 @@ -Subproject commit 21a4671c1617bf26e89a3604b50dc22b5887e937 +Subproject commit 6da71aebad3e78f9da7ed6b26687d544d9bd1bf3