Improve UI

This commit is contained in:
Urtzi Alfaro
2025-12-30 14:40:20 +01:00
parent e494ea8635
commit c07df124fb
71 changed files with 647 additions and 265 deletions

View File

@@ -24,6 +24,7 @@ import type { InventoryDashboardSummary } from '../types/inventory';
import { useSalesAnalytics } from './sales';
import { useProcurementDashboard } from './procurement';
import { useOrdersDashboard } from './orders';
import { useTenantCurrency } from '../../hooks/useTenantCurrency';
// ============================================================================
// Helper Functions
@@ -355,6 +356,7 @@ export const useDepartmentPerformance = (tenantId: string, period: TimePeriod =
const { data: inventory, isLoading: inventoryLoading } = useInventoryPerformance(tenantId);
const { data: sales, isLoading: salesLoading } = useSalesPerformance(tenantId, period);
const { data: procurement, isLoading: procurementLoading } = useProcurementPerformance(tenantId);
const { currencySymbol } = useTenantCurrency();
// Extract primitive values before useMemo to prevent unnecessary recalculations
const productionEfficiency = production?.efficiency || 0;
@@ -408,7 +410,7 @@ export const useDepartmentPerformance = (tenantId: string, period: TimePeriod =
primary_metric: {
label: 'Ingresos totales',
value: salesTotalRevenue,
unit: '€',
unit: currencySymbol,
},
secondary_metric: {
label: 'Transacciones',
@@ -418,7 +420,7 @@ export const useDepartmentPerformance = (tenantId: string, period: TimePeriod =
tertiary_metric: {
label: 'Valor promedio',
value: salesAvgTransactionValue,
unit: '€',
unit: currencySymbol,
},
},
},

View File

@@ -16,6 +16,8 @@
*/
import { apiClient } from '../client';
import { useTenantStore } from '../../stores/tenant.store';
import { getTenantCurrencySymbol } from '../../hooks/useTenantCurrency';
export interface AIInsight {
id: string;
@@ -380,11 +382,12 @@ export class AIInsightsService {
const value = insight.impact_value;
const unit = insight.impact_unit || 'units';
const currencySymbol = getTenantCurrencySymbol(useTenantStore.getState().currentTenant?.currency);
if (unit === 'euros_per_year' || unit === 'eur') {
return `${value.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 0 })}/year`;
return `${currencySymbol}${value.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 0 })}/year`;
} else if (unit === 'euros') {
return `${value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
return `${currencySymbol}${value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
} else if (unit === 'percentage' || unit === 'percentage_points') {
return `${value.toFixed(1)}%`;
} else if (unit === 'units') {

View File

@@ -41,6 +41,10 @@ export interface TenantUpdate {
phone?: string | null;
business_type?: string | null;
business_model?: string | null;
// Regional/Localization settings
currency?: string | null; // Currency code (EUR, USD, GBP)
timezone?: string | null;
language?: string | null;
}
/**
@@ -130,6 +134,11 @@ export interface TenantResponse {
owner_id: string; // ✅ REQUIRED field
created_at: string; // ISO datetime string
// Regional/Localization settings
currency?: string | null; // Default: 'EUR' - Currency code (EUR, USD, GBP)
timezone?: string | null; // Default: 'Europe/Madrid'
language?: string | null; // Default: 'es'
// Backward compatibility
/** @deprecated Use subscription_plan instead */
subscription_tier?: string;