from django.contrib import admin
from .models import Offer, OfferLine


class OfferLineInline(admin.TabularInline):
    model = OfferLine
    extra = 1


@admin.register(Offer)
class OfferAdmin(admin.ModelAdmin):
    list_display = ['title', 'status', 'team_uuid', 'location_name', 'created_at']
    list_filter = ['status', 'created_at']
    search_fields = ['title', 'description']
    inlines = [OfferLineInline]


@admin.register(OfferLine)
class OfferLineAdmin(admin.ModelAdmin):
    list_display = ['product_name', 'quantity', 'unit', 'price_per_unit', 'currency']
    list_filter = ['category_name']
    search_fields = ['product_name']
