diff --git a/api/migrations/0048_alter_order_reference.py b/api/migrations/0048_alter_order_reference.py new file mode 100644 index 000000000..cf8fa0769 --- /dev/null +++ b/api/migrations/0048_alter_order_reference.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.6 on 2024-06-29 14:07 + +import api.models.order +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0047_notification'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='reference', + field=models.UUIDField(default=api.models.order.custom_uuid, editable=False), + ), + ] diff --git a/api/serializers.py b/api/serializers.py index e5d777546..74cf125f7 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -491,10 +491,17 @@ class Meta: class ListNotificationSerializer(serializers.ModelSerializer): + status = serializers.SerializerMethodField( + help_text="The `status` of the order when the notification was trigered", + ) class Meta: model = Notification fields = ("title", "description", "order_id", "status") + def get_status(self, notification) -> int: + return notification.order.status + + class OrderPublicSerializer(serializers.ModelSerializer): maker_nick = serializers.CharField(required=False) diff --git a/api/views.py b/api/views.py index bd7ddd89d..a03dbd33d 100644 --- a/api/views.py +++ b/api/views.py @@ -761,11 +761,7 @@ def get(self, request, format=None): notification_data = [] for notification in queryset: data = self.serializer_class(notification).data - data["title"] = str(notification.title) - data["description"] = str(notification.description) data["order_id"] = notification.order.id - data["status"] = notification.order.status - notification_data.append(data) return Response(notification_data, status=status.HTTP_200_OK) diff --git a/docs/assets/schemas/api-latest.yaml b/docs/assets/schemas/api-latest.yaml index 8047a0e25..49d46997e 100644 --- a/docs/assets/schemas/api-latest.yaml +++ b/docs/assets/schemas/api-latest.yaml @@ -1106,8 +1106,13 @@ components: order_id: type: integer readOnly: true + status: + type: integer + readOnly: true + description: The `status` of the order when the notification was trigered required: - order_id + - status ListOrder: type: object properties: diff --git a/frontend/src/components/MakerForm/AutocompletePayments.tsx b/frontend/src/components/MakerForm/AutocompletePayments.tsx index 642151e35..9d23504d0 100644 --- a/frontend/src/components/MakerForm/AutocompletePayments.tsx +++ b/frontend/src/components/MakerForm/AutocompletePayments.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { useAutocomplete } from '@mui/base/useAutocomplete'; +import useAutocomplete from '@mui/base/useAutocomplete'; import { styled } from '@mui/material/styles'; import { Button,