<?php

namespace GriffinForms\Admin\App\Html\Modals;

use GriffinForms\Traits\Singleton;
use GriffinForms\Admin\App\Html\Modals\FormNotifications\Markup;
use GriffinForms\Admin\App\Html\Modals\FormNotifications\Requests;
use GriffinForms\Admin\App\Html\Modals\FormNotifications\Responses;
use GriffinForms\Admin\App\Html\Modals\FormNotifications\Scripts;

class FormNotifications extends \GriffinForms\Admin\App\Html\Modals\Format
{
    use Singleton;
    use Markup;
    use Requests;
    use Responses;
    use Scripts;

    protected $has_footer         = true;
    protected $modal_dialog_classes = ['modal-xl'];

    protected function getModalTitle()
    {
        return __('Form Notifications', 'griffinforms-form-builder');
    }

    protected function renderModalBodyHtml()
    {
        $this->renderNotificationsBody();
    }

    public function getBodyHtml(): string
    {
        ob_start();
        $this->renderNotificationsBody();
        return (string) ob_get_clean();
    }

    public function getModalJs()
    {
        // Values are PHP-rendered at page load — no modal-open AJAX fetch needed.
    }

    public function getJs()
    {
        parent::getJs();
        $this->renderScripts();
    }

    private function __construct()
    {
        add_action('wp_ajax_gf_get_notifications_html', [$this, 'getNotificationsHtml']);
        $this->setAll();
    }
}
