Files
emilandClaude Sonnet 4.6 50b3c4198a feat: initial commit — backend API + student cabinet frontend
- Go backend: auth (JWT), points earn/spend, QR token generation,
  partners, admin grant/stats endpoints with chi router
- Next.js 14 frontend: login, student dashboard, transaction history,
  QR display, partners list
- PostgreSQL migrations (4 tables), Redis cache, Docker Compose
- CORS middleware, role-based route protection, Zustand auth store

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 10:03:27 +03:00

33 lines
1.0 KiB
TypeScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Utility helpers for formatting numbers and dates throughout the UI.
/**
* Formats a point balance for display: 1234 → "1 234 pts"
* Uses the Russian locale so thousands are separated by a space.
*/
export function formatPoints(n: number): string {
return `${new Intl.NumberFormat('ru-RU').format(n)} pts`;
}
/**
* Formats a transaction amount with a sign prefix.
* Positive amounts use a "+" prefix; negative amounts use the Unicode minus sign "".
* Example: 50 → "+50", -30 → "30"
*/
export function formatTransactionAmount(amount: number): string {
if (amount >= 0) return `+${amount}`;
return `${Math.abs(amount)}`; // U+2212 MINUS SIGN, visually distinct from hyphen
}
/**
* Formats a UTC ISO timestamp to a compact Russian date+time string.
* Example: "2024-04-28T14:32:00Z" → "28 апр., 14:32"
*/
export function formatDate(iso: string): string {
return new Intl.DateTimeFormat('ru-RU', {
day: 'numeric',
month: 'short',
hour: '2-digit',
minute: '2-digit',
}).format(new Date(iso));
}