feat(items): add server field and improve item management
refactor(ai): enhance item structure generation with schema validation feat(ai): add token usage tracking and cost calculation fix(ui): improve item card number formatting with locale support docs(items): add documentation for item value separation test(items): add tests for value field validation
This commit is contained in:
1 parent
dc169f9eba
commit
d3704602fd
22 files changed
+1317
-95
No files matched your search
@@ -446,3 +446,31 @@ export function validatePasswordRequirements(password: string): {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapeia o locale da aplicação (ex: "pt", "en") para um BCP 47 válido
|
||||
* para APIs de formatação (ex: "pt-BR", "en-US").
|
||||
*/
|
||||
export function resolveBCP47Locale(locale?: string): string {
|
||||
switch (locale) {
|
||||
case "pt":
|
||||
return "pt-BR";
|
||||
case "en":
|
||||
return "en-US";
|
||||
default:
|
||||
// Fallback consistente para evitar divergência SSR/cliente
|
||||
return "pt-BR";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formata números com locale consistente, evitando mismatch de hidratação
|
||||
* entre SSR e cliente.
|
||||
*/
|
||||
export function formatNumber(value: number, locale?: string): string {
|
||||
try {
|
||||
return value.toLocaleString(resolveBCP47Locale(locale));
|
||||
} catch {
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user