Skip to content

Commit 60ef569

Browse files
chore(product-to-ecomplus): test colors in importation
1 parent b8d1ca5 commit 60ef569

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

functions/lib/integration/parsers/product-to-ecomplus.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,76 @@ const removeAccents = str => str.replace(/áàãâÁÀÃÂ/g, 'a')
99
.replace(/úÚ/g, 'u')
1010
.replace(/çÇ/g, 'c')
1111

12+
const hexaColors = color => {
13+
const lowerCaseColor = removeAccents(color.toLowerCase());
14+
15+
switch (lowerCaseColor) {
16+
case 'azulclaro':
17+
return '#add8e6';
18+
case 'branco':
19+
case 'branca':
20+
return '#ffffff';
21+
case 'cinza':
22+
return '#808080';
23+
case 'vermelho':
24+
case 'vermelha':
25+
return '#ff0000';
26+
case 'amarelo':
27+
case 'amarela':
28+
return '#ffff00';
29+
case 'verde':
30+
return '#008000';
31+
case 'preto':
32+
case 'preta':
33+
return '#000000';
34+
case 'azul':
35+
return '#0000ff';
36+
case 'petroleo':
37+
return '#006666';
38+
case 'verde limao':
39+
return '#32cd32';
40+
case 'rosa':
41+
case 'pink':
42+
return '#ffc0cb';
43+
case 'roxo':
44+
return '#800080';
45+
case 'laranja':
46+
case 'laranjao':
47+
return '#ffa500';
48+
case 'marrom':
49+
return '#a52a2a';
50+
case 'areia':
51+
return '#f0e68c';
52+
case 'vinho':
53+
case 'vinha':
54+
return '#800000';
55+
case 'ciano':
56+
return '#00ffff';
57+
case 'prata':
58+
return '#c0c0c0';
59+
case 'grafite':
60+
return '#808080';
61+
case 'magento':
62+
return '#ff00ff';
63+
case 'dourado':
64+
return '#ffd700';
65+
case 'turquesa':
66+
return '#40e0d0';
67+
case 'chocolatebranco':
68+
return '#d2691e';
69+
case 'verde oliva':
70+
return '#6b8e23';
71+
case 'caqui':
72+
return '#f0e68c';
73+
case 'pessego':
74+
return '#ffe5b4';
75+
case 'indigo':
76+
return '#4b0082';
77+
default:
78+
return '#ffffff'; // White (default)
79+
}
80+
};
81+
1282
const tryImageUpload = (storeId, auth, originImgUrl, product) => new Promise(resolve => {
1383
axios.get(originImgUrl, {
1484
responseType: 'arraybuffer'
@@ -188,6 +258,8 @@ module.exports = (blingProduct, variations, storeId, auth, isNew = true, appData
188258
specTexts.push(text)
189259
if (gridId !== 'colors') {
190260
spec.value = removeAccents(text.toLowerCase()).substring(0, 100)
261+
} else if (gridId === 'colors') {
262+
spec.value = hexaColors(text)
191263
}
192264
if (!specifications[gridId]) {
193265
specifications[gridId] = [spec]

0 commit comments

Comments
 (0)