added mock fetched tags to tagHandler

This commit is contained in:
mushka 2022-07-22 18:14:03 +03:00
parent f24f2c6bee
commit 0bbf615c8b

View File

@ -2,23 +2,23 @@ class TagHandler {
constructor(tags, setTags) {
this.tags = tags;
this.setTags = setTags;
this.fetchedTags = [
"Figma",
"Portal",
"Design",
"Images",
"Fi",
"Fa",
"Fo",
"Fam",
"Fim",
];
}
createRandomTagId() {
return "_" + Math.random().toString(36).substr(2, 9);
}
addDefaultTag(name) {
this.setTags([
{
id: this.createRandomTagId(),
name,
isDefault: true,
},
...this.tags,
]);
}
refreshDefaultTag(name) {
let newTags = [...this.tags].filter((tag) => !tag.isDefault);
newTags.unshift({
@ -31,9 +31,13 @@ class TagHandler {
}
addTag(name) {
this.setTags(
this.tags.push({ id: this.createRandomTagId(), name, isDefault: false })
);
let newTags = [...this.tags];
newTags.push({
id: this.createRandomTagId(),
name,
});
this.setTags(newTags);
}
deleteTag(id) {