gdpr audit implemented, email log, vollmachten, pdf delete cancel data privacy and vollmachten, removed message no id card in engergy car, and other contracts that are not telecom contracts, added insert counter for engery
This commit is contained in:
+78
-2
@@ -1,5 +1,8 @@
|
||||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useAuth } from './context/AuthContext';
|
||||
import { gdprApi } from './services/api';
|
||||
import { Shield } from 'lucide-react';
|
||||
import ScrollToTop from './components/ScrollToTop';
|
||||
import Layout from './components/layout/Layout';
|
||||
import Login from './pages/Login';
|
||||
@@ -22,9 +25,19 @@ import PortalSettings from './pages/settings/PortalSettings';
|
||||
import DeadlineSettings from './pages/settings/DeadlineSettings';
|
||||
import EmailProviders from './pages/settings/EmailProviders';
|
||||
import DatabaseBackup from './pages/settings/DatabaseBackup';
|
||||
import AuditLogs from './pages/settings/AuditLogs';
|
||||
import EmailLogPage from './pages/settings/EmailLogs';
|
||||
import GDPRDashboard from './pages/settings/GDPRDashboard';
|
||||
import UserList from './pages/users/UserList';
|
||||
import Settings from './pages/Settings';
|
||||
import DatabaseStructure from './pages/developer/DatabaseStructure';
|
||||
import ConsentPage from './pages/public/ConsentPage';
|
||||
import PrivacyPolicyEditor from './pages/settings/PrivacyPolicyEditor';
|
||||
import PortalPrivacy from './pages/portal/PortalPrivacy';
|
||||
import AuthorizationTemplateEditor from './pages/settings/AuthorizationTemplateEditor';
|
||||
import PortalAuthorizations from './pages/portal/PortalAuthorizations';
|
||||
import PortalProfile from './pages/portal/PortalProfile';
|
||||
import PortalMeters from './pages/portal/PortalMeters';
|
||||
|
||||
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
||||
const { isAuthenticated, isLoading } = useAuth();
|
||||
@@ -44,6 +57,55 @@ function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function PortalConsentGate({ children }: { children: React.ReactNode }) {
|
||||
const { isCustomerPortal } = useAuth();
|
||||
|
||||
// Nicht-Portal-Benutzer werden nicht eingeschränkt
|
||||
if (!isCustomerPortal) return <>{children}</>;
|
||||
|
||||
// Portal-Kunden: Consent-Check läuft über Layout ConsentBanner + hier
|
||||
return <PortalConsentCheck>{children}</PortalConsentCheck>;
|
||||
}
|
||||
|
||||
function PortalConsentCheck({ children }: { children: React.ReactNode }) {
|
||||
const { data, isLoading, isError } = useQuery({
|
||||
queryKey: ['my-consent-status'],
|
||||
queryFn: () => gdprApi.getMyConsentStatus(),
|
||||
staleTime: 30_000,
|
||||
retry: 1,
|
||||
});
|
||||
|
||||
if (isLoading) return <div className="text-center py-8 text-gray-500">Laden...</div>;
|
||||
|
||||
// Bei Fehler oder fehlender Einwilligung: sperren
|
||||
const hasConsent = (!isError && data?.data?.hasConsent) ?? false;
|
||||
|
||||
if (!hasConsent) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center py-16 px-6 text-center">
|
||||
<div className="bg-amber-50 border border-amber-200 rounded-full p-4 mb-4">
|
||||
<Shield className="w-8 h-8 text-amber-500" />
|
||||
</div>
|
||||
<h2 className="text-xl font-semibold text-gray-800 mb-2">
|
||||
Datenschutz-Einwilligung erforderlich
|
||||
</h2>
|
||||
<p className="text-sm text-gray-600 mb-6 max-w-md">
|
||||
Dieser Bereich ist erst verfügbar, wenn Sie unserer Datenschutzerklärung zugestimmt haben.
|
||||
</p>
|
||||
<a
|
||||
href="/privacy"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
<Shield className="w-4 h-4" />
|
||||
Jetzt zur Datenschutzerklärung
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function DeveloperRoute({ children }: { children: React.ReactNode }) {
|
||||
const { hasPermission, developerMode } = useAuth();
|
||||
|
||||
@@ -70,6 +132,9 @@ function App() {
|
||||
<>
|
||||
<ScrollToTop />
|
||||
<Routes>
|
||||
{/* Öffentliche Routes (OHNE Authentifizierung) */}
|
||||
<Route path="/datenschutz/:hash" element={<ConsentPage />} />
|
||||
|
||||
<Route
|
||||
path="/login"
|
||||
element={isAuthenticated ? <Navigate to="/" replace /> : <Login />}
|
||||
@@ -92,15 +157,21 @@ function App() {
|
||||
<Route path="customers/:id/edit" element={<CustomerForm />} />
|
||||
|
||||
{/* Contracts */}
|
||||
<Route path="contracts" element={<ContractList />} />
|
||||
<Route path="contracts" element={<PortalConsentGate><ContractList /></PortalConsentGate>} />
|
||||
<Route path="contracts/cockpit" element={<ContractCockpit />} />
|
||||
<Route path="contracts/new" element={<ContractForm />} />
|
||||
<Route path="contracts/:id" element={<ContractDetail />} />
|
||||
<Route path="contracts/:id" element={<PortalConsentGate><ContractDetail /></PortalConsentGate>} />
|
||||
<Route path="contracts/:id/edit" element={<ContractForm />} />
|
||||
|
||||
{/* Tasks / Support-Anfragen */}
|
||||
<Route path="tasks" element={<TaskList />} />
|
||||
|
||||
{/* Portal: Meine Daten, Datenschutz, Vollmachten */}
|
||||
<Route path="my-profile" element={<PortalProfile />} />
|
||||
<Route path="my-meters" element={<PortalMeters />} />
|
||||
<Route path="privacy" element={<PortalPrivacy />} />
|
||||
<Route path="authorizations" element={<PortalAuthorizations />} />
|
||||
|
||||
{/* Settings */}
|
||||
<Route path="settings" element={<Settings />} />
|
||||
<Route path="settings/users" element={<UserList />} />
|
||||
@@ -114,6 +185,11 @@ function App() {
|
||||
<Route path="settings/deadlines" element={<DeadlineSettings />} />
|
||||
<Route path="settings/email-providers" element={<EmailProviders />} />
|
||||
<Route path="settings/database-backup" element={<DatabaseBackup />} />
|
||||
<Route path="settings/audit-logs" element={<AuditLogs />} />
|
||||
<Route path="settings/email-logs" element={<EmailLogPage />} />
|
||||
<Route path="settings/gdpr" element={<GDPRDashboard />} />
|
||||
<Route path="settings/privacy-policy" element={<PrivacyPolicyEditor />} />
|
||||
<Route path="settings/authorization-template" element={<AuthorizationTemplateEditor />} />
|
||||
|
||||
{/* Redirect old users route */}
|
||||
<Route path="users" element={<Navigate to="/settings/users" replace />} />
|
||||
|
||||
Reference in New Issue
Block a user