Refine order code and calendar cards
This commit is contained in:
17
app/composables/useOrderCodePresentation.ts
Normal file
17
app/composables/useOrderCodePresentation.ts
Normal 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)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user