11"use client"
22
3- import {
4- Card ,
5- CardContent ,
6- CardHeader ,
7- CardTitle ,
8- } from "@/components/ui/card"
9- import {
10- ChartContainer ,
11- ChartConfig ,
12- ChartTooltip ,
13- ChartTooltipContent
14- } from "@/components/ui/chart"
15- import { Line , LineChart , XAxis , YAxis , CartesianGrid } from "recharts"
16- import { format } from "date-fns"
3+ import { AreaChart } from '@tinybirdco/charts'
174
18- export interface DailyLoginFailsDataPoint {
19- day : string
20- fails : number
21- }
22-
23- export interface DailyLoginFailsChartData {
24- data : DailyLoginFailsDataPoint [ ]
25- timeRange : 'hourly' | 'daily' | 'monthly'
26- className ?: string
27- }
28-
29- const chartConfig = {
30- fails : {
31- color : "hsl(var(--chart-1))" ,
32- label : "Login Fails" ,
33- } ,
34- } satisfies ChartConfig
35-
36- export function DailyLoginFailsChart ( { data, timeRange, className } : DailyLoginFailsChartData ) {
37- return (
38- < Card >
39- < CardHeader >
40- < CardTitle > Login Failures</ CardTitle >
41- </ CardHeader >
42- < CardContent className = "" >
43- < ChartContainer config = { chartConfig } className = { `w-full ${ className } ` } >
44- < LineChart
45- data = { data }
46- margin = { {
47- left : 48 ,
48- right : 12 ,
49- top : 12 ,
50- bottom : 32
51- } }
52- >
53- < CartesianGrid
54- horizontal = { true }
55- vertical = { false }
56- className = "stroke-muted"
57- />
58- < XAxis
59- dataKey = "day"
60- tickLine = { false }
61- axisLine = { false }
62- tickMargin = { 8 }
63- interval = "equidistantPreserveStart"
64- tickFormatter = { ( value ) => {
65- const date = new Date ( value )
66- return timeRange === 'monthly'
67- ? format ( date , 'MMM yyyy' )
68- : value . split ( '-' ) [ 2 ]
69- } }
70- label = { {
71- value : timeRange === 'monthly' ? "Month of Year" : "Day of Month" ,
72- position : "bottom" ,
73- offset : 20
74- } }
75- />
76- < YAxis
77- tickLine = { false }
78- axisLine = { false }
79- tickMargin = { 8 }
80- label = { {
81- value : "Login Failures" ,
82- angle : - 90 ,
83- position : "left" ,
84- offset : 32
85- } }
86- />
87- < ChartTooltip
88- cursor = { false }
89- content = { < ChartTooltipContent indicator = "dot" /> }
90- />
91- < Line
92- type = "monotone"
93- dataKey = "fails"
94- strokeWidth = { 2 }
95- dot = { true }
96- style = { {
97- stroke : chartConfig . fails . color ,
98- } }
99- activeDot = { { fill : chartConfig . fails . color , stroke : chartConfig . fails . color } }
100- />
101- </ LineChart >
102- </ ChartContainer >
103- </ CardContent >
104- </ Card >
105- )
106- }
5+ export function Auth0DailyLoginFails ( params : {
6+ client_id ?: string
7+ connection_id ?: string
8+ tenant_name ?: string
9+ token ?: string
10+ date_from ?: string
11+ date_to ?: string
12+ time_range ?: string
13+ } ) {
14+ return < AreaChart
15+ endpoint = { `${ process . env . NEXT_PUBLIC_TINYBIRD_API_HOST } /v0/pipes/auth0_daily_login_fails.json` }
16+ token = { params . token ?? '' }
17+ index = "day"
18+ categories = { [ 'fails' ] }
19+ height = "200px"
20+ params = { params }
21+ colorPalette = { [ '#000000' ] }
22+ />
23+ }
0 commit comments