From a6ad7d7542cd39a37f2a83d7fc0b2b1eb4be67d7 Mon Sep 17 00:00:00 2001 From: Ana Elisa Ramos Date: Fri, 14 Feb 2025 01:58:37 -0300 Subject: [PATCH 1/7] =?UTF-8?q?fix(front):=20Filtragem=20no=20formul=C3=A1?= =?UTF-8?q?rio=20de=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/Form-Found.vue | 297 ++++++++++++++++-------------- web/src/components/Form-Lost.vue | 2 +- 2 files changed, 159 insertions(+), 140 deletions(-) diff --git a/web/src/components/Form-Found.vue b/web/src/components/Form-Found.vue index 045cc0fe..4daba4ea 100644 --- a/web/src/components/Form-Found.vue +++ b/web/src/components/Form-Found.vue @@ -19,142 +19,158 @@
- - -
- chevron-down + Categoria * + +
+ +
+ chevron-down +
+
    +
  • + {{ category.name }} +
  • +
- - -
- chevron-down + Localização * + +
+ +
+ chevron-down +
+
    +
  • + {{ location.name }} +
  • +
- - -
- chevron-down + Cor * + +
+ +
+ chevron-down +
+
    +
  • + {{ color.name }} +
  • +
- - -
- chevron-down + Marca * + +
+ +
+ chevron-down +
+
    +
  • + {{ brand.name }} +
  • +
