PrintLogModal.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { useEffect } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { X, History } from 'lucide-react';
  4. import { PrintLogTable } from './PrintLogTable';
  5. interface PrintLogModalProps {
  6. archiveId: number;
  7. archiveName: string | null;
  8. onClose: () => void;
  9. }
  10. export function PrintLogModal({ archiveId, archiveName, onClose }: PrintLogModalProps) {
  11. const { t } = useTranslation();
  12. useEffect(() => {
  13. const handleKeyDown = (e: KeyboardEvent) => {
  14. if (e.key === 'Escape') onClose();
  15. };
  16. window.addEventListener('keydown', handleKeyDown);
  17. return () => window.removeEventListener('keydown', handleKeyDown);
  18. }, [onClose]);
  19. return (
  20. <div
  21. className="fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4"
  22. onClick={onClose}
  23. >
  24. <div
  25. className="bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-2xl max-h-[85vh] flex flex-col"
  26. onClick={(e) => e.stopPropagation()}
  27. >
  28. <div className="flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary">
  29. <div className="flex items-center gap-2 min-w-0">
  30. <History className="w-5 h-5 text-bambu-green flex-shrink-0" />
  31. <h2 className="text-lg font-semibold text-white truncate" title={archiveName || ''}>
  32. {t('archives.runLog.modalTitle', { name: archiveName || t('archives.runLog.modalTitleFallback') })}
  33. </h2>
  34. </div>
  35. <button
  36. onClick={onClose}
  37. className="text-bambu-gray hover:text-white transition-colors"
  38. title={t('common.close')}
  39. >
  40. <X className="w-5 h-5" />
  41. </button>
  42. </div>
  43. <div className="p-6 overflow-y-auto flex-1">
  44. <PrintLogTable archiveId={archiveId} />
  45. </div>
  46. </div>
  47. </div>
  48. );
  49. }