<?php

namespace App\Filament\App\Widgets;

use App\Models\FollowUp;
use Filament\Facades\Filament;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;

class UpcomingFollowUpsTable extends TableWidget
{
    protected int|string|array $columnSpan = 5;

    public function table(Table $table): Table
    {
        return $table
            ->query(
                FollowUp::query()
                    ->where('user_id', Filament::auth()->id())
                    ->where('status', 'pending')
                    ->orderBy('followup_date')
                    ->limit(8)
            )
            ->heading('Upcoming Follow-ups')
            ->description('Your next reminders and payment follow-ups')
            ->columns([
                TextColumn::make('name')
                    ->label('Contact')
                    ->searchable(),
                TextColumn::make('amount')
                    ->money('INR'),
                TextColumn::make('type')
                    ->badge(),
                TextColumn::make('priority')
                    ->badge(),
                TextColumn::make('followup_date')
                    ->label('Due')
                    ->dateTime()
                    ->sortable(),
            ]);
    }
}
