@@ -56,8 +56,23 @@ const DashboardView = memo(({ onDone }: DashboardViewProps) => {
5656 const [ clearNonce , setClearNonce ] = useState < string | null > ( null )
5757
5858 // Custom range date inputs (YYYY-MM-DD). Only used when preset === "custom".
59- const [ customFrom , setCustomFrom ] = useState < string > ( "" )
60- const [ customTo , setCustomTo ] = useState < string > ( "" )
59+ // Default to yesterday~today so the inputs are never empty on first selection.
60+ const toLocalDateString = useCallback ( ( d : Date ) => {
61+ const year = d . getFullYear ( )
62+ const month = String ( d . getMonth ( ) + 1 ) . padStart ( 2 , "0" )
63+ const day = String ( d . getDate ( ) ) . padStart ( 2 , "0" )
64+ return `${ year } -${ month } -${ day } `
65+ } , [ ] )
66+
67+ const defaultDateRange = useMemo ( ( ) => {
68+ const now = new Date ( )
69+ const yesterday = new Date ( now )
70+ yesterday . setDate ( now . getDate ( ) - 1 )
71+ return { from : toLocalDateString ( yesterday ) , to : toLocalDateString ( now ) }
72+ } , [ toLocalDateString ] )
73+
74+ const [ customFrom , setCustomFrom ] = useState < string > ( defaultDateRange . from )
75+ const [ customTo , setCustomTo ] = useState < string > ( defaultDateRange . to )
6176
6277 // Track the latest request to ignore stale responses
6378 const latestRequestIdRef = useRef < string > ( "" )
0 commit comments