From b2c5a2091475640b3e3d6d8572e5eb713d0ab543 Mon Sep 17 00:00:00 2001 From: zuies Date: Thu, 14 Sep 2023 23:00:41 +0300 Subject: [PATCH 1/2] add ability to deselect --- .../pages/statistics/ActiveMembersComposition.tsx | 6 +++++- .../pages/statistics/DisengagedMembersComposition.tsx | 6 +++++- src/components/pages/statistics/Onboarding.tsx | 6 +++++- .../activeMembers/ActiveMemberBreakdown.tsx | 4 ++++ .../DisengagedMembersCompositionBreakdown.tsx | 9 +++++---- .../onboardingMembers/OnboardingMembersBreakdown.tsx | 9 +++++---- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/components/pages/statistics/ActiveMembersComposition.tsx b/src/components/pages/statistics/ActiveMembersComposition.tsx index 9cdd6adf..f1552178 100644 --- a/src/components/pages/statistics/ActiveMembersComposition.tsx +++ b/src/components/pages/statistics/ActiveMembersComposition.tsx @@ -225,7 +225,11 @@ export default function ActiveMembersComposition({ if (existingFilterIndex !== -1) { // If it exists, replace the existing filter's label with the new label - existingFilters[existingFilterIndex].label = label; + if (existingFilters[existingFilterIndex].label !== label) { + existingFilters[existingFilterIndex].label = label; + } else { + existingFilters = []; + } } else { // If it doesn't exist, add the new filter to the array existingFilters.push(newFilter); diff --git a/src/components/pages/statistics/DisengagedMembersComposition.tsx b/src/components/pages/statistics/DisengagedMembersComposition.tsx index bd38ad00..77eaf9db 100644 --- a/src/components/pages/statistics/DisengagedMembersComposition.tsx +++ b/src/components/pages/statistics/DisengagedMembersComposition.tsx @@ -210,7 +210,11 @@ export default function DisengagedMembersComposition({ if (existingFilterIndex !== -1) { // If it exists, replace the existing filter's label with the new label - existingFilters[existingFilterIndex].label = label; + if (existingFilters[existingFilterIndex].label !== label) { + existingFilters[existingFilterIndex].label = label; + } else { + existingFilters = []; + } } else { // If it doesn't exist, add the new filter to the array existingFilters.push(newFilter); diff --git a/src/components/pages/statistics/Onboarding.tsx b/src/components/pages/statistics/Onboarding.tsx index 7f952a16..c31dd9f5 100644 --- a/src/components/pages/statistics/Onboarding.tsx +++ b/src/components/pages/statistics/Onboarding.tsx @@ -187,7 +187,11 @@ export default function Onboarding({ if (existingFilterIndex !== -1) { // If it exists, replace the existing filter's label with the new label - existingFilters[existingFilterIndex].label = label; + if (existingFilters[existingFilterIndex].label !== label) { + existingFilters[existingFilterIndex].label = label; + } else { + existingFilters = []; + } } else { // If it doesn't exist, add the new filter to the array existingFilters.push(newFilter); diff --git a/src/components/pages/statistics/memberBreakdowns/activeMembers/ActiveMemberBreakdown.tsx b/src/components/pages/statistics/memberBreakdowns/activeMembers/ActiveMemberBreakdown.tsx index d4299497..9cee797f 100644 --- a/src/components/pages/statistics/memberBreakdowns/activeMembers/ActiveMemberBreakdown.tsx +++ b/src/components/pages/statistics/memberBreakdowns/activeMembers/ActiveMemberBreakdown.tsx @@ -116,6 +116,10 @@ export default function ActiveMemberBreakdown() { const matchedValue = matchedOption.value; handleActivityOptionSelectionChange([matchedValue]); } + } else { + handleActivityOptionSelectionChange( + options.map((option) => option.value) + ); } } } diff --git a/src/components/pages/statistics/memberBreakdowns/disengagedMembersComposition/DisengagedMembersCompositionBreakdown.tsx b/src/components/pages/statistics/memberBreakdowns/disengagedMembersComposition/DisengagedMembersCompositionBreakdown.tsx index f98f1084..f4622493 100644 --- a/src/components/pages/statistics/memberBreakdowns/disengagedMembersComposition/DisengagedMembersCompositionBreakdown.tsx +++ b/src/components/pages/statistics/memberBreakdowns/disengagedMembersComposition/DisengagedMembersCompositionBreakdown.tsx @@ -46,10 +46,7 @@ const options: IActivityCompositionOptions[] = [ ]; export default function DisengagedMembersCompositionBreakdown() { - const { - getDisengagedMembersCompositionTable, - isDisengagedMembersCompositionBreakdownLoading, - } = useAppStore(); + const { getDisengagedMembersCompositionTable } = useAppStore(); const tableTopRef = useRef(null); @@ -130,6 +127,10 @@ export default function DisengagedMembersCompositionBreakdown() { const matchedValue = matchedOption.value; handleActivityOptionSelectionChange([matchedValue]); } + } else { + handleActivityOptionSelectionChange( + options.map((option) => option.value) + ); } } } diff --git a/src/components/pages/statistics/memberBreakdowns/onboardingMembers/OnboardingMembersBreakdown.tsx b/src/components/pages/statistics/memberBreakdowns/onboardingMembers/OnboardingMembersBreakdown.tsx index cde6c617..82652b62 100644 --- a/src/components/pages/statistics/memberBreakdowns/onboardingMembers/OnboardingMembersBreakdown.tsx +++ b/src/components/pages/statistics/memberBreakdowns/onboardingMembers/OnboardingMembersBreakdown.tsx @@ -34,10 +34,7 @@ const options: IActivityCompositionOptions[] = [ ]; export default function OnboardingMembersBreakdown() { - const { - getOnboardingMemberCompositionTable, - isOnboardingMembersBreakdownLoading, - } = useAppStore(); + const { getOnboardingMemberCompositionTable } = useAppStore(); const tableTopRef = useRef(null); @@ -118,6 +115,10 @@ export default function OnboardingMembersBreakdown() { const matchedValue = matchedOption.value; handleActivityOptionSelectionChange([matchedValue]); } + } else { + handleActivityOptionSelectionChange( + options.map((option) => option.value) + ); } } } From 1d6d1c7332dc059c865b085133c2a9b79815bc58 Mon Sep 17 00:00:00 2001 From: zuies Date: Thu, 14 Sep 2023 23:11:04 +0300 Subject: [PATCH 2/2] fix mistake on deselect items --- src/components/pages/statistics/ActiveMembersComposition.tsx | 2 +- .../pages/statistics/DisengagedMembersComposition.tsx | 2 +- src/components/pages/statistics/Onboarding.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/pages/statistics/ActiveMembersComposition.tsx b/src/components/pages/statistics/ActiveMembersComposition.tsx index f1552178..852f83e2 100644 --- a/src/components/pages/statistics/ActiveMembersComposition.tsx +++ b/src/components/pages/statistics/ActiveMembersComposition.tsx @@ -228,7 +228,7 @@ export default function ActiveMembersComposition({ if (existingFilters[existingFilterIndex].label !== label) { existingFilters[existingFilterIndex].label = label; } else { - existingFilters = []; + existingFilters.splice(existingFilterIndex, 1); // remove the item } } else { // If it doesn't exist, add the new filter to the array diff --git a/src/components/pages/statistics/DisengagedMembersComposition.tsx b/src/components/pages/statistics/DisengagedMembersComposition.tsx index 77eaf9db..fb4211a1 100644 --- a/src/components/pages/statistics/DisengagedMembersComposition.tsx +++ b/src/components/pages/statistics/DisengagedMembersComposition.tsx @@ -213,7 +213,7 @@ export default function DisengagedMembersComposition({ if (existingFilters[existingFilterIndex].label !== label) { existingFilters[existingFilterIndex].label = label; } else { - existingFilters = []; + existingFilters.splice(existingFilterIndex, 1); // remove the item } } else { // If it doesn't exist, add the new filter to the array diff --git a/src/components/pages/statistics/Onboarding.tsx b/src/components/pages/statistics/Onboarding.tsx index c31dd9f5..8df069cb 100644 --- a/src/components/pages/statistics/Onboarding.tsx +++ b/src/components/pages/statistics/Onboarding.tsx @@ -190,7 +190,7 @@ export default function Onboarding({ if (existingFilters[existingFilterIndex].label !== label) { existingFilters[existingFilterIndex].label = label; } else { - existingFilters = []; + existingFilters.splice(existingFilterIndex, 1); // remove the item } } else { // If it doesn't exist, add the new filter to the array