<?php

namespace App\Http\Controllers;

use App\Models\LegalDocument;
use App\Support\LegalDocumentHtml;
use Inertia\Inertia;
use Inertia\Response;

class LegalDocumentController extends Controller
{
    public function show(LegalDocument $legalDocument): Response
    {
        return Inertia::render('legal/show', [
            'document' => [
                'title' => $legalDocument->title,
                'body' => LegalDocumentHtml::sanitize($legalDocument->body ?? ''),
                'updated_at' => $legalDocument->updated_at?->toIso8601String(),
            ],
            'links' => LegalDocument::authLinks(),
        ]);
    }
}
