filteredArray() {
return this.array
.filter((el) => {
if (this.search.length === 0) {
return true;
}
return (
el?.name?.toLowerCase().includes(this.search) ||
el?.surname?.toLowerCase().includes(this.search)
);
})
.filter((el) => {
if (this.salary == null) {
return true;
}
return el.salary === this.salary;
})
.filter((el) => {
if (this.quality == null) {
return true;
}
return el.quality === this.quality;
})
.filter((el) => {
if (this.rating == null) {
return true;
}
return el.rating === this.rating && el.mode !== MODES.HIGH;
})
.filter(({ workers, workersIds }) => {
if (this.body == null) {
return true;
}
return this.body === Bodys.CHECKED
? workers.some(({ checked }, index) =>
index <= workersIds.length - 1 ? checked === false : false
)
: workers.every(({ checked }, index) =>
index <= workersIds.length - 1 ? checked === true : true
);
})
.sort((a, b) => {
if (a?.name?.toLowerCase() > b?.name?.toLowerCase()) {
return isDesc ? -1 : 1;
}
if (a?.name?.toLowerCase() < b?.name?.toLowerCase()) {
return isDesc ? 1 : -1;
}
return 0;
});
},
filteredArray() {
return this.array
.filter((el) => {
return (!this.search.length ? true : (el?.name?.toLowerCase().includes(this.search) ||
el?.surname?.toLowerCase().includes(this.search))) &&
(this.salary === null ? true : el.salary === this.salary) &&
(this.quality === null ? true : el.quality === this.quality) &&
(this.rating === null ? true : el.rating === this.rating && el.mode !== MODES.HIGH) &&
(this.body === null ? true : (this.body === Bodys.CHECKED ? el.workers.some(({ checked }, index) =>
index <= el.workersIds.length - 1 ? !checked : false
)
: el.workers.every(({ checked }, index) =>
index <= el.workersIds.length - 1 ? checked : true
)) )
}).sort((a, b) => {
if (a?.name?.toLowerCase() > b?.name?.toLowerCase()) {
return isDesc ? -1 : 1;
}
if (a?.name?.toLowerCase() < b?.name?.toLowerCase()) {
return isDesc ? 1 : -1;
}
return 0;
});
},