diff --git a/packages/composables/src/composables/getters/facetGetters.ts b/packages/composables/src/composables/getters/facetGetters.ts index 57a9c6b8..c119a138 100644 --- a/packages/composables/src/composables/getters/facetGetters.ts +++ b/packages/composables/src/composables/getters/facetGetters.ts @@ -27,20 +27,20 @@ const getGrouped = ( const data = []; searchData.data.attributes.forEach(item => { - const current = data.find(itemData => itemData.type === item.displayType); + const current = data.find(itemData => itemData.atributeName === item.attribute?.name); if (!current) { data.push({ id: String(item.attribute.id), label: item.attribute?.name, + atributeName: item.attribute?.name, type: item.displayType, count: 0, options: [] }); } - data.find(itemData => itemData.type === item.displayType).options.push({ - type: '', + data.find(itemData => itemData.atributeName === item.attribute?.name).options.push({ id: String(item.search), value: item.id, label: item.name, diff --git a/packages/composables/test/jest/__tests__/__mocks__/productAttributesFormated.ts b/packages/composables/test/jest/__tests__/__mocks__/productAttributesFormated.ts index c5c8647e..1ba6cf51 100644 --- a/packages/composables/test/jest/__tests__/__mocks__/productAttributesFormated.ts +++ b/packages/composables/test/jest/__tests__/__mocks__/productAttributesFormated.ts @@ -20,4 +20,300 @@ export const productVariantsFormatedForProduct = { ] }; -export const attributesFormatedForCategory = [{id: '4', label: 'Size', type: 'select', count: 0, options: [{type: '', id: '4-9', value: 9, label: '5', metadata: '4-9', htmlColor: null}, {type: '', id: '4-10', value: 10, label: '6', metadata: '4-10', htmlColor: null}, {type: '', id: '4-11', value: 11, label: '7', metadata: '4-11', htmlColor: null}, {type: '', id: '4-12', value: 12, label: '8', metadata: '4-12', htmlColor: null}, {type: '', id: '4-13', value: 13, label: '9', metadata: '4-13', htmlColor: null}, {type: '', id: '4-14', value: 14, label: '10', metadata: '4-14', htmlColor: null}, {type: '', id: '4-17', value: 17, label: '13', metadata: '4-17', htmlColor: null}, {type: '', id: '4-18', value: 18, label: '34', metadata: '4-18', htmlColor: null}, {type: '', id: '4-19', value: 19, label: '35', metadata: '4-19', htmlColor: null}, {type: '', id: '4-20', value: 20, label: '36', metadata: '4-20', htmlColor: null}, {type: '', id: '4-21', value: 21, label: '37', metadata: '4-21', htmlColor: null}, {type: '', id: '4-22', value: 22, label: '38', metadata: '4-22', htmlColor: null}, {type: '', id: '4-24', value: 24, label: '40', metadata: '4-24', htmlColor: null}, {type: '', id: '4-25', value: 25, label: '41', metadata: '4-25', htmlColor: null}, {type: '', id: '4-26', value: 26, label: '42', metadata: '4-26', htmlColor: null}, {type: '', id: '4-27', value: 27, label: '43', metadata: '4-27', htmlColor: null}, {type: '', id: '4-29', value: 29, label: '45', metadata: '4-29', htmlColor: null}, {type: '', id: '4-30', value: 30, label: '46', metadata: '4-30', htmlColor: null}, {type: '', id: '4-31', value: 31, label: '47', metadata: '4-31', htmlColor: null}, {type: '', id: '4-32', value: 32, label: '48', metadata: '4-32', htmlColor: null}, {type: '', id: '4-33', value: 33, label: '49', metadata: '4-33', htmlColor: null}, {type: '', id: '4-34', value: 34, label: '50', metadata: '4-34', htmlColor: null}, {type: '', id: '4-35', value: 35, label: '51', metadata: '4-35', htmlColor: null}, {type: '', id: '4-36', value: 36, label: '52', metadata: '4-36', htmlColor: null}]}, {id: '5', label: 'Material', type: 'radio', count: 0, options: [{type: '', id: '5-37', value: 37, label: 'Cotton', metadata: '5-37', htmlColor: null}, {type: '', id: '5-38', value: 38, label: 'Leather', metadata: '5-38', htmlColor: null}]}, {id: '6', label: 'Color', type: 'color', count: 0, options: [{type: '', id: '6-40', value: 40, label: 'Black', metadata: '6-40', htmlColor: '#000000'}, {type: '', id: '6-41', value: 41, label: 'Grey', metadata: '6-41', htmlColor: '#bfbfbf'}, {type: '', id: '6-43', value: 43, label: 'Red', metadata: '6-43', htmlColor: '#f40000'}, {type: '', id: '6-45', value: 45, label: 'Blue', metadata: '6-45', htmlColor: '#0c7af7'}, {type: '', id: '6-46', value: 46, label: 'Green', metadata: '6-46', htmlColor: '#14c00b'}, {type: '', id: '6-47', value: 47, label: 'Brown', metadata: '6-47', htmlColor: '#964B00'}, {type: '', id: '6-49', value: 49, label: 'Beige', metadata: '6-49', htmlColor: '#faecdc'}]}]; +export const attributesFormatedForCategory = + +[ + { + id: '4', + label: 'Size', + type: 'select', + count: 0, + atributeName: 'Size', + options: [ + { + + id: '4-9', + value: 9, + label: '5', + metadata: '4-9', + htmlColor: null + }, + { + + id: '4-10', + value: 10, + label: '6', + metadata: '4-10', + htmlColor: null + }, + { + + id: '4-11', + value: 11, + label: '7', + metadata: '4-11', + htmlColor: null + }, + { + + id: '4-12', + value: 12, + label: '8', + metadata: '4-12', + htmlColor: null + }, + { + + id: '4-13', + value: 13, + label: '9', + metadata: '4-13', + htmlColor: null + }, + { + + id: '4-14', + value: 14, + label: '10', + metadata: '4-14', + htmlColor: null + }, + { + + id: '4-17', + value: 17, + label: '13', + metadata: '4-17', + htmlColor: null + }, + { + + id: '4-18', + value: 18, + label: '34', + metadata: '4-18', + htmlColor: null + }, + { + + id: '4-19', + value: 19, + label: '35', + metadata: '4-19', + htmlColor: null + }, + { + + id: '4-20', + value: 20, + label: '36', + metadata: '4-20', + htmlColor: null + }, + { + + id: '4-21', + value: 21, + label: '37', + metadata: '4-21', + htmlColor: null + }, + { + + id: '4-22', + value: 22, + label: '38', + metadata: '4-22', + htmlColor: null + }, + { + + id: '4-24', + value: 24, + label: '40', + metadata: '4-24', + htmlColor: null + }, + { + + id: '4-25', + value: 25, + label: '41', + metadata: '4-25', + htmlColor: null + }, + { + + id: '4-26', + value: 26, + label: '42', + metadata: '4-26', + htmlColor: null + }, + { + + id: '4-27', + value: 27, + label: '43', + metadata: '4-27', + htmlColor: null + }, + { + + id: '4-29', + value: 29, + label: '45', + metadata: '4-29', + htmlColor: null + }, + { + + id: '4-30', + value: 30, + label: '46', + metadata: '4-30', + htmlColor: null + }, + { + + id: '4-31', + value: 31, + label: '47', + metadata: '4-31', + htmlColor: null + }, + { + + id: '4-32', + value: 32, + label: '48', + metadata: '4-32', + htmlColor: null + }, + { + + id: '4-33', + value: 33, + label: '49', + metadata: '4-33', + htmlColor: null + }, + { + + id: '4-34', + value: 34, + label: '50', + metadata: '4-34', + htmlColor: null + }, + { + + id: '4-35', + value: 35, + label: '51', + metadata: '4-35', + htmlColor: null + }, + { + + id: '4-36', + value: 36, + label: '52', + metadata: '4-36', + htmlColor: null + } + ] + }, + { + id: '5', + label: 'Material', + type: 'radio', + count: 0, + atributeName: 'Material', + options: [ + { + + id: '5-37', + value: 37, + label: 'Cotton', + metadata: '5-37', + htmlColor: null + }, + { + + id: '5-38', + value: 38, + label: 'Leather', + metadata: '5-38', + htmlColor: null + } + ] + }, + { + id: '6', + label: 'Color', + type: 'color', + count: 0, + atributeName: 'Color', + options: [ + { + + id: '6-40', + value: 40, + label: 'Black', + metadata: '6-40', + htmlColor: '#000000' + }, + { + + id: '6-41', + value: 41, + label: 'Grey', + metadata: '6-41', + htmlColor: '#bfbfbf' + }, + { + + id: '6-43', + value: 43, + label: 'Red', + metadata: '6-43', + htmlColor: '#f40000' + }, + { + + id: '6-45', + value: 45, + label: 'Blue', + metadata: '6-45', + htmlColor: '#0c7af7' + }, + { + + id: '6-46', + value: 46, + label: 'Green', + metadata: '6-46', + htmlColor: '#14c00b' + }, + { + + id: '6-47', + value: 47, + label: 'Brown', + metadata: '6-47', + htmlColor: '#964B00' + }, + { + + id: '6-49', + value: 49, + label: 'Beige', + metadata: '6-49', + htmlColor: '#faecdc' + } + ] + } +] + +;