From 7b298329662ac834d192dbcd92570d2d3bcfed07 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 11:12:23 +0200 Subject: [PATCH] feat: refs #6968 Changed groupingMode to enum --- src/pages/Entry/Card/EntryBuys.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pages/Entry/Card/EntryBuys.vue b/src/pages/Entry/Card/EntryBuys.vue index 0208b49ba..3b39840c8 100644 --- a/src/pages/Entry/Card/EntryBuys.vue +++ b/src/pages/Entry/Card/EntryBuys.vue @@ -268,16 +268,11 @@ const importBuys = () => { const toggleGroupingMode = async (buy, mode) => { try { - const grouping = 1; - const packing = 2; - const groupingMode = mode === 'grouping' ? grouping : packing; - - const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; - + const groupingMode = mode === 'grouping' ? mode : 'packing'; + const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; const params = { groupingMode: newGroupingMode, }; - await axios.patch(`Buys/${buy.id}`, params); buy.groupingMode = newGroupingMode; } catch (err) { @@ -287,9 +282,9 @@ const toggleGroupingMode = async (buy, mode) => { const lockIconType = (groupingMode, mode) => { if (mode === 'packing') { - return groupingMode === 2 ? 'lock' : 'lock_open'; + return groupingMode === 'packing' ? 'lock' : 'lock_open'; } else { - return groupingMode === 1 ? 'lock' : 'lock_open'; + return groupingMode === 'grouping' ? 'lock' : 'lock_open'; } };