<?php

namespace App\Filament\Resources\SourcePaperResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Actions\ViewAction;

class PaperPartsRelationManager extends RelationManager
{
    protected static string $relationship = 'parts';

    protected static ?string $recordTitleAttribute = 'title';

    public function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('order')->label('顺序')->sortable(),
                Tables\Columns\TextInputColumn::make('title')->label('区块标题')->searchable(),
                Tables\Columns\SelectColumn::make('type')
                    ->label('题型')
                    ->options([
                        'choice' => '选择题',
                        'fill' => '填空题',
                        'answer' => '解答题',
                        'mixed' => '混合',
                    ]),
                Tables\Columns\TextInputColumn::make('question_count')->label('题量(人工)')->type('number'),
                Tables\Columns\TextColumn::make('candidates_count')
                    ->counts('candidates')
                    ->label('题量(自动)'),
            ])
            ->actions([
                ViewAction::make(),
            ])
            ->headerActions([]);
    }
}
