feat: composants Lightbox plein écran + GlobalActions barre d'upload

This commit is contained in:
2026-06-08 17:45:22 +02:00
parent 683db58f4b
commit 568fe0d38e
2 changed files with 107 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
'use client'
import type { ImageItem } from '@/types/images'
interface GlobalActionsProps {
items: ImageItem[]
onUploadAll: () => void
}
export function GlobalActions({ items, onUploadAll }: GlobalActionsProps) {
if (items.length === 0) return null
const ready = items.filter((i) => i.status === 'ready').length
const processing = items.filter((i) => ['pending', 'converting', 'processing', 'searching'].includes(i.status)).length
const notFound = items.filter((i) => i.status === 'not_found').length
const uploaded = items.filter((i) => i.status === 'uploaded').length
const errors = items.filter((i) => i.status === 'error').length
return (
<div className="bg-slate-900 border border-slate-700 rounded-xl px-4 py-3 flex items-center gap-6 flex-wrap">
<div className="flex gap-4 text-xs text-slate-400 flex-1 flex-wrap">
{processing > 0 && <span> {processing} en traitement</span>}
{ready > 0 && <span className="text-green-400 font-semibold"> {ready} prêtes</span>}
{notFound > 0 && <span className="text-red-400"> {notFound} introuvables</span>}
{errors > 0 && <span className="text-red-400"> {errors} erreurs</span>}
{uploaded > 0 && <span className="text-slate-500"> {uploaded} uploadées</span>}
</div>
{ready > 0 && (
<button
onClick={onUploadAll}
className="bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-semibold px-4 py-2 rounded-lg transition-colors"
>
Tout uploader ({ready})
</button>
)}
</div>
)
}
+70
View File
@@ -0,0 +1,70 @@
'use client'
import { useEffect, useState } from 'react'
import type { ImageItem } from '@/types/images'
interface LightboxProps {
item: ImageItem | null
onClose: () => void
}
function BlobImg({ blob, alt }: { blob: Blob; alt: string }) {
const [url, setUrl] = useState<string | null>(null)
useEffect(() => {
const u = URL.createObjectURL(blob)
setUrl(u)
return () => URL.revokeObjectURL(u)
}, [blob])
if (!url) return null
return <img src={url} alt={alt} className="max-h-full max-w-full object-contain" />
}
export function Lightbox({ item, onClose }: LightboxProps) {
useEffect(() => {
const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() }
document.addEventListener('keydown', onKey)
return () => document.removeEventListener('keydown', onKey)
}, [onClose])
if (!item) return null
return (
<div
className="fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4"
onClick={onClose}
>
<div
className="bg-slate-900 rounded-xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col"
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-center justify-between px-4 py-3 border-b border-slate-700">
<div>
<span className="text-sm font-mono text-slate-300">{item.ref}</span>
{item.shopifyProductTitle && (
<span className="text-xs text-slate-500 ml-2">{item.shopifyProductTitle}</span>
)}
</div>
<button
onClick={onClose}
className="text-slate-400 hover:text-white text-xl leading-none"
></button>
</div>
<div className="flex flex-1 overflow-hidden min-h-0">
<div className="flex-1 flex flex-col items-center justify-center p-4 bg-slate-950 border-r border-slate-700">
<p className="text-xs text-slate-500 mb-2">Avant</p>
<BlobImg blob={item.originalBlob} alt="Avant" />
</div>
<div className="flex-1 flex flex-col items-center justify-center p-4 bg-white/5">
<p className="text-xs text-slate-500 mb-2">Après</p>
{item.processedBlob
? <BlobImg blob={item.processedBlob} alt="Après" />
: <p className="text-slate-600 text-sm">Traitement en cours</p>
}
</div>
</div>
</div>
</div>
)
}