@@ -2,7 +2,7 @@ import { trpc } from '@/api/trpc';
2
2
import { useCurrentWorkspaceId } from '@/store/user' ;
3
3
import dayjs from 'dayjs' ;
4
4
import React , { useMemo , useState } from 'react' ;
5
- import { TimeEventChart } from '../chart/TimeEventChart' ;
5
+ import { TimeEventChart , TimeEventChartType } from '../chart/TimeEventChart' ;
6
6
import { useInsightsStore } from '@/store/insights' ;
7
7
import { pickColorWithNum } from '@/utils/color' ;
8
8
import { DateRangeSelection } from './DateRangeSelection' ;
@@ -44,7 +44,19 @@ export const ChartRender: React.FC<ChartRenderProps> = React.memo((props) => {
44
44
dayjs ( ) . subtract ( 30 , 'day' ) . startOf ( 'day' ) . toDate ( ) ,
45
45
dayjs ( ) . endOf ( 'day' ) . toDate ( ) ,
46
46
] ) ;
47
+ const allowMinute = useMemo ( ( ) => {
48
+ const start = dayjs ( dateRange [ 0 ] ) ;
49
+ const end = dayjs ( dateRange [ 1 ] ) ;
50
+ return end . diff ( start , 'day' ) <= 1 ;
51
+ } , [ dateRange ] ) ;
47
52
const [ dateUnit , setDateUnit ] = useState < DateUnit > ( 'day' ) ;
53
+ const [ chartType , setChartType ] = useState < TimeEventChartType > ( 'area' ) ;
54
+
55
+ useWatch ( [ allowMinute , dateUnit ] , ( ) => {
56
+ if ( ! allowMinute && dateUnit === 'minute' ) {
57
+ setDateUnit ( 'day' ) ;
58
+ }
59
+ } ) ;
48
60
49
61
const time = useMemo (
50
62
( ) => ( {
0 commit comments