refactor: move spa to frontend folder

This commit is contained in:
2025-10-27 12:32:38 +03:00
parent 617b5491a1
commit 5681ac592a
77 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
export function isNotEmpty(value) {
if (value === null || value === undefined) return false;
if (Array.isArray(value)) return value.length > 0;
if (typeof value === 'object') return Object.keys(value).length > 0;
if (typeof value === 'string') return value.trim() !== '';
return true; // для чисел, булевых и т.п.
}
export function formatPrice(raw) {
if (raw === null || raw === undefined) return '';
const str = String(raw).trim();
const match = str.match(/^([+-]?)(\d+(?:\.\d+)?)/);
if (!match) return '';
const sign = match[1] || '';
const num = parseFloat(match[2]);
if (isNaN(num) || num === 0) return '';
const formatted = Math.round(num)
.toString()
.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
return `${sign}${formatted}`;
}