-
+
@@ -246,7 +262,7 @@ @click="save" class="inline-block text-center rounded-full bg-laranja px-5 py-3 text-md text-white w-full" > - {{ editMode ? 'Salvar Alterações' : 'Enviar' }} + {{ editMode ? "Salvar Alterações" : "Enviar" }}
@@ -289,37 +305,40 @@ export default { props: { editMode: { type: Boolean, - default: false + default: false, }, existingItem: { type: Object, - default: null - } + default: null, + }, }, mounted() { this.initializeData(); - + if (this.editMode && this.existingItem) { // Preencher dados existentes this.item = Object.assign(new Item(), this.existingItem); - + this.previews.push(...this.existingItem.image_urls); if (this.item.found_lost_date) { try { const date = new Date(this.item.found_lost_date); - this.item.foundDate = date.getFullYear() + '-' + - String(date.getMonth() + 1).padStart(2, '0') + '-' + - String(date.getDate()).padStart(2, '0'); - - this.foundTime = String(date.getHours()).padStart(2, '0') + ':' + - String(date.getMinutes()).padStart(2, '0'); - + this.item.foundDate = + date.getFullYear() + + "-" + + String(date.getMonth() + 1).padStart(2, "0") + + "-" + + String(date.getDate()).padStart(2, "0"); + + this.foundTime = + String(date.getHours()).padStart(2, "0") + + ":" + + String(date.getMinutes()).padStart(2, "0"); } catch (error) { console.error("Erro ao processar found_lost_date:", error); } - } } }, @@ -385,9 +404,9 @@ export default { const formData = form.toFormData(); - if(this.imagesToRemove.length > 0) { + if (this.imagesToRemove.length > 0) { // Envia múltiplos IDs repetindo a chave "remove_images" - this.imagesToRemove.forEach(id => formData.append("remove_images", id)); + this.imagesToRemove.forEach((id) => formData.append("remove_images", id)); } try { @@ -399,13 +418,13 @@ export default { } await api.patch(`/items/${this.item.id}/`, formData, { - headers: { "Content-Type": "multipart/form-data" } + headers: { "Content-Type": "multipart/form-data" }, }); this.formSubmitted = true; for (let pair of formData.entries()) { console.log(pair[0], pair[1]); - }; + } } else { await api.post("/items/", formData); this.formSubmitted = true; @@ -461,17 +480,17 @@ export default { this.existingItem.image_ids.splice(index, 1); } } else { - // Imagem nova (ainda não foi enviada para a API) - const newIndex = index - ((this.existingItem?.image_urls?.length) || 0); - this.item.images.splice(newIndex, 1); + // Imagem nova (ainda não foi enviada para a API) + const newIndex = index - (this.existingItem?.image_urls?.length || 0); + this.item.images.splice(newIndex, 1); } - // Atualiza a lista de previews corretamente - this.previews.splice(index, 1); + // Atualiza a lista de previews corretamente + this.previews.splice(index, 1); - // Verifica se agora há menos de 2 imagens para reativar o botão de adicionar - this.$forceUpdate(); - this.$refs.fileInput.value = ""; + // Verifica se agora há menos de 2 imagens para reativar o botão de adicionar + this.$forceUpdate(); + this.$refs.fileInput.value = ""; }, handleSelectChange(event) { diff --git a/web/src/components/Form-Lost.vue b/web/src/components/Form-Lost.vue index 96e6646f..ee7f169c 100644 --- a/web/src/components/Form-Lost.vue +++ b/web/src/components/Form-Lost.vue @@ -170,7 +170,7 @@
-
+
From fb9608a72b770e9c0a693c9bc4ebb4f9d3023676 Mon Sep 17 00:00:00 2001 From: Ana Elisa Ramos Date: Fri, 14 Feb 2025 07:42:27 -0300 Subject: [PATCH 2/7] =?UTF-8?q?feat(front):=20Torna=20op=C3=A7=C3=B5es=20d?= =?UTF-8?q?os=20selects=20est=C3=A1ticas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API/AcheiUnB/tests/test_integration.py | 3 +- API/users/apps.py | 2 +- API/users/models.py | 31 +- API/users/pagination.py | 4 +- API/users/serializers.py | 4 +- API/users/signals.py | 2 +- API/users/tasks.py | 3 +- API/users/urls.py | 3 + API/users/views.py | 52 +- web/src/components/Form-Found.vue | 946 ++++++++++++++++++++++++- web/src/components/Form-Lost.vue | 925 ++++++++++++++++++++++-- web/src/components/Header-Found.vue | 2 +- web/src/components/Header-Lost.vue | 2 +- web/src/components/Header-Message.vue | 2 +- web/src/components/Item-Header.vue | 18 +- web/src/services/api.js | 2 +- web/src/services/apiItems.js | 23 +- web/src/views/ListItem.vue | 35 +- web/src/views/Login.vue | 19 +- web/src/views/Register-Found.vue | 2 +- web/src/views/Register-Lost.vue | 2 +- web/src/views/User.vue | 8 + web/src/views/UserItems-Lost.vue | 66 +- 23 files changed, 1948 insertions(+), 208 deletions(-) diff --git a/API/AcheiUnB/tests/test_integration.py b/API/AcheiUnB/tests/test_integration.py index d9d3c78c..402edc2d 100644 --- a/API/AcheiUnB/tests/test_integration.py +++ b/API/AcheiUnB/tests/test_integration.py @@ -1,4 +1,3 @@ -import uuid from unittest.mock import patch import pytest @@ -92,7 +91,7 @@ def test_search_items(mock_authentication): ) assert response.status_code == 200 - + @pytest.mark.django_db() def test_get_messages(mock_authentication): diff --git a/API/users/apps.py b/API/users/apps.py index 0ad634ed..46977358 100644 --- a/API/users/apps.py +++ b/API/users/apps.py @@ -6,4 +6,4 @@ class UsersConfig(AppConfig): name = "users" def ready(self): - import users.signals + import users.signals diff --git a/API/users/models.py b/API/users/models.py index 33987db8..6d6c08a2 100644 --- a/API/users/models.py +++ b/API/users/models.py @@ -4,14 +4,12 @@ class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile") - profile_picture = models.URLField( - null=True, blank=True - ) + profile_picture = models.URLField(null=True, blank=True) welcome_email_sent = models.BooleanField(default=False) class Category(models.Model): - name = models.CharField(max_length=50, unique=True) + name = models.CharField(max_length=50, unique=True) category_id = models.CharField(max_length=10, unique=True) def __str__(self): @@ -20,15 +18,16 @@ def __str__(self): class Location(models.Model): name = models.CharField(max_length=100, unique=True) - location_id = models.CharField(max_length=2, unique=True) + location_id = models.CharField(max_length=2, unique=True) def __str__(self): return self.name class Color(models.Model): - name = models.CharField(max_length=50, unique=True) + name = models.CharField(max_length=50, unique=True) color_id = models.CharField(max_length=2, unique=True) + def __str__(self): return self.name @@ -47,23 +46,15 @@ class Item(models.Model): ("lost", "Lost"), ] - user = models.ForeignKey( - User, on_delete=models.SET_NULL, null=True, blank=True - ) + user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) name = models.CharField(max_length=100) description = models.TextField(max_length=250, blank=True) category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True, blank=True) location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True) - color = models.ForeignKey( - Color, on_delete=models.SET_NULL, null=True, blank=True - ) - brand = models.ForeignKey( - Brand, on_delete=models.SET_NULL, null=True, blank=True - ) - status = models.CharField( - max_length=10, choices=STATUS_CHOICES, default="lost" - ) - found_lost_date = models.DateTimeField(null=True, blank=True) + color = models.ForeignKey(Color, on_delete=models.SET_NULL, null=True, blank=True) + brand = models.ForeignKey(Brand, on_delete=models.SET_NULL, null=True, blank=True) + status = models.CharField(max_length=10, choices=STATUS_CHOICES, default="lost") + found_lost_date = models.DateTimeField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) barcode = models.CharField(max_length=10, editable=False, blank=True) @@ -91,7 +82,7 @@ def __str__(self): class ItemImage(models.Model): item = models.ForeignKey(Item, related_name="images", on_delete=models.CASCADE) - image_url = models.URLField() + image_url = models.URLField() def __str__(self): return f"Image for {self.item.name}" diff --git a/API/users/pagination.py b/API/users/pagination.py index d375fca1..41087262 100644 --- a/API/users/pagination.py +++ b/API/users/pagination.py @@ -2,5 +2,5 @@ class LostFoundPagination(PageNumberPagination): - page_size = 27 - page_size_query_param = "page_size" + page_size = 27 + page_size_query_param = "page_size" diff --git a/API/users/serializers.py b/API/users/serializers.py index 7dcedc3b..7f1932f1 100644 --- a/API/users/serializers.py +++ b/API/users/serializers.py @@ -47,7 +47,7 @@ class ItemSerializer(serializers.ModelSerializer): image_urls = serializers.SerializerMethodField(read_only=True) image_ids = serializers.SerializerMethodField(read_only=True) user_id = serializers.IntegerField(source="user.id", read_only=True) - barcode = serializers.CharField(read_only=True) + barcode = serializers.CharField(read_only=True) category_name = serializers.SerializerMethodField() location_name = serializers.SerializerMethodField() color_name = serializers.SerializerMethodField() @@ -78,7 +78,7 @@ class Meta: "images", "remove_images", "image_urls", - "image_ids", + "image_ids", ] def validate_images(self, value): diff --git a/API/users/signals.py b/API/users/signals.py index 1e8b3fb3..962114ae 100644 --- a/API/users/signals.py +++ b/API/users/signals.py @@ -33,7 +33,7 @@ def send_welcome_email_on_first_login(sender, request, user, **kwargs): if not profile.welcome_email_sent: print("Primeiro login detectado. Enviando e-mail de boas-vindas.") send_welcome_email.delay(user.email, user.first_name) - profile.welcome_email_sent = True + profile.welcome_email_sent = True profile.save() else: print("E-mail de boas-vindas já enviado anteriormente. Nenhuma ação tomada.") diff --git a/API/users/tasks.py b/API/users/tasks.py index 964cb49b..661268b1 100644 --- a/API/users/tasks.py +++ b/API/users/tasks.py @@ -51,7 +51,7 @@ def send_welcome_email(user_email, user_name): @shared_task def find_and_notify_matches_task(target_item_id, max_distance=2): - from .match import find_and_notify_matches + from .match import find_and_notify_matches """Task assíncrona para encontrar e notificar matches.""" try: @@ -94,6 +94,7 @@ def upload_images_to_cloudinary(object_id, images, object_type="item"): except Exception as e: print(f"Erro ao fazer upload de imagem para o objeto {object_id}: {e}") + @shared_task def remove_images_from_item(image_ids): """Remove imagens associadas a um item.""" diff --git a/API/users/urls.py b/API/users/urls.py index dd97c508..c77064af 100644 --- a/API/users/urls.py +++ b/API/users/urls.py @@ -14,6 +14,7 @@ UserDetailView, UserListView, UserValidateView, + LogoutView ) router = DefaultRouter() @@ -31,10 +32,12 @@ path("items/found/my-items/", MyItemsFoundView.as_view(), name="my-found-items"), path("", include(router.urls)), path("auth/validate/", UserValidateView.as_view(), name="useer-detail"), + path("auth/logout/", LogoutView.as_view(), name="useer-detail"), path("auth/user/", UserDetailView.as_view(), name="useer-detail"), path("test-user/", TestUserView.as_view(), name="test_user"), path("users/", UserListView.as_view(), name="user-list"), path("users//", UserListView.as_view(), name="user-detail"), + # Implementação futura sobre matchs path("items//matches/", # MatchItemViewSet.as_view(), name="item-matches"), ] diff --git a/API/users/views.py b/API/users/views.py index 80c282e0..628ca198 100644 --- a/API/users/views.py +++ b/API/users/views.py @@ -41,16 +41,14 @@ class UserListView(View): def get(self, request, user_id=None): if user_id: user = get_object_or_404(User, id=user_id) - profile = getattr(user, "profile", None) - profile_picture = ( - profile.profile_picture if profile else None - ) + profile = getattr(user, "profile", None) + profile_picture = profile.profile_picture if profile else None user_data = { "id": user.id, "first_name": user.first_name, "email": user.email, - "foto": profile_picture, + "foto": profile_picture, } return JsonResponse(user_data, status=200) @@ -60,9 +58,7 @@ def get(self, request, user_id=None): "id": user.id, "first_name": user.first_name, "email": user.email, - "foto": getattr( - user.profile, "profile_picture", None - ), + "foto": getattr(user.profile, "profile_picture", None), } for user in users ] @@ -147,7 +143,8 @@ def perform_update(self, serializer): ) self.schedule_match_task(item) -''' Estrutura de match para implementação futura + +""" Estrutura de match para implementação futura Match de itens caso o usuário queira ver os possíveis matches pelo site: class MatchItemViewSet(APIView): @@ -171,7 +168,7 @@ def get(self, request, item_id): } for match in matches ] - return Response(data, status=200)''' + return Response(data, status=200)""" class MyItemsLostView(APIView): @@ -280,6 +277,19 @@ class UserValidateView(APIView): def get(self, request): return Response({"message": "Token válido"}) + +class LogoutView(APIView): + def get(self, request): + response = Response({"message": "Logout feito"}, status=200) + response.set_cookie( + key="access_token", + value="", + httponly=True, + secure=True, + samesite="Strict", + max_age=0, + ) + return response class UserDetailView(APIView): @@ -291,9 +301,7 @@ class UserDetailView(APIView): def get(self, request): user = request.user - request.headers.get("Authorization", "").replace( - "Bearer ", "" - ) + request.headers.get("Authorization", "").replace("Bearer ", "") logger.info(f"Usuário autenticado: {user.username} (ID: {user.id})") try: @@ -311,7 +319,7 @@ def get(self, request): "first_name": user.first_name, "last_name": user.last_name, "matricula": matricula, - "foto": foto_url, + "foto": foto_url, } return Response(user_data) @@ -414,7 +422,7 @@ def microsoft_callback(request): value=jwt_access, httponly=True, secure=True, - samesite="Strict", + samesite="Strict", max_age=3600, ) return response @@ -448,7 +456,7 @@ def post(self, request): """ Testa a criação de um usuário completo no banco de dados. """ - data = request.data + data = request.data try: user, created = User.objects.update_or_create( @@ -457,9 +465,7 @@ def post(self, request): "username": data.get("username"), "first_name": data.get("first_name"), "last_name": data.get("last_name"), - "password": data.get( - "password", "" - ), + "password": data.get("password", ""), "last_login": data.get("last_login", datetime.now()), "is_superuser": data.get("is_superuser", False), "is_staff": data.get("is_staff", False), @@ -506,11 +512,9 @@ def get_user_photo(access_token): url = "https://graph.microsoft.com/v1.0/me/photo/$value" headers = {"Authorization": f"Bearer {access_token}"} - response = requests.get( - url, headers=headers, stream=True - ) + response = requests.get(url, headers=headers, stream=True) if response.status_code == 200: - return response.content + return response.content else: raise Exception( f"Erro ao buscar a foto do usuário: {response.status_code} - {response.text}" @@ -525,7 +529,7 @@ class DeleteUserView(View): def delete(self, request, user_id): try: user = User.objects.get(id=user_id) - user.delete() + user.delete() return JsonResponse( {"message": f"Usuário com ID {user_id} foi deletado com sucesso."}, status=200, diff --git a/web/src/components/Form-Found.vue b/web/src/components/Form-Found.vue index 5e4bfc8a..e2c386bc 100644 --- a/web/src/components/Form-Found.vue +++ b/web/src/components/Form-Found.vue @@ -296,10 +296,882 @@ export default { submitError: false, formSubmitted: false, alertMessage: "", - categories: [], - locations: [], - colors: [], - brands: [], + categories: [ + { + id: 1, + name: "Anel", + category_id: "01", + }, + { + id: 2, + name: "Anotações", + category_id: "02", + }, + { + id: 3, + name: "Apostila", + category_id: "03", + }, + { + id: 4, + name: "Base", + category_id: "04", + }, + { + id: 5, + name: "Batom", + category_id: "05", + }, + { + id: 6, + name: "Blusa", + category_id: "06", + }, + { + id: 7, + name: "Blush", + category_id: "07", + }, + { + id: 8, + name: "Boné", + category_id: "08", + }, + { + id: 9, + name: "Borracha", + category_id: "09", + }, + { + id: 10, + name: "Brinco", + category_id: "10", + }, + { + id: 11, + name: "Caderno", + category_id: "11", + }, + { + id: 12, + name: "Calculadora", + category_id: "12", + }, + { + id: 13, + name: "Calculadora Científica", + category_id: "13", + }, + { + id: 14, + name: "Camiseta", + category_id: "14", + }, + { + id: 15, + name: "Caneta", + category_id: "15", + }, + { + id: 16, + name: "Carregador", + category_id: "16", + }, + { + id: 17, + name: "Carregador Portátil", + category_id: "17", + }, + { + id: 18, + name: "Carteira", + category_id: "18", + }, + { + id: 19, + name: "Carteira de Identidade", + category_id: "19", + }, + { + id: 20, + name: "Carteira de Motorista", + category_id: "20", + }, + { + id: 21, + name: "Cartão SUS", + category_id: "21", + }, + { + id: 22, + name: "Casaco", + category_id: "22", + }, + { + id: 23, + name: "Case Fone", + category_id: "23", + }, + { + id: 24, + name: "Case Notebook", + category_id: "24", + }, + { + id: 25, + name: "Celular", + category_id: "25", + }, + { + id: 26, + name: "Chapéu", + category_id: "26", + }, + { + id: 27, + name: "Chaves", + category_id: "27", + }, + { + id: 28, + name: "Chinelo", + category_id: "28", + }, + { + id: 29, + name: "Colar", + category_id: "29", + }, + { + id: 30, + name: "Estojo", + category_id: "30", + }, + { + id: 31, + name: "Fone de ouvido", + category_id: "31", + }, + { + id: 32, + name: "Garrafa de Água", + category_id: "32", + }, + { + id: 33, + name: "Gloss", + category_id: "33", + }, + { + id: 34, + name: "Grampeador", + category_id: "34", + }, + { + id: 35, + name: "Guarda-chuva", + category_id: "35", + }, + { + id: 36, + name: "Lapizeira", + category_id: "36", + }, + { + id: 37, + name: "Livro", + category_id: "37", + }, + { + id: 38, + name: "Lápis", + category_id: "38", + }, + { + id: 39, + name: "Lápis de olho", + category_id: "39", + }, + { + id: 40, + name: "Mochila", + category_id: "40", + }, + { + id: 41, + name: "Mouse", + category_id: "41", + }, + { + id: 42, + name: "Nessesair", + category_id: "42", + }, + { + id: 43, + name: "Notebook", + category_id: "43", + }, + { + id: 44, + name: "Passe Estudantil", + category_id: "44", + }, + { + id: 45, + name: "Passe de Ônibus", + category_id: "45", + }, + { + id: 46, + name: "Piercing", + category_id: "46", + }, + { + id: 47, + name: "Pingente", + category_id: "47", + }, + { + id: 48, + name: "Planner", + category_id: "48", + }, + { + id: 49, + name: "Presilha de Cabelo", + category_id: "49", + }, + { + id: 50, + name: "Pulseira", + category_id: "50", + }, + { + id: 51, + name: "Relógio", + category_id: "51", + }, + { + id: 52, + name: "Smartwatch", + category_id: "52", + }, + { + id: 53, + name: "Sombra", + category_id: "53", + }, + { + id: 54, + name: "Stylus", + category_id: "54", + }, + { + id: 55, + name: "Suporte Notebook", + category_id: "55", + }, + { + id: 56, + name: "Tablet", + category_id: "56", + }, + { + id: 57, + name: "Touca", + category_id: "57", + }, + { + id: 58, + name: "Óculos", + category_id: "58", + }, + { + id: 59, + name: "Outra", + category_id: "00", + }, + ], + locations: [ + { + id: 1, + name: "Anfiteatro - UAC", + location_id: "01", + }, + { + id: 2, + name: "Banheiros - LDTEA", + location_id: "02", + }, + { + id: 3, + name: "Banheiros - RU", + location_id: "03", + }, + { + id: 4, + name: "Banheiros - UAC", + location_id: "04", + }, + { + id: 5, + name: "Banheiros - UED", + location_id: "05", + }, + { + id: 6, + name: "Bebedouros - UAC", + location_id: "06", + }, + { + id: 7, + name: "Bebedouros - UED", + location_id: "07", + }, + { + id: 8, + name: "Biblioteca - UAC", + location_id: "08", + }, + { + id: 9, + name: "Box - RU", + location_id: "09", + }, + { + id: 10, + name: "Caixa - RU", + location_id: "10", + }, + { + id: 11, + name: "Diretório Acadêmico - DA", + location_id: "11", + }, + { + id: 12, + name: "Estacionamento - LDTEA", + location_id: "12", + }, + { + id: 13, + name: "Estacionamento - UAC", + location_id: "13", + }, + { + id: 14, + name: "Estacionamento - UED", + location_id: "14", + }, + { + id: 15, + name: "Guarita Estacionamento Norte", + location_id: "15", + }, + { + id: 16, + name: "Guarita Estacionamento Sul", + location_id: "16", + }, + { + id: 17, + name: "I1 - UAC", + location_id: "17", + }, + { + id: 18, + name: "I10 - UAC", + location_id: "18", + }, + { + id: 19, + name: "I2 - UAC", + location_id: "19", + }, + { + id: 20, + name: "I3 - UAC", + location_id: "20", + }, + { + id: 21, + name: "I4 - UAC", + location_id: "21", + }, + { + id: 22, + name: "I5 - UAC", + location_id: "22", + }, + { + id: 23, + name: "I6 - UAC", + location_id: "23", + }, + { + id: 24, + name: "I7 - UAC", + location_id: "24", + }, + { + id: 25, + name: "I8 - UAC", + location_id: "25", + }, + { + id: 26, + name: "I9 - UAC", + location_id: "26", + }, + { + id: 27, + name: "Jardim - RU", + location_id: "27", + }, + { + id: 28, + name: "Jardim - UAC", + location_id: "28", + }, + { + id: 29, + name: "LDTEA", + location_id: "29", + }, + { + id: 30, + name: "Laboratórios - LDTEA", + location_id: "30", + }, + { + id: 31, + name: "Laboratórios - UED", + location_id: "31", + }, + { + id: 32, + name: "Mesa de estudos - UED", + location_id: "32", + }, + { + id: 33, + name: "Mesanino - UAC", + location_id: "33", + }, + { + id: 34, + name: "Mesanino - UED", + location_id: "34", + }, + { + id: 35, + name: "Mesas - RU", + location_id: "35", + }, + { + id: 36, + name: "Mesas O Belisco - UAC", + location_id: "36", + }, + { + id: 37, + name: "Mesas Redondas - UED", + location_id: "37", + }, + { + id: 38, + name: "Mesas de Dama - UAC", + location_id: "38", + }, + { + id: 39, + name: "Mesas de Estudos - UAC", + location_id: "39", + }, + { + id: 40, + name: "Mocap - UED", + location_id: "40", + }, + { + id: 41, + name: "Monumento lado ru", + location_id: "41", + }, + { + id: 42, + name: "Quadra Poliesportiva", + location_id: "42", + }, + { + id: 43, + name: "RU", + location_id: "43", + }, + { + id: 44, + name: "Restaurante - RU", + location_id: "44", + }, + { + id: 45, + name: "S1 - UAC", + location_id: "45", + }, + { + id: 46, + name: "S10 - UAC", + location_id: "46", + }, + { + id: 47, + name: "S2 - UAC", + location_id: "47", + }, + { + id: 48, + name: "S3 - UAC", + location_id: "48", + }, + { + id: 49, + name: "S4 - UAC", + location_id: "49", + }, + { + id: 50, + name: "S5 - UAC", + location_id: "50", + }, + { + id: 51, + name: "S6 - UAC", + location_id: "51", + }, + { + id: 52, + name: "S7 - UAC", + location_id: "52", + }, + { + id: 53, + name: "S8 - UAC", + location_id: "53", + }, + { + id: 54, + name: "S9 - UAC", + location_id: "54", + }, + { + id: 55, + name: "Sala de Professor - UED", + location_id: "55", + }, + { + id: 56, + name: "UAC", + location_id: "56", + }, + { + id: 57, + name: "UED", + location_id: "57", + }, + { + id: 58, + name: "Outro", + location_id: "00", + }, + ], + colors: [ + { + id: 1, + name: "Amarelo", + color_id: "01", + }, + { + id: 2, + name: "Azul", + color_id: "02", + }, + { + id: 3, + name: "Bege", + color_id: "03", + }, + { + id: 4, + name: "Branco", + color_id: "04", + }, + { + id: 5, + name: "Bronze", + color_id: "05", + }, + { + id: 6, + name: "Cinza", + color_id: "06", + }, + { + id: 7, + name: "Dourado", + color_id: "07", + }, + { + id: 8, + name: "Estampado", + color_id: "08", + }, + { + id: 9, + name: "Laranja", + color_id: "09", + }, + { + id: 10, + name: "Marrom", + color_id: "10", + }, + { + id: 11, + name: "Prata", + color_id: "11", + }, + { + id: 12, + name: "Preto", + color_id: "12", + }, + { + id: 13, + name: "Rosa", + color_id: "13", + }, + { + id: 14, + name: "Verde", + color_id: "14", + }, + { + id: 15, + name: "Vermelho", + color_id: "15", + }, + { + id: 16, + name: "Outra", + color_id: "00", + }, + ], + brands: [ + { + id: 1, + name: "Acer", + brand_id: "01", + }, + { + id: 2, + name: "Adidas", + brand_id: "02", + }, + { + id: 3, + name: "Apple", + brand_id: "03", + }, + { + id: 4, + name: "Asus", + brand_id: "04", + }, + { + id: 5, + name: "Avon", + brand_id: "05", + }, + { + id: 6, + name: "Bic", + brand_id: "06", + }, + { + id: 7, + name: "Dell", + brand_id: "07", + }, + { + id: 8, + name: "Dior", + brand_id: "08", + }, + { + id: 9, + name: "FCTE", + brand_id: "09", + }, + { + id: 10, + name: "FGA", + brand_id: "10", + }, + { + id: 11, + name: "HP", + brand_id: "11", + }, + { + id: 12, + name: "Havaianas", + brand_id: "12", + }, + { + id: 13, + name: "Hay-Ban", + brand_id: "13", + }, + { + id: 14, + name: "Huawei", + brand_id: "14", + }, + { + id: 15, + name: "JBL", + brand_id: "15", + }, + { + id: 16, + name: "Kingston", + brand_id: "16", + }, + { + id: 17, + name: "LG", + brand_id: "17", + }, + { + id: 18, + name: "Lenovo", + brand_id: "18", + }, + { + id: 19, + name: "Levi's", + brand_id: "19", + }, + { + id: 20, + name: "Motorola", + brand_id: "20", + }, + { + id: 21, + name: "New Balance", + brand_id: "21", + }, + { + id: 22, + name: "Nike", + brand_id: "22", + }, + { + id: 23, + name: "Nokia", + brand_id: "23", + }, + { + id: 24, + name: "O Boticário", + brand_id: "24", + }, + { + id: 25, + name: "Oaklay", + brand_id: "25", + }, + { + id: 26, + name: "Puma", + brand_id: "26", + }, + { + id: 27, + name: "RRDD", + brand_id: "27", + }, + { + id: 28, + name: "Razer", + brand_id: "28", + }, + { + id: 29, + name: "Samsung", + brand_id: "29", + }, + { + id: 30, + name: "SanDisk", + brand_id: "30", + }, + { + id: 31, + name: "Sony", + brand_id: "31", + }, + { + id: 32, + name: "Stanley", + brand_id: "32", + }, + { + id: 33, + name: "Tapaware", + brand_id: "33", + }, + { + id: 34, + name: "Toshiba", + brand_id: "34", + }, + { + id: 35, + name: "UnB", + brand_id: "35", + }, + { + id: 36, + name: "Vaio", + brand_id: "36", + }, + { + id: 37, + name: "Vans", + brand_id: "37", + }, + { + id: 38, + name: "Xiaomi", + brand_id: "38", + }, + { + id: 39, + name: "Outra", + brand_id: "00", + }, + ], + searchCategory: "", + searchLocation: "", + searchBrand: "", + searchColor: "", + showCategoryDropdown: false, + showLocationDropdown: false, + showBrandDropdown: false, + showColorDropdown: false, }; }, props: { @@ -313,10 +1185,7 @@ export default { }, }, mounted() { - this.initializeData(); - if (this.editMode && this.existingItem) { - // Preencher dados existentes this.item = Object.assign(new Item(), this.existingItem); this.previews.push(...this.existingItem.image_urls); @@ -344,14 +1213,29 @@ export default { } } }, - methods: { - initializeData() { - this.initializeCategories(); - this.initializeLocations(); - this.initializeColors(); - this.initializeBrands(); + computed: { + filteredCategories() { + return this.categories.filter((category) => + category.name.toLowerCase().includes(this.searchCategory.toLowerCase()), + ); }, - + filteredLocations() { + return this.locations.filter((location) => + location.name.toLowerCase().includes(this.searchLocation.toLowerCase()), + ); + }, + filteredBrands() { + return this.brands.filter((brand) => + brand.name.toLowerCase().includes(this.searchBrand.toLowerCase()), + ); + }, + filteredColors() { + return this.colors.filter((color) => + color.name.toLowerCase().includes(this.searchColor.toLowerCase()), + ); + }, + }, + methods: { async initializeCategories() { try { const result = await api.get("/categories/"); @@ -395,7 +1279,6 @@ export default { this.submitError = true; } }, - async save() { this.item.status = "found"; @@ -510,6 +1393,39 @@ export default { this.item[`${element.id}`] = ""; } }, + + selectCategory(category) { + this.item.category = category.id; + this.searchCategory = category.name; + this.showCategoryDropdown = false; + }, + + selectLocation(location) { + this.item.location = location.id; + this.searchLocation = location.name; + this.showLocationDropdown = false; + }, + + selectBrand(brand) { + this.item.brand = brand.id; + this.searchBrand = brand.name; + this.showBrandDropdown = false; + }, + + selectColor(color) { + this.item.color = color.id; + this.searchColor = color.name; + this.showBrandDropdown = false; + }, + + hideDropdown(field) { + setTimeout(() => { + if (field === "category") this.showCategoryDropdown = false; + if (field === "location") this.showLocationDropdown = false; + if (field === "brand") this.showBrandDropdown = false; + if (field === "color") this.showColorDropdown = false; + }, 100); + }, }, }; diff --git a/web/src/components/Form-Lost.vue b/web/src/components/Form-Lost.vue index dfdb457c..ed4c8813 100644 --- a/web/src/components/Form-Lost.vue +++ b/web/src/components/Form-Lost.vue @@ -284,10 +284,874 @@ export default { submitError: false, formSubmitted: false, alertMessage: "", - categories: [], - locations: [], - colors: [], - brands: [], + categories: [ + { + id: 1, + name: "Anel", + category_id: "01", + }, + { + id: 2, + name: "Anotações", + category_id: "02", + }, + { + id: 3, + name: "Apostila", + category_id: "03", + }, + { + id: 4, + name: "Base", + category_id: "04", + }, + { + id: 5, + name: "Batom", + category_id: "05", + }, + { + id: 6, + name: "Blusa", + category_id: "06", + }, + { + id: 7, + name: "Blush", + category_id: "07", + }, + { + id: 8, + name: "Boné", + category_id: "08", + }, + { + id: 9, + name: "Borracha", + category_id: "09", + }, + { + id: 10, + name: "Brinco", + category_id: "10", + }, + { + id: 11, + name: "Caderno", + category_id: "11", + }, + { + id: 12, + name: "Calculadora", + category_id: "12", + }, + { + id: 13, + name: "Calculadora Científica", + category_id: "13", + }, + { + id: 14, + name: "Camiseta", + category_id: "14", + }, + { + id: 15, + name: "Caneta", + category_id: "15", + }, + { + id: 16, + name: "Carregador", + category_id: "16", + }, + { + id: 17, + name: "Carregador Portátil", + category_id: "17", + }, + { + id: 18, + name: "Carteira", + category_id: "18", + }, + { + id: 19, + name: "Carteira de Identidade", + category_id: "19", + }, + { + id: 20, + name: "Carteira de Motorista", + category_id: "20", + }, + { + id: 21, + name: "Cartão SUS", + category_id: "21", + }, + { + id: 22, + name: "Casaco", + category_id: "22", + }, + { + id: 23, + name: "Case Fone", + category_id: "23", + }, + { + id: 24, + name: "Case Notebook", + category_id: "24", + }, + { + id: 25, + name: "Celular", + category_id: "25", + }, + { + id: 26, + name: "Chapéu", + category_id: "26", + }, + { + id: 27, + name: "Chaves", + category_id: "27", + }, + { + id: 28, + name: "Chinelo", + category_id: "28", + }, + { + id: 29, + name: "Colar", + category_id: "29", + }, + { + id: 30, + name: "Estojo", + category_id: "30", + }, + { + id: 31, + name: "Fone de ouvido", + category_id: "31", + }, + { + id: 32, + name: "Garrafa de Água", + category_id: "32", + }, + { + id: 33, + name: "Gloss", + category_id: "33", + }, + { + id: 34, + name: "Grampeador", + category_id: "34", + }, + { + id: 35, + name: "Guarda-chuva", + category_id: "35", + }, + { + id: 36, + name: "Lapizeira", + category_id: "36", + }, + { + id: 37, + name: "Livro", + category_id: "37", + }, + { + id: 38, + name: "Lápis", + category_id: "38", + }, + { + id: 39, + name: "Lápis de olho", + category_id: "39", + }, + { + id: 40, + name: "Mochila", + category_id: "40", + }, + { + id: 41, + name: "Mouse", + category_id: "41", + }, + { + id: 42, + name: "Nessesair", + category_id: "42", + }, + { + id: 43, + name: "Notebook", + category_id: "43", + }, + { + id: 44, + name: "Passe Estudantil", + category_id: "44", + }, + { + id: 45, + name: "Passe de Ônibus", + category_id: "45", + }, + { + id: 46, + name: "Piercing", + category_id: "46", + }, + { + id: 47, + name: "Pingente", + category_id: "47", + }, + { + id: 48, + name: "Planner", + category_id: "48", + }, + { + id: 49, + name: "Presilha de Cabelo", + category_id: "49", + }, + { + id: 50, + name: "Pulseira", + category_id: "50", + }, + { + id: 51, + name: "Relógio", + category_id: "51", + }, + { + id: 52, + name: "Smartwatch", + category_id: "52", + }, + { + id: 53, + name: "Sombra", + category_id: "53", + }, + { + id: 54, + name: "Stylus", + category_id: "54", + }, + { + id: 55, + name: "Suporte Notebook", + category_id: "55", + }, + { + id: 56, + name: "Tablet", + category_id: "56", + }, + { + id: 57, + name: "Touca", + category_id: "57", + }, + { + id: 58, + name: "Óculos", + category_id: "58", + }, + { + id: 59, + name: "Outra", + category_id: "00", + }, + ], + locations: [ + { + id: 1, + name: "Anfiteatro - UAC", + location_id: "01", + }, + { + id: 2, + name: "Banheiros - LDTEA", + location_id: "02", + }, + { + id: 3, + name: "Banheiros - RU", + location_id: "03", + }, + { + id: 4, + name: "Banheiros - UAC", + location_id: "04", + }, + { + id: 5, + name: "Banheiros - UED", + location_id: "05", + }, + { + id: 6, + name: "Bebedouros - UAC", + location_id: "06", + }, + { + id: 7, + name: "Bebedouros - UED", + location_id: "07", + }, + { + id: 8, + name: "Biblioteca - UAC", + location_id: "08", + }, + { + id: 9, + name: "Box - RU", + location_id: "09", + }, + { + id: 10, + name: "Caixa - RU", + location_id: "10", + }, + { + id: 11, + name: "Diretório Acadêmico - DA", + location_id: "11", + }, + { + id: 12, + name: "Estacionamento - LDTEA", + location_id: "12", + }, + { + id: 13, + name: "Estacionamento - UAC", + location_id: "13", + }, + { + id: 14, + name: "Estacionamento - UED", + location_id: "14", + }, + { + id: 15, + name: "Guarita Estacionamento Norte", + location_id: "15", + }, + { + id: 16, + name: "Guarita Estacionamento Sul", + location_id: "16", + }, + { + id: 17, + name: "I1 - UAC", + location_id: "17", + }, + { + id: 18, + name: "I10 - UAC", + location_id: "18", + }, + { + id: 19, + name: "I2 - UAC", + location_id: "19", + }, + { + id: 20, + name: "I3 - UAC", + location_id: "20", + }, + { + id: 21, + name: "I4 - UAC", + location_id: "21", + }, + { + id: 22, + name: "I5 - UAC", + location_id: "22", + }, + { + id: 23, + name: "I6 - UAC", + location_id: "23", + }, + { + id: 24, + name: "I7 - UAC", + location_id: "24", + }, + { + id: 25, + name: "I8 - UAC", + location_id: "25", + }, + { + id: 26, + name: "I9 - UAC", + location_id: "26", + }, + { + id: 27, + name: "Jardim - RU", + location_id: "27", + }, + { + id: 28, + name: "Jardim - UAC", + location_id: "28", + }, + { + id: 29, + name: "LDTEA", + location_id: "29", + }, + { + id: 30, + name: "Laboratórios - LDTEA", + location_id: "30", + }, + { + id: 31, + name: "Laboratórios - UED", + location_id: "31", + }, + { + id: 32, + name: "Mesa de estudos - UED", + location_id: "32", + }, + { + id: 33, + name: "Mesanino - UAC", + location_id: "33", + }, + { + id: 34, + name: "Mesanino - UED", + location_id: "34", + }, + { + id: 35, + name: "Mesas - RU", + location_id: "35", + }, + { + id: 36, + name: "Mesas O Belisco - UAC", + location_id: "36", + }, + { + id: 37, + name: "Mesas Redondas - UED", + location_id: "37", + }, + { + id: 38, + name: "Mesas de Dama - UAC", + location_id: "38", + }, + { + id: 39, + name: "Mesas de Estudos - UAC", + location_id: "39", + }, + { + id: 40, + name: "Mocap - UED", + location_id: "40", + }, + { + id: 41, + name: "Monumento lado ru", + location_id: "41", + }, + { + id: 42, + name: "Quadra Poliesportiva", + location_id: "42", + }, + { + id: 43, + name: "RU", + location_id: "43", + }, + { + id: 44, + name: "Restaurante - RU", + location_id: "44", + }, + { + id: 45, + name: "S1 - UAC", + location_id: "45", + }, + { + id: 46, + name: "S10 - UAC", + location_id: "46", + }, + { + id: 47, + name: "S2 - UAC", + location_id: "47", + }, + { + id: 48, + name: "S3 - UAC", + location_id: "48", + }, + { + id: 49, + name: "S4 - UAC", + location_id: "49", + }, + { + id: 50, + name: "S5 - UAC", + location_id: "50", + }, + { + id: 51, + name: "S6 - UAC", + location_id: "51", + }, + { + id: 52, + name: "S7 - UAC", + location_id: "52", + }, + { + id: 53, + name: "S8 - UAC", + location_id: "53", + }, + { + id: 54, + name: "S9 - UAC", + location_id: "54", + }, + { + id: 55, + name: "Sala de Professor - UED", + location_id: "55", + }, + { + id: 56, + name: "UAC", + location_id: "56", + }, + { + id: 57, + name: "UED", + location_id: "57", + }, + { + id: 58, + name: "Outro", + location_id: "00", + }, + ], + colors: [ + { + id: 1, + name: "Amarelo", + color_id: "01", + }, + { + id: 2, + name: "Azul", + color_id: "02", + }, + { + id: 3, + name: "Bege", + color_id: "03", + }, + { + id: 4, + name: "Branco", + color_id: "04", + }, + { + id: 5, + name: "Bronze", + color_id: "05", + }, + { + id: 6, + name: "Cinza", + color_id: "06", + }, + { + id: 7, + name: "Dourado", + color_id: "07", + }, + { + id: 8, + name: "Estampado", + color_id: "08", + }, + { + id: 9, + name: "Laranja", + color_id: "09", + }, + { + id: 10, + name: "Marrom", + color_id: "10", + }, + { + id: 11, + name: "Prata", + color_id: "11", + }, + { + id: 12, + name: "Preto", + color_id: "12", + }, + { + id: 13, + name: "Rosa", + color_id: "13", + }, + { + id: 14, + name: "Verde", + color_id: "14", + }, + { + id: 15, + name: "Vermelho", + color_id: "15", + }, + { + id: 16, + name: "Outra", + color_id: "00", + }, + ], + brands: [ + { + id: 1, + name: "Acer", + brand_id: "01", + }, + { + id: 2, + name: "Adidas", + brand_id: "02", + }, + { + id: 3, + name: "Apple", + brand_id: "03", + }, + { + id: 4, + name: "Asus", + brand_id: "04", + }, + { + id: 5, + name: "Avon", + brand_id: "05", + }, + { + id: 6, + name: "Bic", + brand_id: "06", + }, + { + id: 7, + name: "Dell", + brand_id: "07", + }, + { + id: 8, + name: "Dior", + brand_id: "08", + }, + { + id: 9, + name: "FCTE", + brand_id: "09", + }, + { + id: 10, + name: "FGA", + brand_id: "10", + }, + { + id: 11, + name: "HP", + brand_id: "11", + }, + { + id: 12, + name: "Havaianas", + brand_id: "12", + }, + { + id: 13, + name: "Hay-Ban", + brand_id: "13", + }, + { + id: 14, + name: "Huawei", + brand_id: "14", + }, + { + id: 15, + name: "JBL", + brand_id: "15", + }, + { + id: 16, + name: "Kingston", + brand_id: "16", + }, + { + id: 17, + name: "LG", + brand_id: "17", + }, + { + id: 18, + name: "Lenovo", + brand_id: "18", + }, + { + id: 19, + name: "Levi's", + brand_id: "19", + }, + { + id: 20, + name: "Motorola", + brand_id: "20", + }, + { + id: 21, + name: "New Balance", + brand_id: "21", + }, + { + id: 22, + name: "Nike", + brand_id: "22", + }, + { + id: 23, + name: "Nokia", + brand_id: "23", + }, + { + id: 24, + name: "O Boticário", + brand_id: "24", + }, + { + id: 25, + name: "Oaklay", + brand_id: "25", + }, + { + id: 26, + name: "Puma", + brand_id: "26", + }, + { + id: 27, + name: "RRDD", + brand_id: "27", + }, + { + id: 28, + name: "Razer", + brand_id: "28", + }, + { + id: 29, + name: "Samsung", + brand_id: "29", + }, + { + id: 30, + name: "SanDisk", + brand_id: "30", + }, + { + id: 31, + name: "Sony", + brand_id: "31", + }, + { + id: 32, + name: "Stanley", + brand_id: "32", + }, + { + id: 33, + name: "Tapaware", + brand_id: "33", + }, + { + id: 34, + name: "Toshiba", + brand_id: "34", + }, + { + id: 35, + name: "UnB", + brand_id: "35", + }, + { + id: 36, + name: "Vaio", + brand_id: "36", + }, + { + id: 37, + name: "Vans", + brand_id: "37", + }, + { + id: 38, + name: "Xiaomi", + brand_id: "38", + }, + { + id: 39, + name: "Outra", + brand_id: "00", + }, + ], searchCategory: "", searchLocation: "", searchBrand: "", @@ -311,8 +1175,6 @@ export default { }, mounted() { - this.initializeData(); - if (this.editMode && this.existingItem) { this.item = Object.assign(new Item(), this.existingItem); @@ -362,57 +1224,6 @@ export default { }, }, methods: { - initializeData() { - this.initializeCategories(); - this.initializeLocations(); - this.initializeColors(); - this.initializeBrands(); - }, - - async initializeCategories() { - try { - const result = await api.get("/categories/"); - this.categories = result.data.results; - } catch { - console.log("Erro ao carregar categorias"); - this.alertMessage = "Erro ao carregar categorias."; - this.submitError = true; - } - }, - - async initializeLocations() { - try { - const result = await api.get("/locations/"); - this.locations = result.data.results; - } catch { - console.log("Erro ao carregar locais"); - this.alertMessage = "Erro ao carregar locais."; - this.submitError = true; - } - }, - - async initializeColors() { - try { - const result = await api.get("/colors/"); - this.colors = result.data.results; - } catch { - console.log("Erro ao carregar cores"); - this.alertMessage = "Erro ao carregar cores."; - this.submitError = true; - } - }, - - async initializeBrands() { - try { - const result = await api.get("/brands/"); - this.brands = result.data.results; - } catch { - console.log("Erro ao carregar marcas"); - this.alertMessage = "Erro ao carregar marcas."; - this.submitError = true; - } - }, - async save() { this.item.status = "lost"; diff --git a/web/src/components/Header-Found.vue b/web/src/components/Header-Found.vue index 0641e16d..b0995dcc 100644 --- a/web/src/components/Header-Found.vue +++ b/web/src/components/Header-Found.vue @@ -7,7 +7,7 @@ Voltar
diff --git a/web/src/components/Header-Lost.vue b/web/src/components/Header-Lost.vue index 1960c712..a635e9da 100644 --- a/web/src/components/Header-Lost.vue +++ b/web/src/components/Header-Lost.vue @@ -7,7 +7,7 @@ Voltar
diff --git a/web/src/components/Header-Message.vue b/web/src/components/Header-Message.vue index 2e1caa35..c588d569 100644 --- a/web/src/components/Header-Message.vue +++ b/web/src/components/Header-Message.vue @@ -8,7 +8,7 @@ @click="goBack" :src="LeftArrow" alt="Voltar" - class="w-6 h-6 md:w-8 md:h-8 cursor-pointer" + class="w-[35px] h-35[px] md:w-8 md:h-8 cursor-pointer transform transition duration-300 hover:scale-125" />
diff --git a/web/src/components/Item-Header.vue b/web/src/components/Item-Header.vue index aaf07ef4..b538e912 100644 --- a/web/src/components/Item-Header.vue +++ b/web/src/components/Item-Header.vue @@ -8,7 +8,7 @@ @click="goBack" src="../assets/icons/arrow-left-white.svg" alt="Voltar" - class="w-[30px] h-[30px] text-white cursor-pointer hover:scale-110 transition-transform duration-300 hover:text-laranja" + class="w-[35px] h-[35px] text-white cursor-pointer hover:scale-110 transition-transform duration-300 hover:text-laranja" />
@@ -19,21 +19,19 @@
-
+
diff --git a/web/src/services/api.js b/web/src/services/api.js index e1366c07..6d2bc9dd 100644 --- a/web/src/services/api.js +++ b/web/src/services/api.js @@ -9,7 +9,7 @@ const api = axios.create({ api.interceptors.response.use( (response) => response, (error) => { - if (error.response.status === 401) { + if (error.response?.status === 401) { router.push({ name: "Expired" }); } diff --git a/web/src/services/apiItems.js b/web/src/services/apiItems.js index bccbff05..0286fe2e 100644 --- a/web/src/services/apiItems.js +++ b/web/src/services/apiItems.js @@ -28,15 +28,20 @@ export const fetchFoundItems = async ({ category_name = "", location_name = "", }) => { - const params = { - page, - ...(filtersState.searchQuery && { search: filtersState.searchQuery }), - ...(filtersState.activeCategory && { category_name: filtersState.activeCategory }), - ...(filtersState.activeLocation && { location_name: filtersState.activeLocation }), - }; + try { + const params = { + page, + ...(filtersState.searchQuery && { search: filtersState.searchQuery }), + ...(filtersState.activeCategory && { category_name: filtersState.activeCategory }), + ...(filtersState.activeLocation && { location_name: filtersState.activeLocation }), + }; - const response = await api.get(`${API_BASE_URL}/found/`, { params }); - return response.data; + const response = await api.get(`${API_BASE_URL}/found/`, { params }); + return response.data; + } catch (error) { + console.error("Erro ao buscar itens encontrados:", error); + throw error; + } }; export const fetchMyItemsFound = async () => { @@ -52,7 +57,7 @@ export const fetchMyItemsFound = async () => { export const fetchMyItemsLost = async () => { try { const response = await api.get(`${API_BASE_URL}/lost/my-items/`); - return response.data; + return response.data; } catch (error) { console.error("Erro ao buscar itens encontrados:", error); throw error; diff --git a/web/src/views/ListItem.vue b/web/src/views/ListItem.vue index 4ad45424..8fabda58 100644 --- a/web/src/views/ListItem.vue +++ b/web/src/views/ListItem.vue @@ -1,14 +1,17 @@