From 9d74f7adabc3522d4ac93881dc752f4a37b476ed Mon Sep 17 00:00:00 2001 From: frakarr Date: Thu, 11 Dec 2025 23:02:43 +0100 Subject: [PATCH] Update FamilyList.tsx --- pages/FamilyList.tsx | 80 +++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/pages/FamilyList.tsx b/pages/FamilyList.tsx index bf9e056..04e481a 100644 --- a/pages/FamilyList.tsx +++ b/pages/FamilyList.tsx @@ -1,9 +1,9 @@ -import React, { useEffect, useState, useMemo } from 'react'; +import React, { useEffect, useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { CondoService } from '../services/mockDb'; import { Family, Condo, Notice, AppSettings, Ticket, TicketStatus } from '../types'; -import { Search, ChevronRight, UserCircle, Building, Bell, AlertTriangle, Hammer, Calendar, Info, Link as LinkIcon, Check, Wallet, Briefcase, MessageSquareWarning, ArrowRight, AlertCircle, CheckCircle2, ChevronDown, ChevronUp } from 'lucide-react'; +import { Search, ChevronRight, UserCircle, Building, Bell, AlertTriangle, Hammer, Calendar, Info, Link as LinkIcon, Check, Wallet, Briefcase, MessageSquareWarning, ArrowRight, CheckCircle2, ChevronDown, ChevronUp, Eye } from 'lucide-react'; export const FamilyList: React.FC = () => { const navigate = useNavigate(); @@ -60,11 +60,10 @@ export const FamilyList: React.FC = () => { setMyExtraExpenses(extra); } - // 4. Calculate Regular Payment Status (Logic Update) + // 4. Calculate Regular Payment Status const payments = await CondoService.getPaymentsByFamily(currentUser.familyId); const currentYear = appSettings.currentYear; const now = new Date(); - const currentRealYear = now.getFullYear(); const currentRealMonth = now.getMonth() + 1; // 1-12 const currentDay = now.getDate(); const dueDay = condo.dueDay || 10; @@ -107,6 +106,7 @@ export const FamilyList: React.FC = () => { if (isPrivileged) return true; + // Check visibility for regular users const isPublic = !n.targetFamilyIds || n.targetFamilyIds.length === 0; const isTargeted = currentUser.familyId && n.targetFamilyIds?.includes(currentUser.familyId); @@ -117,7 +117,7 @@ export const FamilyList: React.FC = () => { relevantNotices.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()); setNotices(relevantNotices); - // Check read status + // Check read status for current user const readStatuses = await Promise.all(relevantNotices.map(n => CondoService.getNoticeReadStatus(n.id))); const readIds: string[] = []; readStatuses.forEach((reads, idx) => { @@ -156,10 +156,10 @@ export const FamilyList: React.FC = () => { const NoticeIcon = ({type}: {type: string}) => { switch(type) { - case 'warning': return ; - case 'maintenance': return ; - case 'event': return ; - default: return ; + case 'warning': return ; + case 'maintenance': return ; + case 'event': return ; + default: return ; } }; @@ -184,6 +184,7 @@ export const FamilyList: React.FC = () => {
{/* 1. BACHECA CONDOMINIALE (Notices) */} + {/* This section is rendered if notices feature is enabled and there are notices */} {settings?.features.notices && notices.length > 0 && (

@@ -194,67 +195,86 @@ export const FamilyList: React.FC = () => { const isRead = userReadIds.includes(notice.id); const isExpanded = expandedNoticeId === notice.id; - // Style configuration based on type and read status - let borderClass = isRead ? 'border-slate-200' : 'border-blue-300 shadow-md ring-1 ring-blue-50'; - let bgClass = isRead ? 'bg-white opacity-75' : 'bg-white'; + // Style configuration + // New notices get a distinct border and white background. + // Read notices get a slate background and are slightly dimmed to indicate "archive" status. + let containerClass = isRead + ? 'bg-slate-50 border-slate-200' + : 'bg-white border-blue-200 shadow-sm ring-1 ring-blue-50'; + if (notice.type === 'warning' && !isRead) { - borderClass = 'border-amber-300 shadow-md ring-1 ring-amber-50'; - bgClass = 'bg-amber-50/30'; + containerClass = 'bg-amber-50/50 border-amber-300 shadow-sm ring-1 ring-amber-50'; } return ( -
+
{/* Icon Column */} -
+
{/* Content Column */}
-
+ {/* Header: Title + Badges */} +
-

{notice.title}

- {!isRead && Nuovo} - {isRead && Letto} +

{notice.title}

+ {!isRead && ( + + Nuovo + + )} + {isRead && ( + + Letto + + )}
{new Date(notice.date).toLocaleDateString()}
-
+ {/* Body Text */} +
{notice.content}
- {/* Action Footer */} -
+ {/* Footer Actions */} +
- {/* Expand Button */} - {notice.content.length > 100 && ( + {/* Expand Button (only if long content) */} + {(notice.content.length > 120 || notice.content.includes('\n')) && ( )} - {/* External Link */} + {/* Link Button */} {notice.link && ( - + Apri Allegato )}
- {/* Mark as Read Button */} + {/* Mark as Read Button (Only if not read) */} {!isRead && ( )} + {/* Re-read indicator (optional visual cue) */} + {isRead && ( + + Archiviato + + )}