Refine order code and calendar cards

This commit is contained in:
Ruslan Bakiev
2026-04-04 15:27:00 +07:00
parent 309d0e78db
commit e20565b4ae
6 changed files with 167 additions and 9 deletions

View File

@@ -0,0 +1,17 @@
export function extractOrderCodeShort(code?: string | null) {
const normalized = String(code ?? '').trim();
if (!normalized) {
return '0000';
}
const digits = normalized.replace(/\D/g, '');
if (digits.length >= 4) {
return digits.slice(-4);
}
return normalized.slice(-4).toUpperCase().padStart(4, '0');
}
export function formatOrderCode(code?: string | null) {
return `#${extractOrderCodeShort(code)}`;
}