From 587cc3989f6edfc47827135bc11cc89613191345 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sun, 22 Dec 2024 11:03:06 -0500 Subject: [PATCH] Add Priority and label to sort by --- src/views/Chores/MyChores.jsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/views/Chores/MyChores.jsx b/src/views/Chores/MyChores.jsx index 8a5b70e..8034f1d 100644 --- a/src/views/Chores/MyChores.jsx +++ b/src/views/Chores/MyChores.jsx @@ -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 }