Add Priority and label to sort by

This commit is contained in:
Mo Tarbin 2024-12-22 11:03:06 -05:00
parent 933ca9a085
commit 587cc3989f

View file

@ -172,19 +172,40 @@ const MyChores = () => {
case 4:
groupRaw['p4'].push(chore)
break
default:
groupRaw['no_priority'].push(chore)
break
}
})
groups = [
{ name: 'Priority 1', content: groupRaw['p1'] },
{ name: 'Priority 2', content: groupRaw['p2'] },
{ name: 'Priority 3', content: groupRaw['p3'] },
{ name: 'Priority 4', content: groupRaw['p4'] },
{ name: 'No Priority', content: groupRaw['no_priority'] },
]
break
case 'labels':
groupRaw = {}
var labels = {}
chores.forEach(chore => {
chore.labelsV2.forEach(label => {
labels[label.id] = label
if (groupRaw[label.id] === undefined) {
groupRaw[label.id] = []
}
groupRaw[label.id].push(chore)
})
})
groups = Object.keys(groupRaw).map(key => {
return {
name: labels[key].name,
content: groupRaw[key],
}
})
groups.sort((a, b) => {
a.name < b.name ? 1 : -1
})
}
return groups
}