feat: Implement a new heatmap grid component for product data visualization and selection, and create new bulk AI analyzer and floating summary bar components.

This commit is contained in:
Michael committed 2026-02-22 13:23:11 +01:00
1 parent a04d6d4e7a
commit 804328a525
3 files changed
+20 -22

No files matched your search

@@ -188,15 +188,15 @@ export function BulkAiAnalyzer() {
if (isAnalyzing) { if (isAnalyzing) {
return ( return (
<div className="flex items-center gap-4 px-4 py-2 rounded-xl bg-indigo-50 dark:bg-indigo-900/30 border border-indigo-200 dark:border-indigo-800"> <div className="flex items-center gap-4 h-10 px-4 rounded-xl bg-indigo-50 dark:bg-indigo-900/30 border border-indigo-200 dark:border-indigo-800">
<Loader2 className="w-4 h-4 text-indigo-500 animate-spin" /> <Loader2 className="w-4 h-4 text-indigo-500 animate-spin" />
<div className="flex flex-col min-w-[150px]"> <div className="flex flex-col min-w-[150px]">
<span className="text-xs font-bold text-indigo-700 dark:text-indigo-400"> <span className="text-[10px] font-bold text-indigo-700 dark:text-indigo-400 leading-none">
{progress.message} {progress.message}
</span> </span>
<div className="w-full bg-indigo-200 dark:bg-indigo-800/50 rounded-full h-1.5 mt-1.5"> <div className="w-full bg-indigo-200 dark:bg-indigo-800/50 rounded-full h-1 mt-1">
<div <div
className="bg-indigo-500 h-1.5 rounded-full transition-all duration-300" className="bg-indigo-500 h-1 rounded-full transition-all duration-300"
style={{ width: `${Math.max(5, (progress.current / progress.total) * 100)}%` }} style={{ width: `${Math.max(5, (progress.current / progress.total) * 100)}%` }}
></div> ></div>
</div> </div>
@@ -206,7 +206,7 @@ export function BulkAiAnalyzer() {
className="p-1 hover:bg-indigo-100 dark:hover:bg-indigo-800 rounded-lg transition-colors text-indigo-600 dark:text-indigo-400" className="p-1 hover:bg-indigo-100 dark:hover:bg-indigo-800 rounded-lg transition-colors text-indigo-600 dark:text-indigo-400"
title="Arrêter l'analyse" title="Arrêter l'analyse"
> >
<XCircle className="w-5 h-5" /> <XCircle className="w-4 h-4" />
</button> </button>
</div> </div>
); );
@@ -214,12 +214,12 @@ export function BulkAiAnalyzer() {
if (progress.current > 0 && !isAnalyzing) { if (progress.current > 0 && !isAnalyzing) {
return ( return (
<div className="flex items-center gap-2 px-4 py-2 rounded-xl bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-800 cursor-default"> <div className="flex items-center gap-2 h-10 px-4 rounded-xl bg-emerald-50 dark:bg-emerald-900/30 border border-emerald-200 dark:border-emerald-800 cursor-default">
<CheckCircle2 className="w-4 h-4 text-emerald-600 dark:text-emerald-500" /> <CheckCircle2 className="w-4 h-4 text-emerald-600 dark:text-emerald-500" />
<span className="text-xs font-bold text-emerald-700 dark:text-emerald-400"> <span className="text-xs font-bold text-emerald-700 dark:text-emerald-400">
{progress.errors > 0 {progress.errors > 0
? `Terminé (${progress.current - progress.errors}/${progress.total} OK)` ? `Terminé (${progress.current - progress.errors}/${progress.total})`
: `Analyse terminée (${progress.total} produits)` : `Analyse Terminée`
} }
</span> </span>
</div> </div>
@@ -229,10 +229,10 @@ export function BulkAiAnalyzer() {
return ( return (
<button <button
onClick={handleAnalyze} onClick={handleAnalyze}
className="group flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all shadow-sm bg-gradient-to-r from-indigo-500 to-violet-500 text-white hover:shadow-md hover:brightness-110 active:scale-95 border border-indigo-400" className="group flex items-center justify-center gap-2 h-10 px-6 rounded-xl text-sm font-bold transition-all shadow-sm bg-gradient-to-r from-indigo-500 to-violet-500 text-white hover:shadow-md hover:brightness-110 active:scale-95 border border-indigo-400"
> >
<Sparkles className="w-4 h-4" /> <Sparkles className="w-4 h-4" />
Analyse IA Globale Analyse IA
</button> </button>
); );
} }
@@ -75,19 +75,16 @@ export function FloatingSummaryBar() {
const currentDrafts = currentState.draftChanges; const currentDrafts = currentState.draftChanges;
const currentRows = currentState.rows; const currentRows = currentState.rows;
// On définit les lignes modifiées comme étant soit dans les drafts,
// soit ayant une gamme différente de la gamme initiale (déjà sauvegardées)
const modifiedRows = currentRows.filter(r => { const modifiedRows = currentRows.filter(r => {
const currentGamme = currentDrafts[r.codein] ?? r.codeGamme; const currentGamme = currentDrafts[r.codein] ?? r.codeGamme;
return currentGamme !== r.codeGammeInit; return currentGamme !== r.codeGammeInit;
}); });
if (modifiedRows.length === 0) { if (modifiedRows.length === 0) {
alert("Aucun changement détecté par rapport à l'état initial. L'export Excel ne contient que les modifications de cette session."); alert("Aucun changement détecté par rapport à l'état initial.");
return; return;
} }
// Prepare payload
const changes = modifiedRows.map(r => ({ const changes = modifiedRows.map(r => ({
codein: r.codein, codein: r.codein,
gtin: r.gtin, gtin: r.gtin,
@@ -95,7 +92,7 @@ export function FloatingSummaryBar() {
gamme: (currentDrafts[r.codein] ?? r.codeGamme) as string, gamme: (currentDrafts[r.codein] ?? r.codeGamme) as string,
})); }));
const nomFournisseur = modifiedRows.length > 0 ? modifiedRows[0].nomFournisseur : "Fournisseur"; const nomFournisseur = modifiedRows[0].nomFournisseur;
try { try {
const res = await fetch("/api/export/modified-gammes", { const res = await fetch("/api/export/modified-gammes", {
@@ -115,10 +112,10 @@ export function FloatingSummaryBar() {
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
alert("Une erreur s'est produite lors de la génération du fichier Excel."); alert("Une erreur s'est produite lors de l'export Excel.");
} }
}} }}
className="px-6 py-3 rounded-xl text-sm font-bold transition-all active:scale-95 border hover:brightness-105" className="h-10 px-6 rounded-xl text-sm font-bold transition-all active:scale-95 border hover:brightness-105"
style={{ style={{
background: "var(--action-secondary-bg)", background: "var(--action-secondary-bg)",
color: "var(--action-secondary-text)", color: "var(--action-secondary-text)",
@@ -131,7 +128,7 @@ export function FloatingSummaryBar() {
<button <button
onClick={handleSave} onClick={handleSave}
disabled={!hasDrafts || isPending} disabled={!hasDrafts || isPending}
className="px-8 py-3 flex items-center gap-2 rounded-xl text-sm font-black transition-all shadow-lg active:scale-95 text-white hover:brightness-110 disabled:opacity-50" className="h-10 px-6 flex items-center justify-center gap-2 rounded-xl text-sm font-black transition-all shadow-lg active:scale-95 text-white hover:brightness-110 disabled:opacity-50"
style={{ style={{
background: "var(--brand-solid)", background: "var(--brand-solid)",
}} }}
@@ -143,7 +140,7 @@ export function FloatingSummaryBar() {
) : saveStatus === "error" ? ( ) : saveStatus === "error" ? (
<AlertCircle className="w-4 h-4" /> <AlertCircle className="w-4 h-4" />
) : null} ) : null}
{isPending ? "Validation..." : "Valider ce Fournisseur"} {isPending ? "Validation..." : "Valider"}
</button> </button>
</div> </div>
</div> </div>
@@ -45,12 +45,13 @@ function formatMonthLabel(key: string): string {
* Indigo for first store, Amber for second, Slate for others. * Indigo for first store, Amber for second, Slate for others.
*/ */
function getStoreConfig(name: string, index: number) { function getStoreConfig(name: string, index: number) {
const initial = name.charAt(0).toUpperCase();
if (index === 0) { if (index === 0) {
return { return {
bg: "rgba(99, 102, 241, 0.1)", // Indigo bg: "rgba(99, 102, 241, 0.1)", // Indigo
text: "#818cf8", text: "#818cf8",
border: "rgba(99, 102, 241, 0.2)", border: "rgba(99, 102, 241, 0.2)",
label: "M1" label: initial
}; };
} }
if (index === 1) { if (index === 1) {
@@ -58,14 +59,14 @@ function getStoreConfig(name: string, index: number) {
bg: "rgba(245, 158, 11, 0.1)", // Amber bg: "rgba(245, 158, 11, 0.1)", // Amber
text: "#fbbf24", text: "#fbbf24",
border: "rgba(245, 158, 11, 0.2)", border: "rgba(245, 158, 11, 0.2)",
label: "M2" label: initial
}; };
} }
return { return {
bg: "var(--bg-elevated)", bg: "var(--bg-elevated)",
text: "var(--text-muted)", text: "var(--text-muted)",
border: "var(--border)", border: "var(--border)",
label: name.charAt(0).toUpperCase() label: initial
}; };
} }