Enables a new reports section in the application. This includes: - Adding a `reports` flag to `AppFeatures` and `AppSettings`. - Including a new "Reportistica" link in the main navigation for privileged users. - Adding a `getCondoPayments` endpoint to the mock DB service. - Updating the backend to support filtering payments by `condoId`. - Providing a basic `ReportsPage` component.
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
|
|
import React from 'react';
|
|
import { HashRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom';
|
|
import { Layout } from './components/Layout';
|
|
import { FamilyList } from './pages/FamilyList';
|
|
import { FamilyDetail } from './pages/FamilyDetail';
|
|
import { SettingsPage } from './pages/Settings';
|
|
import { TicketsPage } from './pages/Tickets';
|
|
import { ReportsPage } from './pages/Reports';
|
|
import { LoginPage } from './pages/Login';
|
|
import { CondoService } from './services/mockDb';
|
|
|
|
const ProtectedRoute = ({ children }: { children?: React.ReactNode }) => {
|
|
const user = CondoService.getCurrentUser();
|
|
const location = useLocation();
|
|
|
|
if (!user) {
|
|
return <Navigate to="/login" state={{ from: location }} replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
};
|
|
|
|
const App: React.FC = () => {
|
|
return (
|
|
<HashRouter>
|
|
<Routes>
|
|
<Route path="/login" element={<LoginPage />} />
|
|
|
|
<Route path="/" element={
|
|
<ProtectedRoute>
|
|
<Layout />
|
|
</ProtectedRoute>
|
|
}>
|
|
<Route index element={<FamilyList />} />
|
|
<Route path="family/:id" element={<FamilyDetail />} />
|
|
<Route path="tickets" element={<TicketsPage />} />
|
|
<Route path="reports" element={<ReportsPage />} />
|
|
<Route path="settings" element={<SettingsPage />} />
|
|
</Route>
|
|
|
|
<Route path="*" element={<Navigate to="/" replace />} />
|
|
</Routes>
|
|
</HashRouter>
|
|
);
|
|
};
|
|
|
|
export default App;
|