import React, { useState, useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { CheckCircle2, Cpu, Globe, Link as LinkIcon } from 'lucide-react'; export default function SettingsModal({ onClose }: { onClose: () => void }) { const [formData, setFormData] = useState({ notionToken: '', notionDbId: '', ollamaUrl: '', ollamaModel: '', searxngUrl: '', aiLanguage: 'Français' }); const [saved, setSaved] = useState(false); useEffect(() => { fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3001'}/api/settings`, { credentials: 'include' }) .then(res => res.json()) .then(data => { if (data) { setFormData({ notionToken: data.notionToken || '', notionDbId: data.notionDbId || '', ollamaUrl: data.ollamaUrl || '', ollamaModel: data.ollamaModel || '', searxngUrl: data.searxngUrl || '', aiLanguage: data.aiLanguage || 'Français' }); } }) .catch(console.error); }, []); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); try { await fetch(`${import.meta.env.VITE_API_URL || 'http://localhost:3001'}/api/settings`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify(formData) }); setSaved(true); setTimeout(() => setSaved(false), 3000); } catch (err) { console.error(err); } }; return ( Paramètres Globaux Configurez vos intégrations Notion, Ollama et SearXNG pour personnaliser votre expérience LogAI.
{/* Notion Integration */}

Intégration Notion

setFormData({...formData, notionToken: e.target.value})} placeholder="secret_..." />
setFormData({...formData, notionDbId: e.target.value})} placeholder="ex: a1b2c3d4e5f6..." />
{/* AI Integration */}

Intégration IA (Ollama Local)

setFormData({...formData, ollamaUrl: e.target.value})} placeholder="ex: http://localhost:11434" />
setFormData({...formData, ollamaModel: e.target.value})} placeholder="ex: qwen:7b, llama3" />
{/* Search Integration */}

Recherche Web (SearXNG)

setFormData({...formData, searxngUrl: e.target.value})} placeholder="ex: http://localhost:8080" />
{saved && (
Sauvegardé avec succès
)}
); }