mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-15 19:28:52 +02:00
feat: Add bulk AI product analysis component with supporting data types and AI system prompt.
This commit is contained in:
1 parent
b015d1f093
commit
661704bf38
3 files changed
+16
-4
No files matched your search
@@ -20,12 +20,16 @@ export function BulkAiAnalyzer() {
|
||||
};
|
||||
|
||||
const handleAnalyze = async () => {
|
||||
const { rows } = useGridStore.getState();
|
||||
isCancelledRef.current = false;
|
||||
|
||||
const totalQtySum = rows.reduce((sum, r) => sum + (r.totalQuantite || 0), 0);
|
||||
const avgQty = rows.length > 0 ? totalQtySum / rows.length : 0;
|
||||
|
||||
// Benchmarks par groupe de magasins
|
||||
const rowsGroup1 = rows.filter(r => (r.workingStores?.length || 1) === 1);
|
||||
const rowsGroup2 = rows.filter(r => (r.workingStores?.length || 1) >= 2);
|
||||
|
||||
const avgQty1 = rowsGroup1.length > 0 ? rowsGroup1.reduce((s, r) => s + (r.totalQuantite || 0), 0) / rowsGroup1.length : 0;
|
||||
const avgQty2 = rowsGroup2.length > 0 ? rowsGroup2.reduce((s, r) => s + (r.totalQuantite || 0), 0) / rowsGroup2.length : 0;
|
||||
|
||||
const productPayloads: ProductAnalysisInput[] = rows.map(r => ({
|
||||
codein: r.codein,
|
||||
libelle1: r.libelle1 || "",
|
||||
@@ -33,6 +37,9 @@ export function BulkAiAnalyzer() {
|
||||
tauxMarge: r.tauxMarge || 0,
|
||||
totalQuantite: r.totalQuantite || 0,
|
||||
avgTotalQuantite: avgQty,
|
||||
avgQtyGroup1: avgQty1,
|
||||
avgQtyGroup2: avgQty2,
|
||||
storeCount: r.workingStores?.length || 1,
|
||||
sales12m: r.sales12m || {},
|
||||
codeGamme: r.codeGamme || null,
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user