SPB Git forge

spb/uqo-chat

Public
14commits 1branches 0releases
1.4 MBsize
maindefault branch
17 days agolast push
Python 64.6% TypeScript 33.7% CSS 0.8%
1.8 KB · 32 lines tsx
Raw Blame History
1import { Download, FileSpreadsheet, FileText, Image as ImageIcon, Share2 } from 'lucide-react';2import type { Artifact } from '@/lib/types';3import { downloadFile, shareFile } from '@/lib/api';45const icon = (t: string) => (t === 'xlsx' ? FileSpreadsheet : t === 'image' ? ImageIcon : FileText);6const label = (t: string) => (t === 'xlsx' ? 'Excel' : t === 'docx' ? 'Word' : t === 'csv' ? 'CSV' : t === 'image' ? 'Image' : 'Fichier');78export function ArtifactChips({ artifacts }: { artifacts?: Artifact[] }) {9  const list = (artifacts || []).filter((a) => a.file_id && a.type !== 'quiz' && a.type !== 'sources');10  if (!list.length) return null;11  const canShare = typeof navigator !== 'undefined' && !!navigator.share;12  return (13    <div className="flex flex-wrap gap-2">14      {list.map((a) => {15        const Icon = icon(a.type);16        return (17          <div key={a.file_id} className="inline-flex items-center rounded-xl border border-neutral-line bg-white overflow-hidden">18            <button onClick={() => downloadFile(a.file_id!, a.filename || 'fichier')} className="inline-flex items-center gap-2 px-3 min-h-[44px] text-sm hover:bg-neutral-surface">19              <Icon size={16} className="text-uqo-blue" /> <span className="max-w-[200px] truncate">{a.filename}</span> <span className="text-[10px] rounded bg-neutral-surface px-1.5 py-0.5 text-neutral-muted">{label(a.type)}</span> <Download size={14} className="text-neutral-muted" />20            </button>21            {canShare && (22              <button onClick={() => shareFile(a.file_id!, a.filename || 'fichier')} className="px-3 min-h-[44px] border-l border-neutral-line hover:bg-neutral-surface" aria-label="Partager">23                <Share2 size={14} className="text-neutral-muted" />24              </button>25            )}26          </div>27        );28      })}29    </div>30  );31}32