feat(extraordinary-expenses): Add module for extraordinary expenses

Introduces a new module to manage and track extraordinary expenses within condominiums. This includes defining expense items, sharing arrangements, and attaching relevant documents.

The module adds new types for `ExpenseItem`, `ExpenseShare`, and `ExtraordinaryExpense`. Mock database functions are updated to support fetching, creating, and managing these expenses. UI components in `Layout.tsx` and `Settings.tsx` are modified to include navigation and feature toggling for extraordinary expenses. Additionally, new routes are added in `App.tsx` for both administrative and user-facing views of these expenses.
This commit is contained in:
2025-12-09 23:00:05 +01:00
parent 048180db75
commit fa12a8de85
13 changed files with 918 additions and 77 deletions

View File

@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { NavLink, Outlet } from 'react-router-dom';
import { Users, Settings, Building, LogOut, Menu, X, ChevronDown, Check, LayoutDashboard, Megaphone, Info, AlertTriangle, Hammer, Calendar, MessageSquareWarning, PieChart } from 'lucide-react';
import { Users, Settings, Building, LogOut, Menu, X, ChevronDown, Check, LayoutDashboard, Megaphone, Info, AlertTriangle, Hammer, Calendar, MessageSquareWarning, PieChart, Briefcase } from 'lucide-react';
import { CondoService } from '../services/mockDb';
import { Condo, Notice, AppSettings } from '../types';
@@ -38,10 +38,6 @@ export const Layout: React.FC = () => {
setActiveCondo(active);
// Check for notices for User
// ONLY if notices feature is enabled (which we check inside logic or rely on settings state)
// However, `getSettings` is async. For simplicity, we fetch notices and if feature disabled at backend/UI level, it's fine.
// Ideally we check `settings?.features.notices` but `settings` might not be set yet.
// We'll rely on the UI hiding it, but fetching it doesn't hurt.
if (!isAdmin && active && user) {
try {
const unread = await CondoService.getUnreadNoticesForUser(user.id, active.id);
@@ -240,6 +236,14 @@ export const Layout: React.FC = () => {
<span className="font-medium">Famiglie</span>
</NavLink>
{/* New Extraordinary Expenses Link - Conditional */}
{settings?.features.extraordinaryExpenses && (
<NavLink to="/extraordinary" className={navClass} onClick={closeMenu}>
<Briefcase className="w-5 h-5" />
<span className="font-medium">{isAdmin ? 'Spese Straordinarie' : 'Le Mie Spese Extra'}</span>
</NavLink>
)}
{/* Privileged Links */}
{isAdmin && settings?.features.reports && (
<NavLink to="/reports" className={navClass} onClick={closeMenu}>