SettingsDrawer.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React from 'react';
  2. import ConfigPanel from './ConfigPanel';
  3. import { AppSettings, ModelConfig } from '../types';
  4. import { X } from 'lucide-react';
  5. import { useLanguage } from '../contexts/LanguageContext';
  6. interface SettingsDrawerProps {
  7. isOpen: boolean;
  8. onClose: () => void;
  9. settings: AppSettings;
  10. models: ModelConfig[];
  11. onSettingsChange: (newSettings: AppSettings) => void;
  12. onOpenSettings: () => void; // Keeps the "Full Settings" link working if needed, or we might redirect
  13. mode?: 'chat' | 'kb' | 'all';
  14. }
  15. export const SettingsDrawer: React.FC<SettingsDrawerProps> = ({
  16. isOpen,
  17. onClose,
  18. settings,
  19. models,
  20. onSettingsChange,
  21. onOpenSettings,
  22. mode = 'all'
  23. }) => {
  24. const { t } = useLanguage();
  25. if (!isOpen) return null;
  26. return (
  27. <div className="fixed inset-0 z-50 overflow-hidden">
  28. <div className="absolute inset-0 bg-black bg-opacity-30 transition-opacity" onClick={onClose} />
  29. <div className="absolute inset-y-0 right-0 max-w-md w-full flex">
  30. <div className="flex-1 flex flex-col bg-white shadow-xl animate-in slide-in-from-right duration-300">
  31. <div className="flex items-center justify-between px-4 py-3 border-b border-gray-200">
  32. <h2 className="text-lg font-medium text-gray-900">{t('systemConfiguration')}</h2>
  33. <button
  34. onClick={onClose}
  35. className="text-gray-400 hover:text-gray-500 focus:outline-none"
  36. >
  37. <X size={24} />
  38. </button>
  39. </div>
  40. <div className="flex-1 overflow-y-auto">
  41. <ConfigPanel
  42. settings={settings}
  43. models={models}
  44. onSettingsChange={onSettingsChange}
  45. onOpenSettings={onOpenSettings}
  46. mode={mode}
  47. />
  48. </div>
  49. <div className="p-4 border-t border-gray-200 bg-gray-50">
  50. <button
  51. onClick={onClose}
  52. className="w-full py-2.5 bg-blue-600 text-white font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm"
  53. >
  54. {t('confirm')}
  55. </button>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. );
  61. };