<?php

namespace App\Exports;

use App\Models\PurchaseHistory;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;

class PurchaseHistoryExporter extends Exporter
{
    public static function getModel(): string
    {
        return PurchaseHistory::class;
    }

    public static function getColumns(): array
    {
        return [
            ExportColumn::make('tenant.name')->label(__('admin.purchase_history.fields.tenant')),
            ExportColumn::make('package_id')->label(__('admin.purchase_history.fields.package')),
            ExportColumn::make('credits_added')->label(__('admin.purchase_history.fields.credits')),
            ExportColumn::make('price')->label(__('admin.purchase_history.fields.price')),
            ExportColumn::make('currency')->label(__('admin.purchase_history.fields.currency')),
            ExportColumn::make('platform')->label(__('admin.purchase_history.fields.platform')),
            ExportColumn::make('transaction_id')->label(__('admin.purchase_history.fields.transaction_id')),
            ExportColumn::make('purchased_at')->label(__('admin.purchase_history.fields.purchased_at')),
        ];
    }

    public static function getCompletedNotificationBody(Export $export): string
    {
        return __('admin.purchase_history.export_success', [
            'count' => $export->successful_rows,
        ]);
    }
}
