deep subcategory solution

This commit is contained in:
egradanin
2019-01-16 21:00:14 +01:00
parent ae446d5333
commit 2945ca8b70
7 changed files with 75 additions and 73 deletions

View File

@@ -6,10 +6,16 @@ const mapOptionToLink = (options, option) =>
}&`
: "";
export const createOlxLink = (category, subcategory, options) =>
subcategory.value
export const createOlxLink = (category, subcategory, options) => {
const deepSubCategory =
Boolean(Object.keys(subcategory).length) &&
subcategory[
Object.keys(subcategory).reduce((max, key) => (max < key ? key : max))
];
return deepSubCategory
? Object.keys(options).reduce(
(link, option) => link + mapOptionToLink(options, option),
`kategorija=${subcategory.value}&`
`kategorija=${deepSubCategory.value}&`
)
: "";
};