import { PermissionAction } from '@supabase/shared-types/out/constants' import { useEffect } from 'react' import { Button, cn, Dialog, DialogContent, DialogFooter, DialogHeader, DialogSection, DialogSectionSeparator, DialogTitle, Form, } from 'ui' import { AIOptInLevelSelector } from '@/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector' import { useAIOptInForm } from '@/hooks/forms/useAIOptInForm' import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions' interface AIOptInModalProps { visible: boolean onCancel: () => void } export const AIOptInModal = ({ visible, onCancel }: AIOptInModalProps) => { const { form, onSubmit, isUpdating, currentOptInLevel } = useAIOptInForm(onCancel) const { can: canUpdateOrganization } = useAsyncCheckPermissions( PermissionAction.UPDATE, 'organizations' ) const onOpenChange = (open: boolean) => { if (!open) { onCancel() } } useEffect(() => { if (visible) { form.reset({ aiOptInLevel: currentOptInLevel }) } }, [visible, currentOptInLevel, form]) return (
Update Briven Assistant Opt-in Level {!canUpdateOrganization && (

You need additional permissions to update the opt-in level

)}
) }