schema([
// AI Review Summary (if available)
Section::make('AI Review')
->icon('heroicon-o-sparkles')
->description('Automated compliance check results')
->schema([
Placeholder::make('ai_summary')
->label('')
->content(function () {
$extra = json_decode($this->record->extra_data ?? '{}', true);
$ai = $extra['ai_review'] ?? null;
if (!$ai) {
return new HtmlString(
'
' .
'
No AI review has been run yet. Click "Run AI Review" above to check this fundraiser.
' .
'
'
);
}
$decision = $ai['decision'] ?? 'unknown';
$confidence = round(($ai['confidence'] ?? 0) * 100);
$summary = $ai['summary'] ?? '';
$reasons = $ai['reasons'] ?? [];
$flags = $ai['flags'] ?? [];
$colorMap = ['approve' => 'green', 'reject' => 'red', 'review' => 'amber'];
$iconMap = ['approve' => '✓', 'reject' => '✗', 'review' => '?'];
$labelMap = ['approve' => 'Safe to Approve', 'reject' => 'Should Be Rejected', 'review' => 'Needs Your Judgment'];
$color = $colorMap[$decision] ?? 'gray';
$icon = $iconMap[$decision] ?? '?';
$label = $labelMap[$decision] ?? 'Unknown';
$html = "";
$html .= "
";
$html .= "
{$icon}";
$html .= "
";
$html .= "
{$label}
";
$html .= "
Confidence: {$confidence}%
";
$html .= "
";
$html .= "
{$summary}
";
if (!empty($reasons)) {
$html .= "
";
foreach ($reasons as $reason) {
$html .= "- • {$reason}
";
}
$html .= "
";
}
if (!empty($flags)) {
$html .= "
";
foreach ($flags as $flag) {
$html .= "{$flag}";
}
$html .= "
";
}
$html .= "
";
return new HtmlString($html);
}),
])
->collapsible(),
// Fundraiser Details
Section::make('Fundraiser Details')
->icon('heroicon-o-document-text')
->description('What the supporter submitted')
->schema([
Fieldset::make('Basic Info')->schema([
Placeholder::make('appeal_name')
->label('Fundraiser Name')
->content(fn () => $this->record->appeal?->name ?? '—'),
Placeholder::make('appeal_owner')
->label('Created By')
->content(fn () => ($this->record->appeal?->user?->name ?? '—') . ' (' . ($this->record->appeal?->user?->email ?? '') . ')'),
Placeholder::make('appeal_type')
->label('Cause')
->content(fn () => $this->record->appeal?->donationType?->display_name ?? '—'),
Placeholder::make('appeal_target')
->label('Fundraising Goal')
->content(fn () => '£' . number_format($this->record->appeal?->amount_to_raise ?? 0, 0)),
Placeholder::make('appeal_status')
->label('Current Status')
->content(function () {
$status = $this->record->status;
return match ($status) {
'pending' => new HtmlString('' . ($this->record->appeal?->story ?? 'No story provided') . '
'
))
->columnSpanFull(),
Placeholder::make('appeal_image')
->label('Cover Image')
->content(function () {
$url = $this->record->appeal?->getPictureUrl();
if (!$url) return new HtmlString('