ruvector/studio/components/ui/SingleStat.tsx
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

77 lines
2 KiB
TypeScript

import Link from 'next/link'
import type { ReactNode } from 'react'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
type SingleStatProps = {
icon: ReactNode
label: ReactNode
value: ReactNode
className?: string
href?: string
onClick?: () => void
trackingProperties?: {
stat_type: 'migrations' | 'backups' | 'branches'
stat_value: number
}
}
export const SingleStat = ({
icon,
label,
value,
className,
href,
onClick,
trackingProperties,
}: SingleStatProps) => {
const { mutate: sendEvent } = useSendEventMutation()
const { data: project } = useSelectedProjectQuery()
const { data: organization } = useSelectedOrganizationQuery()
const trackActivityStat = () => {
if (trackingProperties && project?.ref && organization?.slug) {
sendEvent({
action: 'home_activity_stat_clicked',
properties: trackingProperties,
groups: {
project: project.ref,
organization: organization.slug,
},
})
}
}
const content = (
<div className={`group flex items-center gap-4 p-0 text-base justify-start ${className || ''}`}>
<div className="w-16 h-16 rounded-md bg-surface-75 group-hover:bg-muted border flex items-center justify-center">
{icon}
</div>
<div>
<div className="text-left heading-meta text-foreground-light">{label}</div>
<div className="text-foreground truncate h-[34px] flex items-center capitalize-sentence">
{value}
</div>
</div>
</div>
)
if (href) {
return (
<Link className="group block" href={href} onClick={trackActivityStat}>
{content}
</Link>
)
}
if (onClick) {
return (
<button className="group" onClick={onClick}>
{content}
</button>
)
}
return content
}