mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-19 13:08:11 +02:00
feat: Implement virtualized product heatmap grid with data fetching and client integration.
This commit is contained in:
1 parent
9f827c7554
commit
d75454dd56
3 files changed
+14
-7
No files matched your search
@@ -149,7 +149,7 @@ export async function getProductRows(input: GetProductRowsInput): Promise<Produc
|
|||||||
const workingStores: string[] = [];
|
const workingStores: string[] = [];
|
||||||
for (const [magasin, periods] of productStores.entries()) {
|
for (const [magasin, periods] of productStores.entries()) {
|
||||||
if (magasin === "TOTAL") continue;
|
if (magasin === "TOTAL") continue;
|
||||||
if (periods.size >= 3) {
|
if (periods.size >= 1) {
|
||||||
workingStores.push(magasin);
|
workingStores.push(magasin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export function GridClient({ initialRows, nomFournisseur, fournisseurs, magasins
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
|
<div id="grid-toolbar-actions"></div>
|
||||||
<ExportDropdown nomFournisseur={nomFournisseur} />
|
<ExportDropdown nomFournisseur={nomFournisseur} />
|
||||||
{hasDrafts && (
|
{hasDrafts && (
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useRef, useState, useCallback, useEffect, useMemo } from "react";
|
import React, { useRef, useState, useCallback, useEffect, useMemo } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
import {
|
import {
|
||||||
useReactTable,
|
useReactTable,
|
||||||
getCoreRowModel,
|
getCoreRowModel,
|
||||||
@@ -178,6 +179,7 @@ export function HeatmapGrid({ onSelectionChange }: HeatmapGridProps) {
|
|||||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||||
const [columnVisibility, setColumnVisibility] = useState({});
|
const [columnVisibility, setColumnVisibility] = useState({});
|
||||||
const [isMounted, setIsMounted] = useState(false);
|
const [isMounted, setIsMounted] = useState(false);
|
||||||
|
const [portalContainer, setPortalContainer] = useState<HTMLElement | null>(null);
|
||||||
const tableContainerRef = useRef<HTMLDivElement>(null);
|
const tableContainerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
// Calculer les mois dynamiquement pour éviter le mismatch entre serveur et client
|
// Calculer les mois dynamiquement pour éviter le mismatch entre serveur et client
|
||||||
@@ -185,6 +187,8 @@ export function HeatmapGrid({ onSelectionChange }: HeatmapGridProps) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsMounted(true);
|
setIsMounted(true);
|
||||||
|
const container = document.getElementById('grid-toolbar-actions');
|
||||||
|
setPortalContainer(container);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const rowHeight = displayDensity === "compact" ? 32 : displayDensity === "normal" ? 40 : 48;
|
const rowHeight = displayDensity === "compact" ? 32 : displayDensity === "normal" ? 40 : 48;
|
||||||
@@ -473,7 +477,8 @@ export function HeatmapGrid({ onSelectionChange }: HeatmapGridProps) {
|
|||||||
overscan: 20,
|
overscan: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
const totalWidth = columns.reduce((s, c) => s + ((c as { size?: number }).size ?? 150), 0);
|
const visibleColumns = table.getVisibleLeafColumns();
|
||||||
|
const totalWidth = visibleColumns.reduce((s, c) => s + ((c.columnDef as { size?: number }).size ?? 150), 0);
|
||||||
|
|
||||||
if (!isMounted) {
|
if (!isMounted) {
|
||||||
return (
|
return (
|
||||||
@@ -490,8 +495,8 @@ export function HeatmapGrid({ onSelectionChange }: HeatmapGridProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full w-full gap-3 relative">
|
<div className="h-full w-full relative">
|
||||||
<div className="flex justify-end items-center w-full px-1">
|
{portalContainer && createPortal(
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<button
|
<button
|
||||||
@@ -524,12 +529,13 @@ export function HeatmapGrid({ onSelectionChange }: HeatmapGridProps) {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>,
|
||||||
</div>
|
portalContainer
|
||||||
|
)}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
ref={tableContainerRef}
|
ref={tableContainerRef}
|
||||||
className="flex-1 min-h-0 w-full overflow-auto rounded-[12px] scroll-smooth relative"
|
className="h-full w-full overflow-auto rounded-[12px] scroll-smooth relative"
|
||||||
style={{
|
style={{
|
||||||
background: "var(--bg-surface)",
|
background: "var(--bg-surface)",
|
||||||
border: "1px solid var(--border)",
|
border: "1px solid var(--border)",
|
||||||
|
|||||||
Reference in new issue
Block a user