import { useMemo } from 'react'; import { OGDialog, DialogTemplate, useToastContext } from '@librechat/client'; import type { TTermsOfService } from 'librechat-data-provider'; import MarkdownLite from '~/components/Chat/Messages/Content/MarkdownLite'; import { useAcceptTermsMutation } from '~/data-provider'; import { useLocalize } from '~/hooks'; const TermsAndConditionsModal = ({ open, onOpenChange, onAccept, onDecline, title, modalContent, }: { open: boolean; onOpenChange: (isOpen: boolean) => void; onAccept: () => void; onDecline: () => void; title?: string; contentUrl?: string; modalContent?: TTermsOfService['modalContent']; }) => { const localize = useLocalize(); const { showToast } = useToastContext(); const acceptTermsMutation = useAcceptTermsMutation({ onSuccess: () => { onAccept(); onOpenChange(false); }, onError: () => { showToast({ message: 'Failed to accept terms' }); }, }); const handleAccept = () => { acceptTermsMutation.mutate(); }; const handleDecline = () => { onDecline(); onOpenChange(false); }; const handleOpenChange = (isOpen: boolean) => { if (open && !isOpen) { return; } onOpenChange(isOpen); }; const content = useMemo(() => { if (typeof modalContent === 'string') { return modalContent; } if (Array.isArray(modalContent)) { return modalContent.join('\n'); } return ''; }, [modalContent]); return (
{content !== '' ? ( ) : (

{localize('com_ui_no_terms_content')}

)}
} buttons={ <> } />
); }; export default TermsAndConditionsModal;