From 2b658a0ba6ce1d4b55717235be92f6c9b55f522c Mon Sep 17 00:00:00 2001 From: Parikshit85 Date: Wed, 27 Mar 2024 16:40:36 +0530 Subject: [PATCH 1/3] chore: remove local storage after component unmounts and added region filter --- src/api/marketplace/accounts/views.py | 12 ++++++++++-- src/ui/app/business/explore/page.tsx | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/api/marketplace/accounts/views.py b/src/api/marketplace/accounts/views.py index 5179b6d1..f5956886 100644 --- a/src/api/marketplace/accounts/views.py +++ b/src/api/marketplace/accounts/views.py @@ -5,6 +5,7 @@ from django.shortcuts import get_object_or_404 from accounts.tasks import promote_xfluencer, sendEmail +from core.models import RegionMaster from marketplace.authentication import JWTAuthentication, JWTAuthenticationOptional from django.db.models import Q @@ -172,13 +173,15 @@ def get(self, request): collaborationIds = request.GET.getlist("collaborationIds[]", []) + regions = request.GET.getlist("regions[]", []) + upperPriceLimit = request.GET.get("upperPriceLimit", "") lowerPriceLimit = request.GET.get("lowerPriceLimit", "") upperFollowerLimit = request.GET.get("upperFollowerLimit", "") lowerFollowerLimit = request.GET.get("lowerFollowerLimit", "") searchString = request.GET.get("searchString", "") - rating = request.GET.get("rating", 0) + rating = request.GET.get("rating", "0") # Default fetch influencers for explore page role = request.GET.get("role", "influencer") @@ -236,6 +239,11 @@ def get(self, request): cat_twitter_account_id__category__name=category ) + if regions: + region_ids = RegionMaster.objects.filter(regionName__in=regions).values_list('id', flat=True) + twitterAccount = twitterAccount.filter( + Q(user_twitter_account_id__region_user_account__region__in=region_ids) + ) if languages: twitter_accounts_to_exclude = [ twitter_account.id @@ -309,7 +317,7 @@ def get(self, request): id__in=twitter_accounts_to_exclude ) - if rating: + if rating != "0": exclude_ids = [] for twitter_account in twitterAccount: diff --git a/src/ui/app/business/explore/page.tsx b/src/ui/app/business/explore/page.tsx index b7005df8..17410970 100644 --- a/src/ui/app/business/explore/page.tsx +++ b/src/ui/app/business/explore/page.tsx @@ -83,6 +83,9 @@ export default function Explore({}: Props) { formik.setFieldValue("categories", filterData?.categories); } getInfluencers(filterData); + return () => { + localStorage.removeItem("filterData"); + }; }, []); const getPrice = (inf: any, type = "max") => { From 1123a253b6914dfb85495043fe8eb64ddf7a3c9a Mon Sep 17 00:00:00 2001 From: Parikshit85 Date: Wed, 27 Mar 2024 16:48:10 +0530 Subject: [PATCH 2/3] chore: or condition in category filter --- src/api/marketplace/accounts/views.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/api/marketplace/accounts/views.py b/src/api/marketplace/accounts/views.py index f5956886..013023f0 100644 --- a/src/api/marketplace/accounts/views.py +++ b/src/api/marketplace/accounts/views.py @@ -234,10 +234,9 @@ def get(self, request): ) if categories: - for category in categories: - twitterAccount = twitterAccount.filter( - cat_twitter_account_id__category__name=category - ) + twitterAccount = twitterAccount.filter( + cat_twitter_account_id__category__name__in=categories + ) if regions: region_ids = RegionMaster.objects.filter(regionName__in=regions).values_list('id', flat=True) From 4e245d0b6333881822ece41f4e25d17a82c3957c Mon Sep 17 00:00:00 2001 From: Parikshit85 Date: Wed, 27 Mar 2024 17:09:14 +0530 Subject: [PATCH 3/3] fix: Multi filter bug fix --- src/ui/src/components/shared/customAutoComplete/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/src/components/shared/customAutoComplete/index.tsx b/src/ui/src/components/shared/customAutoComplete/index.tsx index 34035299..875cf12a 100644 --- a/src/ui/src/components/shared/customAutoComplete/index.tsx +++ b/src/ui/src/components/shared/customAutoComplete/index.tsx @@ -83,7 +83,9 @@ const CustomAutoComplete = ({ value: string ) => { setSearch(value); - setOptions([]); + if (!(value == "" && isMulti)) { + setOptions([]); + } setPagination({ ...pagination, current_page_number: 1 }); // Reset pagination };