Skip to content

Commit

Permalink
Merge pull request #278 from Build-Squad/ENG-220-Explore-Page-Filters…
Browse files Browse the repository at this point in the history
…-Issue

Explore page filters fixes
  • Loading branch information
varsha1305nav authored Mar 28, 2024
2 parents 4dba2a9 + 4e245d0 commit 8cc4bf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/api/marketplace/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -231,11 +234,15 @@ 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)
twitterAccount = twitterAccount.filter(
Q(user_twitter_account_id__region_user_account__region__in=region_ids)
)
if languages:
twitter_accounts_to_exclude = [
twitter_account.id
Expand Down Expand Up @@ -309,7 +316,7 @@ def get(self, request):
id__in=twitter_accounts_to_exclude
)

if rating:
if rating != "0":
exclude_ids = []

for twitter_account in twitterAccount:
Expand Down
3 changes: 3 additions & 0 deletions src/ui/app/business/explore/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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") => {
Expand Down
4 changes: 3 additions & 1 deletion src/ui/src/components/shared/customAutoComplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const CustomAutoComplete = ({
value: string
) => {
setSearch(value);
setOptions([]);
if (!(value == "" && isMulti)) {
setOptions([]);
}
setPagination({ ...pagination, current_page_number: 1 }); // Reset pagination
};

Expand Down

0 comments on commit 8cc4bf4

Please sign in to comment.