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