demo seed change 4
This commit is contained in:
@@ -122,6 +122,7 @@ export function useDashboardData(tenantId: string) {
|
||||
|
||||
// Get reasoning data from multiple possible locations
|
||||
const reasoningData = alert.event_metadata?.reasoning_data ||
|
||||
alert.metadata?.reasoning_data ||
|
||||
alert.ai_reasoning_details ||
|
||||
alert.reasoning_data ||
|
||||
alert.ai_reasoning ||
|
||||
@@ -150,8 +151,9 @@ export function useDashboardData(tenantId: string) {
|
||||
return {
|
||||
...po,
|
||||
supplier_name: supplierName, // Enrich with actual supplier name
|
||||
reasoning_data: reasoningInfo?.reasoning_data,
|
||||
ai_reasoning_summary: reasoningInfo?.ai_reasoning_summary,
|
||||
// Prioritize reasoning_data from PO itself, then fall back to alert
|
||||
reasoning_data: po.reasoning_data || reasoningInfo?.reasoning_data,
|
||||
ai_reasoning_summary: po.ai_reasoning_summary || reasoningInfo?.ai_reasoning_summary,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ export interface PurchaseOrderSummary {
|
||||
total_amount: string; // Decimal as string
|
||||
currency: string;
|
||||
created_at: string;
|
||||
reasoning_data?: any; // AI reasoning data for dashboard display
|
||||
ai_reasoning_summary?: string; // Human-readable summary
|
||||
}
|
||||
|
||||
export interface PurchaseOrderDetail extends PurchaseOrderSummary {
|
||||
|
||||
@@ -138,6 +138,58 @@ export function PendingPurchasesBlock({
|
||||
});
|
||||
}
|
||||
|
||||
// Handle production requirement reasoning
|
||||
if (reasoningData.type === 'production_requirement') {
|
||||
const params = reasoningData.parameters || {};
|
||||
const productNames = params.product_names || [];
|
||||
const productsStr = productNames.length > 0 ? productNames.join(', ') : 'products';
|
||||
|
||||
return t('dashboard:new_dashboard.pending_purchases.reasoning.production_requirement', {
|
||||
products: productsStr,
|
||||
batches: params.production_batches || params.batches_required || 0,
|
||||
days: params.days_until_required || 0,
|
||||
});
|
||||
}
|
||||
|
||||
// Handle safety stock replenishment reasoning
|
||||
if (reasoningData.type === 'safety_stock_replenishment') {
|
||||
const params = reasoningData.parameters || {};
|
||||
return t('dashboard:new_dashboard.pending_purchases.reasoning.safety_stock', {
|
||||
count: params.product_count || 0,
|
||||
current: params.current_safety_stock || 0,
|
||||
target: params.target_safety_stock || 0,
|
||||
});
|
||||
}
|
||||
|
||||
// Handle supplier contract reasoning
|
||||
if (reasoningData.type === 'supplier_contract') {
|
||||
const params = reasoningData.parameters || {};
|
||||
return t('dashboard:new_dashboard.pending_purchases.reasoning.supplier_contract', {
|
||||
supplier: params.supplier_name || 'supplier',
|
||||
products: params.product_categories?.join(', ') || 'products',
|
||||
});
|
||||
}
|
||||
|
||||
// Handle seasonal demand reasoning
|
||||
if (reasoningData.type === 'seasonal_demand') {
|
||||
const params = reasoningData.parameters || {};
|
||||
return t('dashboard:new_dashboard.pending_purchases.reasoning.seasonal_demand', {
|
||||
season: params.season || 'season',
|
||||
increase: params.expected_demand_increase_pct || 0,
|
||||
products: params.product_names?.join(', ') || 'products',
|
||||
});
|
||||
}
|
||||
|
||||
// Handle forecast demand reasoning
|
||||
if (reasoningData.type === 'forecast_demand') {
|
||||
const params = reasoningData.parameters || {};
|
||||
return t('dashboard:new_dashboard.pending_purchases.reasoning.forecast_demand', {
|
||||
product: params.product_name || 'product',
|
||||
confidence: params.confidence_score ? Math.round(params.confidence_score * 100) : 0,
|
||||
period: params.forecast_period_days || 0,
|
||||
});
|
||||
}
|
||||
|
||||
if (reasoningData.summary) return reasoningData.summary;
|
||||
|
||||
// Fallback to ai_reasoning_summary if structured data doesn't have a matching type
|
||||
|
||||
@@ -458,7 +458,12 @@
|
||||
"reasoning": {
|
||||
"low_stock": "{ingredient} will run out in {days, plural, =0 {less than a day} one {# day} other {# days}}",
|
||||
"low_stock_detailed": "{count, plural, one {# critical ingredient} other {# critical ingredients}} at risk: {products}. Earliest depletion in {days, plural, =0 {<1 day} one {1 day} other {# days}}, affecting {batches, plural, one {# batch} other {# batches}}. Potential loss: €{loss}",
|
||||
"demand_forecast": "Demand for {product} is expected to increase by {increase}%"
|
||||
"demand_forecast": "Demand for {product} is expected to increase by {increase}%",
|
||||
"production_requirement": "{products} needed for {batches, plural, one {# batch} other {# batches}} of production in {days, plural, =0 {less than a day} one {# day} other {# days}}",
|
||||
"safety_stock": "Safety stock replenishment: {count, plural, one {# product} other {# products}} (current: {current}, target: {target})",
|
||||
"supplier_contract": "Contract with {supplier} for {products}",
|
||||
"seasonal_demand": "Seasonal increase of {increase}% in {products} for {season}",
|
||||
"forecast_demand": "Forecasted demand for {product} with {confidence}% confidence for next {period, plural, one {# day} other {# days}}"
|
||||
}
|
||||
},
|
||||
"pending_deliveries": {
|
||||
|
||||
@@ -507,7 +507,12 @@
|
||||
"reasoning": {
|
||||
"low_stock": "{ingredient} se agotará en {days, plural, =0 {menos de un día} one {# día} other {# días}}",
|
||||
"low_stock_detailed": "{count, plural, one {# ingrediente crítico} other {# ingredientes críticos}} en riesgo: {products}. Agotamiento más temprano en {days, plural, =0 {<1 día} one {1 día} other {# días}}, afectando {batches, plural, one {# lote} other {# lotes}}. Pérdida potencial: €{loss}",
|
||||
"demand_forecast": "Se espera que la demanda de {product} aumente un {increase}%"
|
||||
"demand_forecast": "Se espera que la demanda de {product} aumente un {increase}%",
|
||||
"production_requirement": "Se necesitan {products} para {batches, plural, one {# lote} other {# lotes}} de producción en {days, plural, =0 {menos de un día} one {# día} other {# días}}",
|
||||
"safety_stock": "Reabastecimiento de stock de seguridad: {count, plural, one {# producto} other {# productos}} (actual: {current}, objetivo: {target})",
|
||||
"supplier_contract": "Contrato con {supplier} para {products}",
|
||||
"seasonal_demand": "Aumento estacional del {increase}% en {products} para {season}",
|
||||
"forecast_demand": "Demanda prevista de {product} con {confidence}% de confianza para los próximos {period, plural, one {# día} other {# días}}"
|
||||
}
|
||||
},
|
||||
"pending_deliveries": {
|
||||
|
||||
Reference in New Issue
Block a user