@@ -113,11 +113,54 @@ const projectStatusButtons = [
113113 } ,
114114] ;
115115
116- export default function WeeklyProjectSummary ( ) {
116+ export function WeeklyProjectSummaryContent ( ) {
117117 const dispatch = useDispatch ( ) ;
118118 const materials = useSelector ( state => state . materials ?. materialslist || [ ] ) ;
119119 const [ openSections , setOpenSections ] = useState ( { } ) ;
120120
121+ const getColorScheme = percentage => {
122+ if ( percentage === '-' ) return 'neutral' ;
123+ if ( percentage > 0 ) return 'positive' ;
124+ if ( percentage < 0 ) return 'negative' ;
125+ return 'neutral' ;
126+ } ;
127+
128+ const colorScheme = getColorScheme ( monthOverMonth ) ;
129+
130+ const titleClass = title . replace ( / \s + / g, '-' ) . toLowerCase ( ) ;
131+
132+ return (
133+ < div
134+ className = { `financial-card ${ colorScheme } custom-box-shadow financial-card-background-${ titleClass } ` }
135+ onMouseEnter = { ( ) => setShowTooltip ( true ) }
136+ onMouseLeave = { ( ) => setShowTooltip ( false ) }
137+ >
138+ < div className = "financial-card-title" > { title } </ div >
139+ < div className = { `financial-card-ellipse financial-card-ellipse-${ titleClass } ` } />
140+ < div className = "financial-card-value" > { value === '-' ? '-' : value . toLocaleString ( ) } </ div >
141+ < div className = { `financial-card-month-over-month ${ colorScheme } ` } >
142+ { monthOverMonth === '-'
143+ ? '-'
144+ : `${ monthOverMonth > 0 ? '+' : '' } ${ monthOverMonth } % month over month` }
145+ </ div >
146+
147+ { /* Tooltip for Additional Info */ }
148+ { showTooltip && Object . keys ( additionalInfo ) . length > 0 && (
149+ < div className = "financial-card-tooltip" >
150+ { Object . entries ( additionalInfo ) . map ( ( [ key ] ) => (
151+ < div key = { key } className = "financial-card-tooltip-item" >
152+ < span className = "tooltip-key" > { key } :</ span >
153+ < span className = "tooltip-value" > { value } </ span >
154+ </ div >
155+ ) ) }
156+ </ div >
157+ ) }
158+ </ div >
159+ ) ;
160+ }
161+
162+ function WeeklyProjectSummary ( ) {
163+ const [ openSections , setOpenSections ] = useState ( { } ) ;
121164 const darkMode = useSelector ( state => state . theme . darkMode ) ;
122165
123166 useEffect ( ( ) => {
@@ -429,3 +472,5 @@ export default function WeeklyProjectSummary() {
429472 </ div >
430473 ) ;
431474}
475+
476+ export default WeeklyProjectSummary ;
0 commit comments