@@ -19,6 +19,7 @@ import {
1919} from "@/components/ui/select"
2020import { Separator } from "@/components/ui/separator"
2121import { Card , CardContent } from "@/components/ui/card"
22+ import { Button } from "@/components/ui/button"
2223
2324interface ConversionData {
2425 new_signups : number
@@ -87,6 +88,7 @@ export default function Auth0Dashboard() {
8788 const [ selectedConnection , setSelectedConnection ] = useState < string > ( 'all' )
8889 const [ applications , setApplications ] = useState < Array < { client_id : string , client_name : string } > > ( [ ] )
8990 const [ connections , setConnections ] = useState < Array < { connection_id : string , connection_name : string } > > ( [ ] )
91+ const [ timeRange , setTimeRange ] = useState < 'hourly' | 'daily' | 'monthly' > ( 'daily' )
9092
9193 useEffect ( ( ) => {
9294 async function fetchInitialData ( ) {
@@ -124,12 +126,14 @@ export default function Auth0Dashboard() {
124126 const params = {
125127 date_from : fromDate ,
126128 date_to : toDate ,
129+ time_range : timeRange ,
127130 ...( selectedApp !== 'all' && { client_id : selectedApp } ) ,
128131 ...( selectedConnection !== 'all' && { connection_id : selectedConnection } )
129132 }
130133
131134 const thirtyDayParams = {
132135 date_from : thirtyDaysAgo ,
136+ time_range : timeRange ,
133137 ...( selectedApp !== 'all' && { client_id : selectedApp } ) ,
134138 ...( selectedConnection !== 'all' && { connection_id : selectedConnection } )
135139 }
@@ -150,6 +154,7 @@ export default function Auth0Dashboard() {
150154 dailyLoginFailsResult
151155 ] = await Promise . all ( [
152156 pipe < UsersResult > ( token , 'auth0_users_total' , selectedApp !== 'all' || selectedConnection !== 'all' ? {
157+ time_range : timeRange ,
153158 ...( selectedApp !== 'all' && { client_id : selectedApp } ) ,
154159 ...( selectedConnection !== 'all' && { connection_id : selectedConnection } )
155160 } : undefined ) ,
@@ -193,7 +198,7 @@ export default function Auth0Dashboard() {
193198 return ( ) => {
194199 mounted = false
195200 }
196- } , [ token , dateRange . from , dateRange . to , dateRange . compareMode , selectedApp , selectedConnection ] )
201+ } , [ token , dateRange . from , dateRange . to , dateRange . compareMode , selectedApp , selectedConnection , timeRange ] )
197202
198203 return (
199204 < div className = "space-y-8" >
@@ -275,18 +280,36 @@ export default function Auth0Dashboard() {
275280
276281 < Separator className = "my-6" />
277282
278- < div className = "flex justify-end" >
283+ < div className = "flex justify-end items-center gap-4" >
284+ < div className = "flex items-center gap-2" >
285+ < Button
286+ variant = { timeRange === 'hourly' ? 'default' : 'outline' }
287+ size = "sm"
288+ onClick = { ( ) => setTimeRange ( 'hourly' ) }
289+ >
290+ Hourly
291+ </ Button >
292+ < Button
293+ variant = { timeRange === 'daily' ? 'default' : 'outline' }
294+ size = "sm"
295+ onClick = { ( ) => setTimeRange ( 'daily' ) }
296+ >
297+ Daily
298+ </ Button >
299+ < Button
300+ variant = { timeRange === 'monthly' ? 'default' : 'outline' }
301+ size = "sm"
302+ onClick = { ( ) => setTimeRange ( 'monthly' ) }
303+ >
304+ Monthly
305+ </ Button >
306+ </ div >
279307 < DateRangePicker
280308 initialDateRange = { dateRange }
281309 onChange = { ( newRange ) => setDateRange ( newRange ) }
282310 />
283311 </ div >
284312
285- < DauChart
286- data = { dauData }
287- comparisonData = { dateRange . compareMode ? dauComparisonData : undefined }
288- />
289-
290313 { /* Charts Grid */ }
291314 < div className = "grid gap-4 grid-cols-1" >
292315 < DauChart data = { dauData } />
0 commit comments