import React from 'react'; import { useWatch, useFormContext } from 'react-hook-form'; import { SystemRoles, Permissions, PermissionTypes } from 'librechat-data-provider'; import type { AgentForm, AgentPanelProps } from '~/common'; import { useLocalize, useAuthContext, useHasAccess } from '~/hooks'; import { useUpdateAgentMutation } from '~/data-provider'; import AdvancedButton from './Advanced/AdvancedButton'; import DuplicateAgent from './DuplicateAgent'; import AdminSettings from './AdminSettings'; import DeleteButton from './DeleteButton'; import { Spinner } from '~/components'; import ShareAgent from './ShareAgent'; import { Panel } from '~/common'; export default function AgentFooter({ activePanel, createMutation, updateMutation, setActivePanel, setCurrentAgentId, }: Pick< AgentPanelProps, 'setCurrentAgentId' | 'createMutation' | 'activePanel' | 'setActivePanel' > & { updateMutation: ReturnType; }) { const localize = useLocalize(); const { user } = useAuthContext(); const methods = useFormContext(); const { control } = methods; const agent = useWatch({ control, name: 'agent' }); const agent_id = useWatch({ control, name: 'id' }); const hasAccessToShareAgents = useHasAccess({ permissionType: PermissionTypes.AGENTS, permission: Permissions.SHARED_GLOBAL, }); const renderSaveButton = () => { if (createMutation.isLoading || updateMutation.isLoading) { return