feat(frontend): add react spa with wishlist flows and public profile

This commit is contained in:
Anton
2026-04-23 16:05:27 +03:00
parent 5f6a551b6c
commit 00f01611ed
44 changed files with 2166 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
export function formatPrice(price: string | null | undefined, currency: string): string | null {
if (!price) return null;
const n = Number(price);
if (Number.isNaN(n)) return `${price} ${currency}`;
try {
return new Intl.NumberFormat(undefined, {
style: 'currency',
currency,
maximumFractionDigits: 2,
}).format(n);
} catch {
return `${n.toLocaleString()} ${currency}`;
}
}
export function formatDate(iso: string | Date): string {
const d = typeof iso === 'string' ? new Date(iso) : iso;
return d.toLocaleDateString(undefined, { day: 'numeric', month: 'short', year: 'numeric' });
}
export function daysLeftUntil(iso: string | Date, retentionDays: number): number {
const d = typeof iso === 'string' ? new Date(iso) : iso;
const expires = d.getTime() + retentionDays * 24 * 60 * 60 * 1000;
return Math.max(0, Math.ceil((expires - Date.now()) / (24 * 60 * 60 * 1000)));
}