@@ -5,10 +5,16 @@ import { cn } from "@/lib/utils";
55import { StatisticalUnitIcon } from "@/components/statistical-unit-icon" ;
66import { StatisticalUnitDetailsLinkWithSubPath } from "@/components/statistical-unit-details-link-with-sub-path" ;
77import { Card , CardContent , CardHeader , CardTitle } from "@/components/ui/card" ;
8- import { Asterisk } from "lucide-react" ;
8+ import { Asterisk , Info } from "lucide-react" ;
99import { thousandSeparator } from "@/lib/number-utils" ;
10- import { useBaseData } from '@/atoms/base-data' ;
11- import { Tables } from '@/lib/database.types' ;
10+ import { useBaseData } from "@/atoms/base-data" ;
11+ import { Tables } from "@/lib/database.types" ;
12+ import {
13+ Tooltip ,
14+ TooltipContent ,
15+ TooltipProvider ,
16+ TooltipTrigger ,
17+ } from "../ui/tooltip" ;
1218
1319interface TopologyItemProps {
1420 readonly active ?: boolean ;
@@ -55,7 +61,27 @@ export function TopologyItem({
5561 active && "bg-gray-300"
5662 ) }
5763 >
58- < CardTitle className = "text-xs font-medium" > { unit . name } </ CardTitle >
64+ < div className = "flex" >
65+ < CardTitle className = "text-xs font-medium" > { unit . name } </ CardTitle >
66+ { unit . status ?. used_for_counting === false && (
67+ < div className = "self-center pl-1" >
68+ < TooltipProvider >
69+ < Tooltip >
70+ < TooltipTrigger asChild >
71+ < Info className = "h-4 w-4 fill-blue-300 stroke-gray-700" />
72+ </ TooltipTrigger >
73+ < TooltipContent >
74+ < span className = "text-sm" >
75+ This unit has status{ " " }
76+ < strong > { unit . status ?. name } </ strong > and is therefore
77+ not included in aggregates.
78+ </ span >
79+ </ TooltipContent >
80+ </ Tooltip >
81+ </ TooltipProvider >
82+ </ div >
83+ ) }
84+ </ div >
5985 < div className = "flex items-center space-x-1" >
6086 { primary && (
6187 < div title = "This is a primary unit" >
@@ -82,29 +108,34 @@ export function TopologyItem({
82108 title = "Country"
83109 value = { location ?. country ?. name }
84110 />
85- { statDefinitions . map ( ( statDefinition : Tables < 'stat_definition_active' > ) => {
86- const statsSum =
87- stats ?. stats_summary ?. [ statDefinition . code ] ?. sum ;
88- const stat = unit . stat_for_unit ?. find (
89- ( s ) => s . stat_definition_id === statDefinition . id
90- ) ;
91- const value =
92- stat ?. value_int ??
93- stat ?. value_bool ??
94- stat ?. value_float ??
95- stat ?. value_string ;
96- const formattedValue =
97- typeof value === "number" ? thousandSeparator ( value ) : value ;
98- return (
99- < TopologyItemInfo
100- key = { statDefinition . id }
101- className = "flex-1"
102- title = { statDefinition . name ! }
103- value = { type !== "enterprise" && formattedValue }
104- sum = { thousandSeparator ( statsSum ) }
105- />
106- ) ;
107- } ) }
111+ { statDefinitions . map (
112+ ( statDefinition : Tables < "stat_definition_active" > ) => {
113+ const statsSum =
114+ stats ?. stats_summary ?. [ statDefinition . code ] ?. sum ;
115+ const stat = unit . stat_for_unit ?. find (
116+ ( s ) => s . stat_definition_id === statDefinition . id
117+ ) ;
118+ const value =
119+ stat ?. value_int ??
120+ stat ?. value_bool ??
121+ stat ?. value_float ??
122+ stat ?. value_string ;
123+ const formattedValue =
124+ typeof value === "number"
125+ ? thousandSeparator ( value )
126+ : value ;
127+ return (
128+ < TopologyItemInfo
129+ key = { statDefinition . id }
130+ className = "flex-1"
131+ title = { statDefinition . name ! }
132+ value = { type !== "enterprise" && formattedValue }
133+ sum = { thousandSeparator ( statsSum ) }
134+ status = { unit . status }
135+ />
136+ ) ;
137+ }
138+ ) }
108139 </ div >
109140 < TopologyItemInfo
110141 title = "Primary Activity"
@@ -128,6 +159,7 @@ interface TopologyItemInfoProps {
128159 fallbackValue ?: string ;
129160 className ?: string ;
130161 sum ?: string | number | boolean | null ;
162+ status ?: Status ;
131163}
132164
133165const TopologyItemInfo = ( {
@@ -136,10 +168,16 @@ const TopologyItemInfo = ({
136168 fallbackValue = "-" ,
137169 className,
138170 sum,
171+ status,
139172} : TopologyItemInfoProps ) => (
140173 < div className = { cn ( "flex flex-col space-y-0 text-left" , className ) } >
141174 < span className = "text-xs font-medium uppercase text-gray-500" > { title } </ span >
142- < span className = "text-sm" > { value ?? fallbackValue } </ span >
175+ < span
176+ className = { `text-sm ${ status ?. used_for_counting === false && "italic text-stone-500" } ` }
177+ title = { `This unit has status ${ status ?. name } , therefore this value is not included in aggregates.` }
178+ >
179+ { value ?? fallbackValue }
180+ </ span >
143181 { sum && (
144182 < div className = "inline-flex items-center font-semibold" >
145183 < span className = "text-xs mr-1" > ∑</ span >
0 commit comments