{"id":5695,"date":"2025-04-22T11:47:58","date_gmt":"2025-04-22T14:47:58","guid":{"rendered":"https:\/\/alagev.org\/?page_id=5695"},"modified":"2025-05-03T18:00:17","modified_gmt":"2025-05-03T21:00:17","slug":"primeiro-acesso","status":"publish","type":"page","link":"https:\/\/alagev.org\/en\/primeiro-acesso\/","title":{"rendered":"Primeiro Acesso"},"content":{"rendered":"<div data-elementor-type=\"wp-page\" data-elementor-id=\"5695\" class=\"elementor elementor-5695\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-994762f e-flex e-con-boxed e-con e-parent\" data-id=\"994762f\" data-element_type=\"container\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[],&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-fef869c e-con-full e-flex e-con e-child\" data-id=\"fef869c\" data-element_type=\"container\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t<div class=\"elementor-element elementor-element-7501042 e-con-full e-flex e-con e-child\" data-id=\"7501042\" data-element_type=\"container\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[],&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t<div class=\"elementor-element elementor-element-e8192bf e-con-full jedv-enabled--yes e-flex e-con e-child\" data-id=\"e8192bf\" data-element_type=\"container\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d02fcf1 elementor-widget elementor-widget-heading\" data-id=\"d02fcf1\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\">Ative seu cadastro<\/h1>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-19910c9 elementor-widget__width-initial elementor-widget elementor-widget-shortcode\" data-id=\"19910c9\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\">    <div id=\"primeiro-acesso-wrapper\">\n\t\t\n\n        <div id=\"status-primeiro-acesso\" style=\"margin-bottom: 20px; color: red;\"><\/div>\n\n        <form id=\"form-verifica-email\" style=\"margin-bottom: 20px;\" action=\"\">\n            <input type=\"email\" id=\"email_check\" placeholder=\"Informe seu e-mail\" required>\n            <button type=\"button\" id=\"btn-enviar-codigo\">Enviar c\u00f3digo<\/button>\n        <input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form>\n\n        <form id=\"form-verifica-codigo\" style=\"display:none; margin-bottom: 20px; width: 100%\" action=\"\">\n            <input type=\"text\" id=\"codigo_verificacao\" placeholder=\"C\u00f3digo recebido por e-mail\" required>\n            <button type=\"submit\">Validar c\u00f3digo<\/button>\n        <input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form>\n\n        <form id=\"form-primeiro-acesso\" style=\"display:none;\" action=\"\">\n            <div id=\"dados-representante\"><\/div>\n            <input type=\"hidden\" name=\"email\" id=\"email\" readonly>\n\n            <label>Senha:\n                <input type=\"password\" name=\"senha\" id=\"senha\" required>\n            <\/label>\n\n            <label>Confirmar Senha:\n                <input type=\"password\" name=\"confirmar_senha\" id=\"confirmar_senha\" required>\n            <\/label>\n\n            <label class=\"checkbox-field\" style=\"display: block;\"><input type=\"checkbox\" id=\"aceite\" required>Li e aceito o <a target=\"_blank\" href=\"https:\/\/drive.google.com\/file\/d\/1iFHDMl4tTnuvExJ5EXnBhW6yDkRTT_Ud\/view\" rel=\"noopener\">regimento das comunidades<\/a><\/label>\n\n            <button type=\"submit\">Ativar conta<\/button>\n        <input type=\"hidden\" name=\"trp-form-language\" value=\"en\"\/><\/form>\n    <\/div>\n\n    <script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jquery.mask\/1.14.16\/jquery.mask.min.js\"><\/script>\n<script>\ndocument.addEventListener('DOMContentLoaded', function () {\n    const emailInput = document.getElementById('email_check');\n    const btnEnviarCodigo = document.getElementById('btn-enviar-codigo');\n    const formCodigo = document.getElementById('form-verifica-codigo');\n    const formAccess = document.getElementById('form-primeiro-acesso');\n    const emailHidden = document.getElementById('email');\n    const statusDiv = document.getElementById('status-primeiro-acesso');\n    const dadosDiv = document.getElementById('dados-representante');\n\n    btnEnviarCodigo.addEventListener('click', function () {\n        const email = emailInput.value.trim();\n        if (!email) return;\n\n        statusDiv.innerText = 'Enviando c\u00f3digo...';\n        statusDiv.style.color = '';\n\n        fetch('https:\/\/alagev.org\/wp-admin\/admin-ajax.php', {\n            method: 'POST',\n            headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n            body: new URLSearchParams({\n                action: 'enviar_codigo_validacao',\n                email: email\n            })\n        }).then(res => res.json())\n        .then(data => {\n            if (data.success) {\n                statusDiv.style.color = 'green';\n                statusDiv.innerText = 'C\u00f3digo enviado para o e-mail.';\n                formCodigo.style.display = 'block';\n                emailHidden.value = email;\n            } else {\n                statusDiv.style.color = 'red';\n                statusDiv.innerText = data.message;\n            }\n        });\n    });\n\n    document.getElementById('form-verifica-codigo').addEventListener('submit', function (e) {\n        e.preventDefault();\n        const codigo = document.getElementById('codigo_verificacao').value.trim();\n        const email = emailHidden.value;\n\n        fetch('https:\/\/alagev.org\/wp-admin\/admin-ajax.php', {\n            method: 'POST',\n            headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n            body: new URLSearchParams({\n                action: 'validar_codigo_verificacao',\n                email: email,\n                codigo: codigo\n            })\n        }).then(res => res.json())\n        .then(data => {\n            if (data.success) {\n                dadosDiv.innerHTML = data.html;\n                formAccess.style.display = 'block';\n                statusDiv.innerText = '';\n                document.getElementById('form-verifica-codigo').style.display = 'none';\n                document.getElementById('email').value = email;\n\n                \/\/ Aplica m\u00e1scaras aos campos din\u00e2micos\n                jQuery(function ($) {\n                    $('#campo-cpf').mask('000.000.000-00');\n                });\n\n                \/\/ Se for apenas redefinir senha, oculta os campos extras\n                if (data.modo === 'senha') {\n                    const camposExtras = dadosDiv.querySelectorAll('label');\n                    camposExtras.forEach(el => el.style.display = 'none');\n                }\n            } else {\n                statusDiv.innerText = data.message;\n                statusDiv.style.color = 'red';\n            }\n        });\n    });\n\n    formAccess.addEventListener('submit', function (e) {\n        e.preventDefault();\n        const senha = document.getElementById('senha').value;\n        const confirmar = document.getElementById('confirmar_senha').value;\n        const aceite = document.getElementById('aceite').checked;\n        if (senha !== confirmar) return alert('As senhas n\u00e3o coincidem!');\n        if (!aceite) return alert('Voc\u00ea deve aceitar os termos.');\n\n        const formData = new FormData(formAccess);\n        formData.append('action', 'criar_primeiro_acesso');\n\n        fetch('https:\/\/alagev.org\/wp-admin\/admin-ajax.php', {\n            method: 'POST',\n            body: formData\n        }).then(res => res.json())\n        .then(data => {\n            if (data.success) {\n                alert('Conta ativada com sucesso!');\n                window.location.href = 'https:\/\/alagev.org\/login';\n            } else {\n                alert(data.message || 'Erro ao salvar os dados.');\n            }\n        }).catch(err => {\n            alert('Erro ao salvar os dados.');\n        });\n    });\n});\n<\/script>\n\n\n\n\n<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Ative seu cadastro<\/p>","protected":false},"author":9,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5695","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/pages\/5695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/comments?post=5695"}],"version-history":[{"count":50,"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/pages\/5695\/revisions"}],"predecessor-version":[{"id":6751,"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/pages\/5695\/revisions\/6751"}],"wp:attachment":[{"href":"https:\/\/alagev.org\/en\/wp-json\/wp\/v2\/media?parent=5695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}