@@ -6,7 +6,7 @@ import { AnalyticsRes } from 'pages/api/orgs/[id]/analytics';
66
77import { useOrg } from 'lib/context/org' ;
88
9- import { formatRate , sameWeek } from './utils' ;
9+ import { formatRate } from './utils' ;
1010import Graph from './graph' ;
1111
1212interface LinkProps {
@@ -47,7 +47,15 @@ function Card<T extends Record<string, number> & { week: number }>({
4747} : CardProps < T > ) : JSX . Element {
4848 const num = useMemo ( ( ) => {
4949 if ( ! data || ! content ) return undefined ;
50- const today = data . find ( ( d ) => sameWeek ( new Date ( d . week ) , new Date ( ) ) ) ;
50+ console . log ( 'Finding current week date...' , data ) ;
51+ const today = data . find ( ( d ) => {
52+ const now = new Date ( ) ;
53+ const monday = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) ) ;
54+ monday . setDate ( monday . getDate ( ) - 7 - monday . getDay ( ) + 1 ) ;
55+ return monday . valueOf ( ) === new Date ( d . week ) . valueOf ( ) ;
56+ } ) ;
57+ console . log ( 'Found current week date:' , today ) ;
58+ console . log ( 'Accessing data:' , content [ 0 ] . dataKey ) ;
5159 return today ? today [ content [ 0 ] . dataKey ] : 0 ;
5260 } , [ data , content ] ) ;
5361
@@ -104,7 +112,7 @@ function Card<T extends Record<string, number> & { week: number }>({
104112 }
105113
106114 h2.loading {
107- width: 100px ;
115+ width: 50px ;
108116 }
109117
110118 .header h3 {
0 commit comments