diff --git a/backend/server/adventures/views.py b/backend/server/adventures/views.py index d0a1b0c..5ad6697 100644 --- a/backend/server/adventures/views.py +++ b/backend/server/adventures/views.py @@ -143,6 +143,8 @@ class AdventureViewSet(viewsets.ModelViewSet): @action(detail=False, methods=['get']) def search(self, request): query = self.request.query_params.get('query', '') + if len(query) < 2: + return Response({"error": "Query must be at least 2 characters long"}, status=400) queryset = Adventure.objects.filter( (Q(name__icontains=query) | Q(description__icontains=query) | Q(location__icontains=query) | Q(activity_types__icontains=query)) & (Q(user_id=request.user.id) | Q(is_public=True)) diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index 8535a0c..4824208 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -161,49 +161,53 @@ {/if}
-
diff --git a/frontend/src/lib/components/NotFound.svelte b/frontend/src/lib/components/NotFound.svelte index e05ade2..8337c70 100644 --- a/frontend/src/lib/components/NotFound.svelte +++ b/frontend/src/lib/components/NotFound.svelte @@ -1,5 +1,6 @@
No adventures found -

- There are no adventures to display. Add some using the plus button at the bottom right or try - changing filters! -

+ {#if !error} +

+ There are no adventures to display. Add some using the plus button at the bottom right or + try changing filters! +

+ {:else} +

{error}

+ {/if}
diff --git a/frontend/src/routes/adventures/+page.svelte b/frontend/src/routes/adventures/+page.svelte index 39c333d..ef6a11d 100644 --- a/frontend/src/routes/adventures/+page.svelte +++ b/frontend/src/routes/adventures/+page.svelte @@ -172,7 +172,7 @@

My Adventures

This search returned {count} results.

{#if adventures.length === 0} - + {/if}