This commit is contained in:
Bastien COIGNOUX
2026-05-04 08:28:32 +02:00
parent 7f94f83940
commit 695d4e76d0
46 changed files with 13390 additions and 251 deletions

8
app/utils/format.ts Normal file
View File

@ -0,0 +1,8 @@
export function formatEUR(value: number | null | undefined): string {
if (value == null || Number.isNaN(value)) return '—';
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(value);
}
export function roundMoney(n: number): number {
return Math.round(n * 100) / 100;
}

View File

@ -0,0 +1,12 @@
import { ClientResponseError } from 'pocketbase';
export function formatPocketBaseError(e: unknown): string {
if (e instanceof ClientResponseError) {
const msg = e.response?.message;
if (typeof msg === 'string') return msg;
if (Array.isArray(msg)) return msg.join(', ');
if (e.message) return e.message;
}
if (e instanceof Error) return e.message;
return 'Une erreur est survenue.';
}