<?php

namespace App\Filament\Resources\TenantResource\Schemas;

use App\Models\Tenant;
use Filament\Infolists\Components\IconEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class TenantInfolist
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Section::make(__('admin.tenants.sections.profile'))
                ->columns(3)
                ->schema([
                    TextEntry::make('name')->label(__('admin.tenants.fields.name')),
                    TextEntry::make('slug')->label(__('admin.tenants.fields.slug')),
                    TextEntry::make('contact_email')->label(__('admin.tenants.fields.contact_email')),
                    TextEntry::make('user.full_name')
                        ->label(__('admin.tenants.fields.owner'))
                        ->state(fn (Tenant $record) => $record->user?->full_name ?? '—'),
                    TextEntry::make('paddle_customer_id')
                        ->label('Paddle Customer ID')
                        ->placeholder('—'),
                    TextEntry::make('total_revenue')
                        ->label(__('admin.tenants.fields.total_revenue'))
                        ->money('EUR'),
                    TextEntry::make('active_reseller_package_id')
                        ->label(__('admin.tenants.fields.active_reseller_package'))
                        ->state(fn (Tenant $record) => $record->activeResellerPackage?->name ?? '—'),
                    TextEntry::make('remaining_events')
                        ->label(__('admin.tenants.fields.remaining_events'))
                        ->state(fn (Tenant $record) => $record->activeResellerPackage?->remaining_events ?? 0),
                    TextEntry::make('package_expires_at')
                        ->label(__('admin.tenants.fields.package_expires_at'))
                        ->state(fn (Tenant $record) => $record->activeResellerPackage?->expires_at)
                        ->dateTime(),
                ]),
            Section::make(__('admin.tenants.sections.lifecycle'))
                ->columns(3)
                ->schema([
                    IconEntry::make('is_active')
                        ->label(__('admin.tenants.fields.is_active'))
                        ->boolean(),
                    IconEntry::make('is_suspended')
                        ->label(__('admin.tenants.fields.is_suspended'))
                        ->boolean(),
                    TextEntry::make('subscription_expires_at')
                        ->label(__('admin.tenants.fields.subscription_expires_at'))
                        ->dateTime()
                        ->placeholder('—'),
                    TextEntry::make('pending_deletion_at')
                        ->label(__('admin.tenants.fields.pending_deletion_at'))
                        ->dateTime()
                        ->placeholder('—'),
                    TextEntry::make('deletion_warning_sent_at')
                        ->label(__('admin.tenants.fields.deletion_warning_sent_at'))
                        ->dateTime()
                        ->placeholder('—'),
                    TextEntry::make('anonymized_at')
                        ->label(__('admin.tenants.fields.anonymized_at'))
                        ->dateTime()
                        ->placeholder('—'),
                ]),
        ]);
    }
}
