$(document).ready(function(){
    checkManifestStatus();
});

function checkManifestStatus(){
    $.get("/signed-manifest/status", function (response) {
        if(!response?.is_signed && response.redirect !== null){
            Swal.fire({
                title: translateAndReplace('iframes.manifiesto.swal.title'),
                icon: 'info',
                html: `
                    <div class="text-justify px-1">
                        <p>${translateAndReplace('iframes.manifiesto.swal.context')}</p>
                        <p>${translateAndReplace('iframes.manifiesto.swal.notice')}</p>

                        <ul class="mt-3">
                            ${translateAndReplace('iframes.manifiesto.swal.results')}
                        </ul>
                    </div>

                    <small><i>
                        ${translateAndReplace('iframes.manifiesto.swal.comment')}
                    </i></small>
                `,
                width: '500px',
                confirmButtonColor: '#0d6889',
                confirmButtonText: translateAndReplace('common_actions.sign'),
                showCancelButton: true,
                cancelButtonText: translateAndReplace('common_actions.postpone'),
            }).then((result) => {
                if(result.isConfirmed)
                window.location.href = '/signed-manifest';
            });
        }
    });
}
