Categories in working!

This commit is contained in:
2022-10-14 14:39:34 +03:00
parent c67ddb75cb
commit 3d47a8fd55
3 changed files with 104 additions and 118 deletions

View File

@ -59,3 +59,24 @@ export function checkItemStruct(item) {
return item.hasOwnProperty('id') && item.hasOwnProperty('title') && item.hasOwnProperty('value');
}
export function getFormatItem(dataItem, index) {
const random = Math.random().toString(36).substring(2, 10);
let item = {};
if (checkItemStruct(dataItem)) {
item = {
id: dataItem.id,
title: dataItem.title,
value: index,
};
} else {
item = {
id: random,
title: dataItem,
value: index,
};
}
return item;
}