feat(part-models): detail page with fleet insights
Adds /part-models/:id mirroring host/part detail pattern: KPIs for units, spend, avg price, failure counts, and FMs implicating the model, a state-breakdown bar chart, and the parts-of-this-model table. New GET /part-models/:id/insights aggregates via part.groupBy + aggregate and repair/fm counts. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -18,3 +18,4 @@ export * from './webhooks.js';
|
||||
export * from './saved-views.js';
|
||||
export * from './csv-imports.js';
|
||||
export * from './analytics.js';
|
||||
export * from './part-model-insights.js';
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { z } from 'zod';
|
||||
import { PartState } from './enums.js';
|
||||
|
||||
export interface PartModelStateCount {
|
||||
state: z.infer<typeof PartState>;
|
||||
count: number;
|
||||
totalPrice: number;
|
||||
}
|
||||
|
||||
export interface PartModelPriceStats {
|
||||
total: number;
|
||||
average: number;
|
||||
min: number | null;
|
||||
max: number | null;
|
||||
countWithPrice: number;
|
||||
}
|
||||
|
||||
export interface PartModelFailureStats {
|
||||
repairs: number;
|
||||
distinctFailedParts: number;
|
||||
fmsImplicating: number;
|
||||
}
|
||||
|
||||
export interface PartModelInsights {
|
||||
totalParts: number;
|
||||
byState: PartModelStateCount[];
|
||||
priceStats: PartModelPriceStats;
|
||||
failures: PartModelFailureStats;
|
||||
}
|
||||
Reference in New Issue
Block a user