from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from drf_spectacular.utils import extend_schema
from configuration.models import SiteConfiguration

class CurrencyInfoView(APIView):
    """
    Get current site currency and display information.
    """
    
    @extend_schema(
        summary="Get site currency information",
        description="Returns the current site currency and available options",
        tags=["configuration"]
    )
    def get(self, request):
        config = SiteConfiguration.get_solo()
        
        currency_symbols = {
            'EUR': '€',
            'CZK': 'Kč', 
            'USD': '$',
            'GBP': '£',
            'PLN': 'zł',
            'HUF': 'Ft',
            'SEK': 'kr',
            'DKK': 'kr',
            'NOK': 'kr',
            'CHF': 'Fr'
        }
        
        return Response({
            'current_currency': config.currency,
            'currency_symbol': currency_symbols.get(config.currency, config.currency),
            'currency_name': dict(SiteConfiguration.CURRENCY.choices)[config.currency],
            'available_currencies': [
                {
                    'code': choice[0],
                    'name': choice[1],
                    'symbol': currency_symbols.get(choice[0], choice[0])
                }
                for choice in SiteConfiguration.CURRENCY.choices
            ]
        })