Files
evidencija-rezija/web-app/app/lib/formatStrings.ts
Knee Cola 57dcebd640 refactor: convert repository to monorepo with npm workspaces
Restructured the repository into a monorepo to better organize application code
and maintenance scripts.

## Workspace Structure
- web-app: Next.js application (all app code moved from root)
- housekeeping: Database backup and maintenance scripts

## Key Changes
- Moved all application code to web-app/ using git mv
- Moved database scripts to housekeeping/ workspace
- Updated Dockerfile for monorepo build process
- Updated docker-compose files (volume paths: ./web-app/etc/hosts/)
- Updated .gitignore for workspace-level node_modules
- Updated documentation (README.md, CLAUDE.md, CHANGELOG.md)

## Migration Impact
- Root package.json now manages workspaces
- Build commands delegate to web-app workspace
- All file history preserved via git mv
- Docker build process updated for workspace structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-25 12:13:04 +01:00

43 lines
1.4 KiB
TypeScript

export const formatCurrency = (amount: number, currencyCode?: string | null) => {
// format number with 2 decimal places and a thousand separator
// amount is in cents
const amountInUnits = amount / 100;
// Use Intl.NumberFormat for proper currency formatting
try {
return new Intl.NumberFormat('hr-HR', {
style: 'currency',
currency: currencyCode ?? "EUR",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(amountInUnits);
} catch (e) {
// Fallback if invalid currency code
console.error(`Invalid currency code: ${currencyCode}`, e);
}
}
/**
* Formats an IBAN for display with proper spacing
* Format: XX12 XXXX XXXX XXXX XXXX XX
* First group: 2 letters (country) + 2 digits (check) = 4 chars
* Following groups: 4 characters each
* Last group: can be less than 4 characters
* @param iban - IBAN string without spaces
* @returns Formatted IBAN with spaces
*/
export const formatIban = (iban: string | null | undefined): string => {
if (!iban) return "";
// Remove any existing spaces
const cleaned = iban.replace(/\s/g, '');
// Split into groups: first 4 chars, then groups of 4
const groups: string[] = [];
for (let i = 0; i < cleaned.length; i += 4) {
groups.push(cleaned.slice(i, i + 4));
}
return groups.join(' ');
}