import React from 'react' import { Head, router, usePage } from '@inertiajs/react' import AdminLayout from '../../../Layouts/AdminLayout' function formatTimestamp(value) { if (!value) { return 'Not finished' } return new Intl.DateTimeFormat('en-GB', { dateStyle: 'medium', timeStyle: 'short', }).format(new Date(value)) } function SummaryCard({ label, value, tone }) { const tones = { red: 'border-rose-400/15 bg-rose-500/10 text-rose-100', orange: 'border-orange-400/15 bg-orange-500/10 text-orange-100', yellow: 'border-amber-400/15 bg-amber-500/10 text-amber-100', blue: 'border-sky-400/15 bg-sky-500/10 text-sky-100', slate: 'border-white/[0.07] bg-white/[0.02] text-white', } return (

{label}

{value}

) } function RiskBadge({ label }) { const tone = label === 'Critical' ? 'border-rose-400/20 bg-rose-500/10 text-rose-200' : label === 'High' ? 'border-orange-400/20 bg-orange-500/10 text-orange-200' : label === 'Medium' ? 'border-amber-400/20 bg-amber-500/10 text-amber-200' : label === 'Low' ? 'border-sky-400/20 bg-sky-500/10 text-sky-200' : 'border-emerald-400/20 bg-emerald-500/10 text-emerald-200' return {label} } export default function SecurityReportIndex({ latest, reports, canRunScan }) { const flash = usePage().props.flash ?? {} const items = reports?.data ?? [] const runScan = () => { router.post('/moderation/system/security-report/run') } return (
{flash.success ? (
{flash.success}
) : null} {latest ? ( <>

Latest scan

{latest.status}
{canRunScan ? ( ) : null}
Started
{formatTimestamp(latest.started_at)}
Finished
{formatTimestamp(latest.finished_at)}
Triggered by
{latest.triggered_by || 'Unknown'}
Composer outdated
{latest.composer_outdated_count}
npm outdated
{latest.npm_outdated_count}
Requested by
{latest.user ? (latest.user.username ? `@${latest.user.username}` : latest.user.name) : 'System'}
View Details
) : (

No security report has been generated yet.

Run php artisan security:scan --notify or use the manual scan button after the queue worker is running.

{canRunScan ? ( ) : null}
)}

Scan History

{items.length === 0 ? ( ) : items.map((report) => ( ))}
ID Finished Status Risk Critical High Medium Low Outdated
No reports recorded yet.
#{report.id} {formatTimestamp(report.finished_at)} {report.status} {report.total_critical} {report.total_high} {report.total_medium} {report.total_low} Composer: {report.composer_outdated_count}, npm: {report.npm_outdated_count} Details
{reports?.last_page > 1 ? (

Showing {reports.from}–{reports.to} of {reports.total} reports

{reports.links.map((link, index) => ( link.url ? (
) : null}
) }