1- " use client"
1+ ' use client'
22
3- import {
4- Card ,
5- CardContent ,
6- CardHeader ,
7- CardTitle ,
8- } from "@/components/ui/card"
9- import {
10- ChartContainer ,
11- ChartTooltip ,
12- ChartConfig ,
13- ChartTooltipContent
14- } from "@/components/ui/chart"
15- import { Bar , BarChart , XAxis , YAxis } from "recharts"
3+ import { BarList } from '@tinybirdco/charts'
164
17- export interface AuthMechDataPoint {
18- mech : string
19- logins : number
20- }
21-
22- export interface AuthMechChartData {
23- data : AuthMechDataPoint [ ]
24- className ?: string
25- }
26-
27- const chartConfig = {
28- logins : {
29- color : "hsl(var(--chart-1))" ,
30- label : "Logins" ,
31- } ,
32- } satisfies ChartConfig
33-
34- function transformData ( data : AuthMechDataPoint [ ] ) : ( AuthMechDataPoint & { fill : string } ) [ ] {
35- return data . map ( ( item , index ) => ( {
36- ...item ,
37- fill : `hsl(var(--chart-${ ( index % 12 ) + 1 } ))`
38- } ) ) ;
39- }
40-
41- export function AuthMechChart ( { data, className } : AuthMechChartData ) {
42- const sortedData = transformData ( [ ...data ] . sort ( ( a , b ) => b . logins - a . logins ) )
43-
44- return (
45- < Card >
46- < CardHeader >
47- < CardTitle > Authentication Methods</ CardTitle >
48- </ CardHeader >
49- < CardContent >
50- < ChartContainer config = { chartConfig } className = { `w-full ${ className } ` } >
51- < BarChart
52- data = { sortedData }
53- layout = "vertical"
54- margin = { {
55- left : 24 ,
56- right : 12 ,
57- top : 12 ,
58- bottom : 12 ,
59- } }
60- >
61- < XAxis
62- type = "number"
63- tickLine = { false }
64- axisLine = { false }
65- tickMargin = { 8 }
66- />
67- < YAxis
68- type = "category"
69- dataKey = "mech"
70- tickLine = { false }
71- axisLine = { false }
72- tickMargin = { 8 }
73- width = { 70 }
74- />
75- < ChartTooltip
76- content = { < ChartTooltipContent /> }
77- cursor = { { fill : "hsl(var(--muted))" , opacity : 0.2 } }
78- />
79- < Bar
80- dataKey = "logins"
81- radius = { [ 4 , 4 , 4 , 4 ] }
82- />
83- </ BarChart >
84- </ ChartContainer >
85- </ CardContent >
86- </ Card >
87- )
88- }
5+ export function Auth0TopAuth ( 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+ } ) {
13+ return < BarList
14+ endpoint = { `${ process . env . NEXT_PUBLIC_TINYBIRD_API_HOST } /v0/pipes/auth0_mech_usage.json` }
15+ token = { params . token ?? '' }
16+ index = "mech"
17+ categories = { [ 'logins' ] }
18+ colorPalette = { [ '#000000' ] }
19+ height = "250px"
20+ params = { params }
21+ indexConfig = { {
22+ label : 'AUTH' ,
23+ renderBarContent : ( { label } ) => (
24+ < span className = "font-normal text-white [text-shadow:2px_1px_0px_#000]" > { label } </ span >
25+ )
26+ } }
27+ options = { {
28+ tooltip : {
29+ backgroundColor : '#fff' ,
30+ textStyle : {
31+ color : '#333'
32+ }
33+ }
34+ } }
35+ />
36+ }
0 commit comments