@apotech-os/support-kit 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/index.cjs +586 -180
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +588 -182
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
package/dist/ui/index.cjs
CHANGED
|
@@ -283,225 +283,631 @@ function formatDate(iso) {
|
|
|
283
283
|
function toNameMap(rows) {
|
|
284
284
|
return new Map(rows.map((r) => [r.id, r.name]));
|
|
285
285
|
}
|
|
286
|
-
function windowCutoffIso(days) {
|
|
287
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
288
|
-
}
|
|
289
286
|
|
|
290
287
|
// src/ui/dashboard/dashboard-stats.ts
|
|
291
|
-
function sumCounts(rows, countField = "count") {
|
|
292
|
-
return rows.reduce((sum, row) => sum + (Number(row[countField]) || 0), 0);
|
|
293
|
-
}
|
|
294
|
-
function countFor(rows, groupField, value, countField = "count") {
|
|
295
|
-
const row = rows.find((r) => r[groupField] === value);
|
|
296
|
-
return row ? Number(row[countField]) || 0 : 0;
|
|
297
|
-
}
|
|
298
288
|
function bucketDay(row) {
|
|
299
289
|
return String(row["bucket"]).slice(0, 10);
|
|
300
290
|
}
|
|
301
|
-
|
|
291
|
+
var EMPTY_TOTALS = {
|
|
292
|
+
auto: 0,
|
|
293
|
+
human: 0,
|
|
294
|
+
inProgress: 0,
|
|
295
|
+
noReplyNeeded: 0,
|
|
296
|
+
failed: 0
|
|
297
|
+
};
|
|
298
|
+
function outcomeOf(status, autoSendDecision) {
|
|
299
|
+
if (status === "sent") return "auto";
|
|
300
|
+
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
301
|
+
if (status === "failed") return "failed";
|
|
302
|
+
if (status === "invalidated" || status === "expired") return "human";
|
|
303
|
+
return autoSendDecision === "hold" ? "human" : "inProgress";
|
|
304
|
+
}
|
|
305
|
+
function foldOutcomes(rows) {
|
|
306
|
+
const totals = { ...EMPTY_TOTALS };
|
|
307
|
+
for (const row of rows) {
|
|
308
|
+
totals[outcomeOf(row["status"], row["autoSendDecision"])] += Number(row["count"]) || 0;
|
|
309
|
+
}
|
|
310
|
+
return totals;
|
|
311
|
+
}
|
|
312
|
+
function settledCount(totals) {
|
|
313
|
+
return totals.auto + totals.human;
|
|
314
|
+
}
|
|
315
|
+
function autonomyRate(totals) {
|
|
316
|
+
const settled = settledCount(totals);
|
|
317
|
+
return settled > 0 ? totals.auto / settled : Number.NaN;
|
|
318
|
+
}
|
|
319
|
+
function foldDailyOutcomes(rows) {
|
|
302
320
|
const byDay = /* @__PURE__ */ new Map();
|
|
303
|
-
for (const row of
|
|
321
|
+
for (const row of rows) {
|
|
304
322
|
const day = bucketDay(row);
|
|
305
|
-
|
|
323
|
+
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
324
|
+
totals[outcomeOf(row["status"], row["autoSendDecision"])] += Number(row["count"]) || 0;
|
|
325
|
+
byDay.set(day, totals);
|
|
306
326
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
327
|
+
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
328
|
+
day,
|
|
329
|
+
auto: totals.auto,
|
|
330
|
+
human: totals.human,
|
|
331
|
+
rate: settledCount(totals) > 0 ? autonomyRate(totals) : null
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
function fillMissingDays(series, fromIso, toIso) {
|
|
335
|
+
const from = Date.parse(fromIso.slice(0, 10));
|
|
336
|
+
const to = Date.parse(toIso.slice(0, 10));
|
|
337
|
+
if (Number.isNaN(from) || Number.isNaN(to) || to < from) return series;
|
|
338
|
+
const measured = new Map(series.map((point) => [point.day, point]));
|
|
339
|
+
const filled = [];
|
|
340
|
+
for (let t = from; t <= to; t += 864e5) {
|
|
341
|
+
const day = new Date(t).toISOString().slice(0, 10);
|
|
342
|
+
filled.push(measured.get(day) ?? { day, auto: 0, human: 0, rate: null });
|
|
343
|
+
}
|
|
344
|
+
return filled;
|
|
345
|
+
}
|
|
346
|
+
function ratePoints(rate, compareRate) {
|
|
347
|
+
return Number.isNaN(rate) || Number.isNaN(compareRate) ? null : (rate - compareRate) * 100;
|
|
348
|
+
}
|
|
349
|
+
var SIGNAL_MIN_VOLUME = 20;
|
|
350
|
+
var SIGNAL_MIN_POINTS = 3;
|
|
351
|
+
function dashboardSignals(totals, compare) {
|
|
352
|
+
const signals = [];
|
|
353
|
+
const settled = settledCount(totals);
|
|
354
|
+
const rate = autonomyRate(totals);
|
|
355
|
+
if (compare !== null && settled >= SIGNAL_MIN_VOLUME && settledCount(compare) >= SIGNAL_MIN_VOLUME) {
|
|
356
|
+
const points = ratePoints(rate, autonomyRate(compare));
|
|
357
|
+
if (points !== null && Math.abs(points) >= SIGNAL_MIN_POINTS) {
|
|
358
|
+
const move = points < 0 ? "recule" : "progresse";
|
|
359
|
+
signals.push({
|
|
360
|
+
level: points < 0 ? "creuser" : "info",
|
|
361
|
+
text: `Le taux d\u2019autonomie ${move} de ${Math.abs(Math.round(points))} points par rapport \xE0 la p\xE9riode pr\xE9c\xE9dente.`
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (totals.failed > 0) {
|
|
366
|
+
signals.push({
|
|
367
|
+
level: "creuser",
|
|
368
|
+
text: `${totals.failed} g\xE9n\xE9ration${totals.failed > 1 ? "s ont" : " a"} \xE9chou\xE9 techniquement : ${totals.failed > 1 ? "ces demandes n\u2019ont" : "cette demande n\u2019a"} jamais eu de brouillon.`
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
if (totals.inProgress > 0) {
|
|
372
|
+
signals.push({
|
|
373
|
+
level: "info",
|
|
374
|
+
text: `${totals.inProgress} r\xE9ponse${totals.inProgress > 1 ? "s sont" : " est"} encore en cours : ${totals.inProgress > 1 ? "elles ne comptent" : "elle ne compte"} dans aucun des deux camps.`
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (totals.noReplyNeeded > 0) {
|
|
378
|
+
signals.push({
|
|
379
|
+
level: "info",
|
|
380
|
+
text: `${totals.noReplyNeeded} demande${totals.noReplyNeeded > 1 ? "s" : ""} ne n\xE9cessitai${totals.noReplyNeeded > 1 ? "ent" : "t"} aucune r\xE9ponse : hors du taux d\u2019autonomie.`
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
if (compare !== null && settled > 0 && settledCount(compare) < SIGNAL_MIN_VOLUME) {
|
|
384
|
+
signals.push({
|
|
385
|
+
level: "info",
|
|
386
|
+
text: "La p\xE9riode pr\xE9c\xE9dente compte trop peu de demandes r\xE9gl\xE9es pour que la comparaison veuille dire quelque chose."
|
|
387
|
+
});
|
|
311
388
|
}
|
|
312
|
-
return
|
|
389
|
+
return signals;
|
|
313
390
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
|
|
391
|
+
function foldHumanReasons(rows) {
|
|
392
|
+
const reasons = { blocked: 0, invalidated: 0, expired: 0 };
|
|
393
|
+
for (const row of rows) {
|
|
394
|
+
if (outcomeOf(row["status"], row["autoSendDecision"]) !== "human") continue;
|
|
395
|
+
const count = Number(row["count"]) || 0;
|
|
396
|
+
if (row["status"] === "invalidated") reasons.invalidated += count;
|
|
397
|
+
else if (row["status"] === "expired") reasons.expired += count;
|
|
398
|
+
else reasons.blocked += count;
|
|
399
|
+
}
|
|
400
|
+
return reasons;
|
|
401
|
+
}
|
|
402
|
+
var CATEGORY_TOP_N = 10;
|
|
403
|
+
function foldCategoryOutcomes(triageRows, responseRows, categoryNames, topN = CATEGORY_TOP_N) {
|
|
404
|
+
const byId = /* @__PURE__ */ new Map();
|
|
405
|
+
const barFor = (id) => {
|
|
318
406
|
const name = typeof id === "string" ? categoryNames.get(id) : void 0;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
407
|
+
if (name === void 0) return null;
|
|
408
|
+
const existing = byId.get(id);
|
|
409
|
+
if (existing !== void 0) return existing;
|
|
410
|
+
const bar = {
|
|
411
|
+
label: name,
|
|
412
|
+
total: 0,
|
|
413
|
+
auto: 0,
|
|
414
|
+
human: 0,
|
|
415
|
+
noReply: 0,
|
|
416
|
+
undrafted: 0
|
|
417
|
+
};
|
|
418
|
+
byId.set(id, bar);
|
|
419
|
+
return bar;
|
|
420
|
+
};
|
|
421
|
+
for (const row of triageRows) {
|
|
422
|
+
const bar = barFor(row["categoryId"]);
|
|
423
|
+
if (bar !== null) bar.total += Number(row["count"]) || 0;
|
|
424
|
+
}
|
|
425
|
+
for (const row of responseRows) {
|
|
426
|
+
const bar = barFor(row["categoryId"]);
|
|
427
|
+
if (bar === null) continue;
|
|
428
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
429
|
+
const count = Number(row["count"]) || 0;
|
|
430
|
+
if (outcome === "auto") bar.auto += count;
|
|
431
|
+
else if (outcome === "human") bar.human += count;
|
|
432
|
+
else if (outcome === "noReplyNeeded") bar.noReply += count;
|
|
433
|
+
}
|
|
434
|
+
const bars = [...byId.values()].map((bar) => {
|
|
435
|
+
const accounted = bar.auto + bar.human + bar.noReply;
|
|
436
|
+
return {
|
|
437
|
+
...bar,
|
|
438
|
+
total: Math.max(bar.total, accounted),
|
|
439
|
+
undrafted: Math.max(0, bar.total - accounted)
|
|
440
|
+
};
|
|
441
|
+
}).filter((bar) => bar.total > 0).sort((a, b) => b.total - a.total);
|
|
442
|
+
if (bars.length <= topN + 1) return bars;
|
|
443
|
+
const tail = bars.slice(topN).reduce(
|
|
444
|
+
(sum, bar) => ({
|
|
445
|
+
label: "Autres",
|
|
446
|
+
total: sum.total + bar.total,
|
|
447
|
+
auto: sum.auto + bar.auto,
|
|
448
|
+
human: sum.human + bar.human,
|
|
449
|
+
noReply: sum.noReply + bar.noReply,
|
|
450
|
+
undrafted: sum.undrafted + bar.undrafted
|
|
451
|
+
}),
|
|
452
|
+
{ label: "Autres", total: 0, auto: 0, human: 0, noReply: 0, undrafted: 0 }
|
|
453
|
+
);
|
|
454
|
+
return [...bars.slice(0, topN), tail];
|
|
324
455
|
}
|
|
325
|
-
var
|
|
326
|
-
|
|
456
|
+
var POINTS_FORMAT = new Intl.NumberFormat("fr-FR", {
|
|
457
|
+
maximumFractionDigits: 1,
|
|
458
|
+
signDisplay: "exceptZero"
|
|
459
|
+
});
|
|
327
460
|
function formatRate(value) {
|
|
328
|
-
return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)}%`;
|
|
461
|
+
return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)} %`;
|
|
329
462
|
}
|
|
330
|
-
function
|
|
331
|
-
|
|
463
|
+
function AutonomyHero({
|
|
464
|
+
rate,
|
|
465
|
+
compareRate,
|
|
466
|
+
caption
|
|
467
|
+
}) {
|
|
468
|
+
const points = ratePoints(rate, compareRate);
|
|
469
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { className: "border-primary/25 bg-gradient-to-br from-primary/10 via-card to-card", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-1 p-4", children: [
|
|
470
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-muted-foreground", children: [
|
|
471
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "inline-block size-2 rounded-full bg-primary" }),
|
|
472
|
+
"Taux d\u2019autonomie"
|
|
473
|
+
] }),
|
|
474
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-4xl font-semibold leading-tight tabular-nums text-foreground", children: formatRate(rate) }),
|
|
475
|
+
points !== null && // Direction is in the sign as well as the colour — `KpiCard`'s own
|
|
476
|
+
// rule, restated here because this card does not go through it.
|
|
477
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
478
|
+
"p",
|
|
479
|
+
{
|
|
480
|
+
className: `text-xs font-semibold tabular-nums ${points < 0 ? "text-status-blocked" : "text-status-success"}`,
|
|
481
|
+
children: [
|
|
482
|
+
POINTS_FORMAT.format(points),
|
|
483
|
+
" pts",
|
|
484
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
485
|
+
"vs ",
|
|
486
|
+
formatRate(compareRate)
|
|
487
|
+
] })
|
|
488
|
+
]
|
|
489
|
+
}
|
|
490
|
+
),
|
|
491
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption })
|
|
492
|
+
] }) });
|
|
332
493
|
}
|
|
333
|
-
|
|
334
|
-
|
|
494
|
+
var DASHBOARD_PRESETS = [
|
|
495
|
+
{ key: "last7", label: "7 derniers jours" },
|
|
496
|
+
{ key: "last30", label: "30 derniers jours" }
|
|
497
|
+
];
|
|
498
|
+
var WEEKLY_BUCKET_FROM_DAYS = 46;
|
|
499
|
+
var DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
500
|
+
var EPOCH_ISO = "1970-01-01T00:00:00.000Z";
|
|
501
|
+
function startOfDayIso(day) {
|
|
502
|
+
return day !== void 0 && DAY_PATTERN.test(day) ? `${day}T00:00:00.000Z` : EPOCH_ISO;
|
|
503
|
+
}
|
|
504
|
+
function endOfDayIso(day) {
|
|
505
|
+
return DAY_PATTERN.test(day) ? `${day}T23:59:59.999Z` : (/* @__PURE__ */ new Date()).toISOString();
|
|
506
|
+
}
|
|
507
|
+
function dayCount(bounds) {
|
|
508
|
+
const from = Date.parse(bounds.fromIso);
|
|
509
|
+
const to = Date.parse(bounds.toIso);
|
|
510
|
+
if (Number.isNaN(from) || Number.isNaN(to)) return 0;
|
|
511
|
+
return Math.max(1, Math.round((to - from) / 864e5));
|
|
512
|
+
}
|
|
513
|
+
function periodBoundsOf(value) {
|
|
514
|
+
const current = {
|
|
515
|
+
fromIso: startOfDayIso(value.range.from),
|
|
516
|
+
toIso: endOfDayIso(value.range.to)
|
|
517
|
+
};
|
|
518
|
+
const compare = value.compare === "none" ? void 0 : value.compareRange ?? uiSdk.comparisonRange(value.preset, value.range, value.compare);
|
|
519
|
+
const days = dayCount(current);
|
|
520
|
+
return {
|
|
521
|
+
current,
|
|
522
|
+
previous: compare === void 0 ? null : { fromIso: startOfDayIso(compare.from), toIso: endOfDayIso(compare.to) },
|
|
523
|
+
days,
|
|
524
|
+
interval: days >= WEEKLY_BUCKET_FROM_DAYS ? "week" : "day"
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function defaultPeriod(today = /* @__PURE__ */ new Date()) {
|
|
528
|
+
const to = today.toISOString().slice(0, 10);
|
|
529
|
+
const start = new Date(today);
|
|
530
|
+
start.setUTCDate(start.getUTCDate() - 29);
|
|
531
|
+
const range = { from: start.toISOString().slice(0, 10), to };
|
|
532
|
+
const compareRange = uiSdk.comparisonRange("last30", range, "previous_period");
|
|
533
|
+
return {
|
|
534
|
+
preset: "last30",
|
|
535
|
+
range,
|
|
536
|
+
compare: "previous_period",
|
|
537
|
+
...compareRange === void 0 ? {} : { compareRange }
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function sharePercent(value, total) {
|
|
541
|
+
return total > 0 ? `${Math.round(value / total * 100)} %` : null;
|
|
542
|
+
}
|
|
543
|
+
function StackedRow({
|
|
544
|
+
label,
|
|
545
|
+
segments,
|
|
546
|
+
total,
|
|
547
|
+
scale,
|
|
548
|
+
formatCount: formatCount2
|
|
549
|
+
}) {
|
|
550
|
+
const width = scale > 0 ? total / scale * 100 : 0;
|
|
551
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(6rem,9rem)_1fr_auto] items-center gap-3 text-xs", children: [
|
|
552
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-muted-foreground", title: label, children: label }),
|
|
553
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full overflow-hidden rounded-sm", style: { width: `${width}%` }, children: segments.filter((segment) => segment.value > 0).map((segment) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
554
|
+
"div",
|
|
555
|
+
{
|
|
556
|
+
role: "presentation",
|
|
557
|
+
title: `${segment.label} : ${formatCount2(segment.value)}${sharePercent(segment.value, total) === null ? "" : ` (${sharePercent(segment.value, total)})`}`,
|
|
558
|
+
style: {
|
|
559
|
+
width: `${segment.value / total * 100}%`,
|
|
560
|
+
backgroundColor: segment.color
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
segment.key
|
|
564
|
+
)) }) }),
|
|
565
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums text-muted-foreground", children: formatCount2(total) })
|
|
566
|
+
] });
|
|
567
|
+
}
|
|
568
|
+
function StackedLegend({ segments }) {
|
|
569
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: segments.map((segment) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
|
|
570
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
571
|
+
"span",
|
|
572
|
+
{
|
|
573
|
+
"aria-hidden": true,
|
|
574
|
+
className: "inline-block size-2 rounded-[2px]",
|
|
575
|
+
style: { backgroundColor: segment.color }
|
|
576
|
+
}
|
|
577
|
+
),
|
|
578
|
+
segment.label
|
|
579
|
+
] }, segment.key)) });
|
|
580
|
+
}
|
|
581
|
+
var OUTCOME_METRICS = [{ op: "count", as: "count" }];
|
|
582
|
+
var OUTCOME_GROUP_BY = ["status", "autoSendDecision"];
|
|
583
|
+
var CATEGORY_OUTCOME_GROUP_BY = ["categoryId", "status", "autoSendDecision"];
|
|
584
|
+
var CATEGORY_COLORS = {
|
|
585
|
+
auto: "var(--chart-1)",
|
|
586
|
+
human: "var(--chart-2)",
|
|
587
|
+
noReply: "var(--chart-4)",
|
|
588
|
+
undrafted: "var(--muted)"
|
|
589
|
+
};
|
|
590
|
+
var CATEGORY_LEGEND = [
|
|
591
|
+
{ key: "auto", label: "R\xE9ponse automatis\xE9e par l\u2019agent", color: CATEGORY_COLORS.auto },
|
|
592
|
+
{ key: "human", label: "Repris par un humain", color: CATEGORY_COLORS.human },
|
|
593
|
+
{ key: "noReply", label: "Sans r\xE9ponse n\xE9cessaire", color: CATEGORY_COLORS.noReply },
|
|
594
|
+
{ key: "undrafted", label: "Sans brouillon", color: CATEGORY_COLORS.undrafted }
|
|
595
|
+
];
|
|
596
|
+
function formatCount(value) {
|
|
597
|
+
return Number.isNaN(value) ? "\u2026" : value.toLocaleString("fr-FR");
|
|
598
|
+
}
|
|
599
|
+
function dayLabel(day) {
|
|
600
|
+
const parsed = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
|
|
601
|
+
return Number.isNaN(parsed.getTime()) ? day : parsed.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", timeZone: "UTC" });
|
|
335
602
|
}
|
|
336
603
|
function DashboardPage() {
|
|
337
604
|
const { appSlug } = uiSdk.useAppContext();
|
|
338
|
-
const [
|
|
339
|
-
const { settings
|
|
605
|
+
const [period, setPeriod] = react.useState(() => defaultPeriod());
|
|
606
|
+
const { settings } = uiSdk.useAppSettings();
|
|
340
607
|
const timezone = settings?.statsTimezone ?? "UTC";
|
|
341
|
-
const
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
608
|
+
const periodKey = JSON.stringify(period);
|
|
609
|
+
const bounds = react.useMemo(() => periodBoundsOf(JSON.parse(periodKey)), [periodKey]);
|
|
610
|
+
const currentFilter = { generatedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } };
|
|
611
|
+
const previousBounds = bounds.previous ?? bounds.current;
|
|
612
|
+
const {
|
|
613
|
+
rows: dailyRows,
|
|
614
|
+
isLoading: dailyLoading,
|
|
615
|
+
error: dailyError
|
|
616
|
+
} = useAggregate("generated-response", {
|
|
617
|
+
filter: currentFilter,
|
|
618
|
+
groupBy: OUTCOME_GROUP_BY,
|
|
619
|
+
bucket: { field: "generatedAt", interval: bounds.interval, tz: timezone },
|
|
620
|
+
metrics: OUTCOME_METRICS
|
|
351
621
|
});
|
|
352
|
-
const { rows:
|
|
353
|
-
filter: {
|
|
354
|
-
|
|
622
|
+
const { rows: previousRows, isLoading: previousLoading } = useAggregate("generated-response", {
|
|
623
|
+
filter: { generatedAt: { gte: previousBounds.fromIso, lte: previousBounds.toIso } },
|
|
624
|
+
groupBy: OUTCOME_GROUP_BY,
|
|
625
|
+
metrics: OUTCOME_METRICS
|
|
355
626
|
});
|
|
356
|
-
const {
|
|
357
|
-
|
|
627
|
+
const {
|
|
628
|
+
rows: categoryCounts,
|
|
629
|
+
isLoading: categoryLoading,
|
|
630
|
+
error: categoryError
|
|
631
|
+
} = useAggregate("triage-decision", {
|
|
632
|
+
filter: { decidedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } },
|
|
358
633
|
groupBy: ["categoryId"],
|
|
359
|
-
metrics:
|
|
634
|
+
metrics: OUTCOME_METRICS
|
|
360
635
|
});
|
|
361
|
-
const { rows:
|
|
362
|
-
filter:
|
|
363
|
-
|
|
364
|
-
metrics:
|
|
636
|
+
const { rows: categoryOutcomes } = useAggregate("generated-response", {
|
|
637
|
+
filter: currentFilter,
|
|
638
|
+
groupBy: CATEGORY_OUTCOME_GROUP_BY,
|
|
639
|
+
metrics: OUTCOME_METRICS
|
|
365
640
|
});
|
|
366
|
-
const { rows: dailyHeld, error: dailyHeldError } = useAggregate("generated-response", {
|
|
367
|
-
filter: { generatedAt: { gte: cutoffIso }, autoSendDecision: { eq: "hold" } },
|
|
368
|
-
bucket: { field: "generatedAt", interval: "day", tz: timezone },
|
|
369
|
-
metrics: [{ op: "count", as: "count" }]
|
|
370
|
-
});
|
|
371
|
-
const dailySeriesError = dailySentError !== void 0 || dailyHeldError !== void 0;
|
|
372
641
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
373
642
|
const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
} = useRecordList(
|
|
379
|
-
"triage-decision",
|
|
380
|
-
{ sort: [{ field: "decidedAt", direction: "desc" }], limit: RECENT_ACTIVITY_LIMIT },
|
|
381
|
-
toTriageDecision
|
|
643
|
+
const totals = react.useMemo(() => foldOutcomes(dailyRows), [dailyRows]);
|
|
644
|
+
const compareTotals = react.useMemo(
|
|
645
|
+
() => bounds.previous === null ? null : foldOutcomes(previousRows),
|
|
646
|
+
[bounds.previous, previousRows]
|
|
382
647
|
);
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
] }) }),
|
|
401
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-1 p-4", children: [
|
|
402
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Escalades" }),
|
|
403
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: escalatedLoading ? "\u2026" : escalatedError ? "Indisponible" : `${escalatedTotal} au total` })
|
|
404
|
-
] }) })
|
|
405
|
-
] }) })
|
|
406
|
-
] });
|
|
407
|
-
const columns = [
|
|
408
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
|
|
409
|
-
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
410
|
-
{
|
|
411
|
-
key: "escalated",
|
|
412
|
-
header: "Escalade",
|
|
413
|
-
cell: (row) => row.escalated ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Escalad\xE9" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Non escalad\xE9" })
|
|
414
|
-
},
|
|
415
|
-
{ key: "decidedAt", header: "Date", cell: (row) => formatDate(row.decidedAt) }
|
|
416
|
-
];
|
|
648
|
+
const daily = react.useMemo(() => {
|
|
649
|
+
const folded = foldDailyOutcomes(dailyRows);
|
|
650
|
+
return bounds.interval === "day" ? fillMissingDays(folded, bounds.current.fromIso, bounds.current.toIso) : folded;
|
|
651
|
+
}, [dailyRows, bounds]);
|
|
652
|
+
const rate = autonomyRate(totals);
|
|
653
|
+
const compareRate = compareTotals === null ? Number.NaN : autonomyRate(compareTotals);
|
|
654
|
+
const settled = settledCount(totals);
|
|
655
|
+
const signals = react.useMemo(() => dashboardSignals(totals, compareTotals), [totals, compareTotals]);
|
|
656
|
+
const reasons = react.useMemo(() => foldHumanReasons(dailyRows), [dailyRows]);
|
|
657
|
+
const categoryBars = react.useMemo(
|
|
658
|
+
() => foldCategoryOutcomes(categoryCounts, categoryOutcomes, categoryNames),
|
|
659
|
+
[categoryCounts, categoryOutcomes, categoryNames]
|
|
660
|
+
);
|
|
661
|
+
const categoryScale = categoryBars.reduce((max, bar) => Math.max(max, bar.total), 0);
|
|
662
|
+
const loading = dailyLoading || previousLoading;
|
|
663
|
+
const chartData = daily.map((point) => ({ ...point, jour: dayLabel(point.day) }));
|
|
664
|
+
const bucketWord = bounds.interval === "day" ? "jour" : "semaine";
|
|
417
665
|
return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
|
|
418
666
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
419
667
|
PageHeader,
|
|
420
668
|
{
|
|
421
669
|
title: "Tableau de bord",
|
|
422
|
-
description: "
|
|
423
|
-
actions: /* @__PURE__ */ jsxRuntime.
|
|
424
|
-
/* @__PURE__ */ jsxRuntime.
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
670
|
+
description: "Ce que l\u2019IA a r\xE9gl\xE9 seule sur la p\xE9riode, et ce qui est retomb\xE9 sur un humain.",
|
|
671
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
673
|
+
uiSdk.DateRangeCompare,
|
|
674
|
+
{
|
|
675
|
+
value: period,
|
|
676
|
+
onChange: setPeriod,
|
|
677
|
+
comparable: true,
|
|
678
|
+
presets: DASHBOARD_PRESETS,
|
|
679
|
+
align: "end"
|
|
680
|
+
}
|
|
681
|
+
),
|
|
431
682
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
|
|
432
|
-
] })
|
|
683
|
+
] })
|
|
433
684
|
}
|
|
434
685
|
),
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
686
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
"data-testid": "dashboard-kpis",
|
|
690
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-[1.3fr_1fr_1fr]",
|
|
691
|
+
children: [
|
|
692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
693
|
+
AutonomyHero,
|
|
694
|
+
{
|
|
695
|
+
rate: loading ? Number.NaN : rate,
|
|
696
|
+
compareRate,
|
|
697
|
+
caption: loading ? "Calcul en cours\u2026" : `${formatCount(totals.auto)} r\xE9gl\xE9es par l\u2019IA sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
|
|
698
|
+
}
|
|
699
|
+
),
|
|
700
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
701
|
+
uiSdk.KpiCard,
|
|
702
|
+
{
|
|
703
|
+
label: "R\xE9ponse automatis\xE9e par l\u2019agent",
|
|
704
|
+
value: loading ? Number.NaN : totals.auto,
|
|
705
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.auto },
|
|
706
|
+
formatValue: formatCount
|
|
707
|
+
}
|
|
708
|
+
),
|
|
709
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
710
|
+
uiSdk.KpiCard,
|
|
711
|
+
{
|
|
712
|
+
label: "Repris par un humain",
|
|
713
|
+
value: loading ? Number.NaN : totals.human,
|
|
714
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.human },
|
|
715
|
+
formatValue: formatCount,
|
|
716
|
+
lowerIsBetter: true
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [
|
|
723
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
724
|
+
uiSdk.KpiCard,
|
|
725
|
+
{
|
|
726
|
+
label: "Encore en cours",
|
|
727
|
+
value: loading ? Number.NaN : totals.inProgress,
|
|
728
|
+
formatValue: formatCount
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
732
|
+
uiSdk.KpiCard,
|
|
733
|
+
{
|
|
734
|
+
label: "Sans r\xE9ponse n\xE9cessaire",
|
|
735
|
+
value: loading ? Number.NaN : totals.noReplyNeeded,
|
|
736
|
+
formatValue: formatCount
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
] }),
|
|
740
|
+
/* @__PURE__ */ jsxRuntime.jsxs("details", { className: "text-xs leading-relaxed text-muted-foreground", children: [
|
|
741
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { className: "cursor-pointer select-none font-medium", children: "Comment le taux d\u2019autonomie est calcul\xE9" }),
|
|
742
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2", children: "Le taux d\u2019autonomie rapporte les r\xE9ponses envoy\xE9es par l\u2019IA \xE0 ces m\xEAmes r\xE9ponses plus celles qu\u2019un humain a reprises \u2014 bloqu\xE9es, escalad\xE9es, invalid\xE9es parce qu\u2019un agent avait d\xE9j\xE0 r\xE9pondu, ou expir\xE9es. \xB7 Une escalade est compt\xE9e UNE fois, du c\xF4t\xE9 humain : c\u2019est un motif de blocage, pas un camp de plus. \xB7 Les demandes encore en cours, celles sans r\xE9ponse n\xE9cessaire et les \xE9checs techniques sont hors du taux \u2014 les compter d\u2019un c\xF4t\xE9 ou de l\u2019autre le fausserait dans les deux sens. \xB7 Le d\xE9nominateur ne couvre que les demandes mises en file : un ticket escalad\xE9 avant toute g\xE9n\xE9ration n\u2019y figure pas." })
|
|
743
|
+
] }),
|
|
744
|
+
dailyError !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du calcul des chiffres cl\xE9s." }),
|
|
745
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
746
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
747
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardTitle, { className: "text-sm", children: [
|
|
748
|
+
"Automatique ou humain, ",
|
|
749
|
+
bucketWord,
|
|
750
|
+
" par ",
|
|
751
|
+
bucketWord
|
|
752
|
+
] }) }),
|
|
753
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: dailyError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
|
|
754
|
+
"Impossible de calculer l\u2019\xE9volution par ",
|
|
755
|
+
bucketWord,
|
|
756
|
+
"."
|
|
757
|
+
] }) : chartData.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune journ\xE9e mesur\xE9e sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
758
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-xs font-medium uppercase tracking-widest text-muted-foreground", children: "Part r\xE9gl\xE9e par l\u2019IA" }),
|
|
759
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
760
|
+
uiSdk.AreaChart,
|
|
761
|
+
{
|
|
762
|
+
data: chartData,
|
|
763
|
+
x: "jour",
|
|
764
|
+
series: [{ key: "rate", label: "Taux d\u2019autonomie" }],
|
|
765
|
+
formatValue: formatRate,
|
|
766
|
+
height: 150,
|
|
767
|
+
hideLegend: true
|
|
768
|
+
}
|
|
769
|
+
),
|
|
770
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 mt-4 text-xs font-medium uppercase tracking-widest text-muted-foreground", children: "Demandes r\xE9gl\xE9es, en volume" }),
|
|
771
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
772
|
+
uiSdk.StackedBarChart,
|
|
773
|
+
{
|
|
774
|
+
data: chartData,
|
|
775
|
+
x: "jour",
|
|
776
|
+
label: `Demandes r\xE9gl\xE9es par ${bucketWord}`,
|
|
777
|
+
series: [
|
|
778
|
+
{ key: "auto", label: "R\xE9gl\xE9 par l\u2019IA", colorIndex: 0 },
|
|
779
|
+
{ key: "human", label: "Repris par un humain", colorIndex: 1 }
|
|
780
|
+
],
|
|
781
|
+
formatValue: formatCount,
|
|
782
|
+
height: 150
|
|
783
|
+
}
|
|
784
|
+
),
|
|
785
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-3 text-xs leading-relaxed text-muted-foreground", children: [
|
|
786
|
+
"La courbe est la ",
|
|
787
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "part" }),
|
|
788
|
+
" r\xE9gl\xE9e sans personne ; les barres sont le",
|
|
789
|
+
" ",
|
|
790
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "volume" }),
|
|
791
|
+
" qu\u2019elle recouvre. Un ",
|
|
792
|
+
bucketWord,
|
|
793
|
+
" \xE0 100 % sur deux demandes n\u2019est pas la m\xEAme nouvelle qu\u2019un ",
|
|
794
|
+
bucketWord,
|
|
795
|
+
" \xE0 80 % sur deux cents."
|
|
796
|
+
] }),
|
|
797
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: [
|
|
798
|
+
"Un trou dans la courbe veut dire \xAB rien de r\xE9gl\xE9 ce ",
|
|
799
|
+
bucketWord,
|
|
800
|
+
"-l\xE0 \xBB, jamais \xAB 0 % \xBB : sans d\xE9nominateur, il n\u2019y a pas de taux \xE0 tracer."
|
|
801
|
+
] })
|
|
802
|
+
] }) })
|
|
440
803
|
] }),
|
|
441
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
804
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
805
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "R\xE9partition par cat\xE9gorie" }) }),
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { className: "space-y-3", children: categoryLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : categoryError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer la r\xE9partition par cat\xE9gorie." }) : categoryBars.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun volume calcul\xE9 pour l'instant sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
807
|
+
/* @__PURE__ */ jsxRuntime.jsx(StackedLegend, { segments: CATEGORY_LEGEND }),
|
|
808
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1.5", children: categoryBars.map((bar) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
809
|
+
StackedRow,
|
|
810
|
+
{
|
|
811
|
+
label: bar.label,
|
|
812
|
+
total: bar.total,
|
|
813
|
+
scale: categoryScale,
|
|
814
|
+
formatCount,
|
|
815
|
+
segments: [
|
|
816
|
+
{
|
|
817
|
+
key: "auto",
|
|
818
|
+
label: "R\xE9ponse automatis\xE9e par l\u2019agent",
|
|
819
|
+
value: bar.auto,
|
|
820
|
+
color: CATEGORY_COLORS.auto
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
key: "human",
|
|
824
|
+
label: "Repris par un humain",
|
|
825
|
+
value: bar.human,
|
|
826
|
+
color: CATEGORY_COLORS.human
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
key: "noReply",
|
|
830
|
+
label: "Sans r\xE9ponse n\xE9cessaire",
|
|
831
|
+
value: bar.noReply,
|
|
832
|
+
color: CATEGORY_COLORS.noReply
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
key: "undrafted",
|
|
836
|
+
label: "Sans brouillon",
|
|
837
|
+
value: bar.undrafted,
|
|
838
|
+
color: CATEGORY_COLORS.undrafted
|
|
839
|
+
}
|
|
840
|
+
]
|
|
841
|
+
},
|
|
842
|
+
bar.label
|
|
843
|
+
)) }),
|
|
844
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Ce qui arrive, par cat\xE9gorie \u2014 et qui l\u2019a trait\xE9. La longueur d\u2019une barre est le volume tri\xE9 sur la p\xE9riode ; les couleurs sont ce que ce volume est devenu. \xAB\xA0Sans brouillon\xA0\xBB couvre ce que le triage a vu sans qu\u2019une r\xE9ponse soit g\xE9n\xE9r\xE9e : escalade imm\xE9diate, conversation d\xE9j\xE0 close, ou traitement encore en cours." })
|
|
845
|
+
] }) })
|
|
846
|
+
] })
|
|
847
|
+
] }),
|
|
848
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
849
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "Pourquoi un humain a repris" }) }),
|
|
850
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { className: "space-y-3", children: loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : totals.human === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune reprise humaine sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
442
851
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
443
|
-
|
|
852
|
+
StackedRow,
|
|
444
853
|
{
|
|
445
|
-
label: "
|
|
446
|
-
|
|
447
|
-
|
|
854
|
+
label: "Motifs",
|
|
855
|
+
total: totals.human,
|
|
856
|
+
scale: totals.human,
|
|
857
|
+
formatCount,
|
|
858
|
+
segments: [
|
|
859
|
+
{
|
|
860
|
+
key: "blocked",
|
|
861
|
+
label: "Bloqu\xE9 avant envoi",
|
|
862
|
+
value: reasons.blocked,
|
|
863
|
+
color: "var(--chart-2)"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
key: "invalidated",
|
|
867
|
+
label: "Un agent avait d\xE9j\xE0 r\xE9pondu",
|
|
868
|
+
value: reasons.invalidated,
|
|
869
|
+
color: "var(--chart-3)"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
key: "expired",
|
|
873
|
+
label: "Brouillon expir\xE9",
|
|
874
|
+
value: reasons.expired,
|
|
875
|
+
color: "var(--chart-5)"
|
|
876
|
+
}
|
|
877
|
+
]
|
|
448
878
|
}
|
|
449
879
|
),
|
|
450
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 px-1 text-xs text-muted-foreground", children: "Part des r\xE9ponses g\xE9n\xE9r\xE9es sur la fen\xEAtre dont le statut est \xAB Envoy\xE9e \xBB." })
|
|
451
|
-
] }),
|
|
452
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
453
880
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
454
|
-
|
|
881
|
+
StackedLegend,
|
|
455
882
|
{
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-3 text-sm font-medium", children: "\xC9volution par jour" }),
|
|
473
|
-
dailySeriesError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer l'\xE9volution par jour." }) : dailySeries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune journ\xE9e mesur\xE9e sur cette fen\xEAtre." }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
474
|
-
uiSdk.StackedBarChart,
|
|
475
|
-
{
|
|
476
|
-
data: dailySeries,
|
|
477
|
-
x: "day",
|
|
478
|
-
label: "\xC9volution par jour",
|
|
479
|
-
series: [
|
|
480
|
-
{ key: "sent", label: "Envoy\xE9es", colorIndex: 0 },
|
|
481
|
-
{ key: "held", label: "Bloqu\xE9es", colorIndex: 1 }
|
|
883
|
+
segments: [
|
|
884
|
+
{
|
|
885
|
+
key: "blocked",
|
|
886
|
+
label: `Bloqu\xE9 avant envoi (${formatCount(reasons.blocked)})`,
|
|
887
|
+
color: "var(--chart-2)"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
key: "invalidated",
|
|
891
|
+
label: `Un agent avait d\xE9j\xE0 r\xE9pondu (${formatCount(reasons.invalidated)})`,
|
|
892
|
+
color: "var(--chart-3)"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
key: "expired",
|
|
896
|
+
label: `Brouillon expir\xE9 (${formatCount(reasons.expired)})`,
|
|
897
|
+
color: "var(--chart-5)"
|
|
898
|
+
}
|
|
482
899
|
]
|
|
483
900
|
}
|
|
484
|
-
)
|
|
901
|
+
),
|
|
902
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Les escalades sont dans \xAB\xA0bloqu\xE9\xA0\xBB : un ticket escalad\xE9 voit son brouillon retenu par le garde-fou, c\u2019est un motif de blocage et non un camp de plus. Le d\xE9tail ticket par ticket est sur la page Escalades." })
|
|
485
903
|
] }) })
|
|
486
904
|
] }),
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
/* @__PURE__ */ jsxRuntime.
|
|
490
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
491
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
492
|
-
] })
|
|
493
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
494
|
-
uiSdk.DataTable,
|
|
495
|
-
{
|
|
496
|
-
columns,
|
|
497
|
-
rows: recentActivity,
|
|
498
|
-
rowId: (row) => row.id,
|
|
499
|
-
manual: true,
|
|
500
|
-
loading: activityLoading,
|
|
501
|
-
error: activityError ? "Erreur lors du chargement de l\u2019activit\xE9 r\xE9cente." : void 0,
|
|
502
|
-
empty: "Aucune d\xE9cision de triage enregistr\xE9e pour l\u2019instant."
|
|
503
|
-
}
|
|
504
|
-
)
|
|
905
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
906
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "Signaux \xE0 surveiller" }) }),
|
|
907
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: signals.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rien de notable sur cette p\xE9riode \u2014 ou pas assez de demandes r\xE9gl\xE9es pour qu\u2019une comparaison veuille dire quelque chose." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: signals.map((signal) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
908
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: signal.level === "creuser" ? "warning" : "neutral", children: signal.level === "creuser" ? "\xC0 creuser" : "Info" }),
|
|
909
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm leading-relaxed", children: signal.text })
|
|
910
|
+
] }, signal.text)) }) })
|
|
505
911
|
] })
|
|
506
912
|
] });
|
|
507
913
|
}
|
|
@@ -1217,7 +1623,7 @@ function computePipelineStats(rows, timezone = "UTC") {
|
|
|
1217
1623
|
}
|
|
1218
1624
|
var STATS_PAGE_SIZE = 200;
|
|
1219
1625
|
var TABLE_PAGE_SIZE = 200;
|
|
1220
|
-
var
|
|
1626
|
+
var WINDOW_OPTIONS = [7, 14, 30];
|
|
1221
1627
|
var DECISION_OPTIONS = [
|
|
1222
1628
|
{ value: "", label: "Tous" },
|
|
1223
1629
|
{ value: "sent", label: "Envoy\xE9s auto" },
|
|
@@ -1245,7 +1651,7 @@ function buildTableFilter(decision, status) {
|
|
|
1245
1651
|
function countOrEllipsis(value) {
|
|
1246
1652
|
return Number.isNaN(value) ? "\u2026" : String(value);
|
|
1247
1653
|
}
|
|
1248
|
-
function
|
|
1654
|
+
function windowCutoffIso(days) {
|
|
1249
1655
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
1250
1656
|
}
|
|
1251
1657
|
function ConfidenceCell({ confidence }) {
|
|
@@ -1333,7 +1739,7 @@ function PipelinePage() {
|
|
|
1333
1739
|
const toast = uiSdk.useToast();
|
|
1334
1740
|
const [isTriaging, setIsTriaging] = react.useState(false);
|
|
1335
1741
|
const isTriagingRef = react.useRef(false);
|
|
1336
|
-
const [windowDays, setWindowDays] = react.useState(
|
|
1742
|
+
const [windowDays, setWindowDays] = react.useState(WINDOW_OPTIONS[0]);
|
|
1337
1743
|
const [decisionFilter, setDecisionFilter] = react.useState("");
|
|
1338
1744
|
const [statusFilter, setStatusFilter] = react.useState("");
|
|
1339
1745
|
const [verdictFilter, setVerdictFilter] = react.useState("");
|
|
@@ -1368,7 +1774,7 @@ function PipelinePage() {
|
|
|
1368
1774
|
const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
|
|
1369
1775
|
const agentNames = react.useMemo(() => toNameMap(agents), [agents]);
|
|
1370
1776
|
const windowedStatsRows = react.useMemo(() => {
|
|
1371
|
-
const cutoff =
|
|
1777
|
+
const cutoff = windowCutoffIso(windowDays);
|
|
1372
1778
|
return statsRows.filter((row) => row.generatedAt !== null && row.generatedAt >= cutoff);
|
|
1373
1779
|
}, [statsRows, windowDays]);
|
|
1374
1780
|
const stats = react.useMemo(
|
|
@@ -1463,7 +1869,7 @@ function PipelinePage() {
|
|
|
1463
1869
|
),
|
|
1464
1870
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1465
1871
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
|
|
1466
|
-
|
|
1872
|
+
WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
|
|
1467
1873
|
days,
|
|
1468
1874
|
" j"
|
|
1469
1875
|
] }, days))
|
|
@@ -5289,7 +5695,7 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
5289
5695
|
globalNotes: promptWarningNodes.length > 0 ? [{ ...PROMPT_403_NOTE, nodes: promptWarningNodes }] : []
|
|
5290
5696
|
};
|
|
5291
5697
|
}
|
|
5292
|
-
function
|
|
5698
|
+
function windowCutoffIso2(days, now = Date.now()) {
|
|
5293
5699
|
return new Date(now - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
5294
5700
|
}
|
|
5295
5701
|
function totalOf(rows) {
|
|
@@ -5303,7 +5709,7 @@ function totalOf(rows) {
|
|
|
5303
5709
|
return total;
|
|
5304
5710
|
}
|
|
5305
5711
|
function useGraphTraffic(windowDays) {
|
|
5306
|
-
const cutoffIso = react.useMemo(() =>
|
|
5712
|
+
const cutoffIso = react.useMemo(() => windowCutoffIso2(windowDays), [windowDays]);
|
|
5307
5713
|
const triaged = useAggregate("triage-decision", {
|
|
5308
5714
|
filter: { decidedAt: { gte: cutoffIso } },
|
|
5309
5715
|
metrics: [{ op: "count", as: "count" }]
|