import { PermissionAction } from '@supabase/shared-types/out/constants' import { Check, Webhook } from 'lucide-react' import { Badge } from 'ui' import { Input } from 'ui-patterns/DataInputs/Input' import { Hook } from './hooks.constants' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import { DocsButton } from '@/components/ui/DocsButton' import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions' import { DOCS_URL } from '@/lib/constants' interface HookCardProps { hook: Hook onSelect: () => void } export const HookCard = ({ hook, onSelect }: HookCardProps) => { const { can: canUpdateAuthHook } = useAsyncCheckPermissions(PermissionAction.AUTH_EXECUTE, '*') return (
{hook.title} {hook.subtitle}
{hook.method.type === 'postgres' ? (
type Postgres function
) : (
type HTTPS endpoint
)}
onSelect()} tooltip={{ content: { side: 'bottom', text: !canUpdateAuthHook ? 'You need additional permissions to configure auth hooks' : undefined, }, }} > Configure hook
{hook.enabled ? (
Enabled
) : ( Disabled )}
) }