Format product color labels
This commit is contained in:
@@ -24,3 +24,18 @@ export const formatDisplayName = (value: string) => {
|
||||
})
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
export const formatColorLabel = (value: string) => {
|
||||
const normalized = String(value || '').replace(/\s+/g, ' ').trim();
|
||||
if (!normalized) return '';
|
||||
if (normalized.toLocaleLowerCase('pt-BR') === 'sem cor') return 'Sem cor';
|
||||
|
||||
return normalized
|
||||
.toLocaleLowerCase('pt-BR')
|
||||
.split(' ')
|
||||
.map((word, index) => {
|
||||
if (index > 0 && SMALL_WORDS.has(word)) return word;
|
||||
return word.charAt(0).toLocaleUpperCase('pt-BR') + word.slice(1);
|
||||
})
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user