<?php

namespace App\Livewire\Admin;

use LivewireUI\Modal\ModalComponent;

/**
 * Confirmation before .env — the file that holds every credential in the
 * system — is overwritten (R23).
 *
 * The content being written lives only in Integrations' own $envContent; this
 * modal never sees it and cannot mutate anything itself. Confirming
 * dispatches back to the page component, whose saveEnv() keeps its own
 * guardSecrets() (secrets.manage + a recently confirmed password) unchanged —
 * same pattern as ConfirmSaveSecret/ConfirmForgetSecret.
 */
class ConfirmSaveEnv extends ModalComponent
{
    public function mount(): void
    {
        $this->authorize('secrets.manage');
    }

    public function confirm(): void
    {
        $this->authorize('secrets.manage');
        $this->dispatch('env-save-confirmed');
        $this->closeModal();
    }

    public function render()
    {
        return view('livewire.admin.confirm-save-env');
    }
}
