<?php

namespace App\Filament\Resources\Facilities\Tables;

use Filament\Tables\Table;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\BadgeColumn;
use Filament\Actions\EditAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;

class FacilitiesTable
{
    public static function configure(Table $table): Table
    {
        return $table
            ->columns([
                // 1. Kolom Khusus Preview Icon
                TextColumn::make('icon_preview')
                    ->label('Preview')
                    ->state(fn($record) => $record->icon) // Mengambil data dari kolom 'icon'
                    ->icon(fn(string $state): string => $state) // Memunculkan gambar
                    ->formatStateUsing(fn() => '') // Menyembunyikan teks, sehingga sisa gambarnya saja
                    ->alignCenter(),

                // 2. Kolom Khusus Kode Teks
                TextColumn::make('icon')
                    ->label('Kode Icon')
                    ->searchable(),

                TextColumn::make('name')
                    ->label('Nama Fasilitas')
                    ->searchable(),

                BadgeColumn::make('category')
                    ->label('Kategori')
                    ->colors([
                        'primary' => 'kamar',
                        'success' => 'properti',
                    ])
                    ->sortable(),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }
}
