feat: open webhook response (HTML/PDF) in new window, update success text

- Replace fetch() with hidden form POST + target='_blank' so the webhook's
  auto-download HTML page opens in a new tab/window
- Send form-encoded fields (not JSON) since webhook expects POST form data
- Update success message: 'A new window has opened with your personalized
  Odoo project plan. The download will start automatically after research
  is complete.'
- Remove dead bizDownloadBtn references (button no longer needed)
This commit is contained in:
2026-08-20 15:28:25 +00:00
parent 87874d0f34
commit b2d2677a34
2 changed files with 31 additions and 28 deletions
+1 -2
View File
@@ -418,8 +418,7 @@
<div class="biz-success" id="bizSuccess" style="display:none"> <div class="biz-success" id="bizSuccess" style="display:none">
<i class="fas fa-check-circle"></i> <i class="fas fa-check-circle"></i>
<h3>Your project plan is being prepared</h3> <h3>Your project plan is being prepared</h3>
<p>Download your personalized PDF below — a custom Odoo implementation roadmap tailored to your business.</p> <p>A new window has opened with your personalized Odoo project plan. The download will start automatically after research is complete.</p>
<a class="btn btn-brass btn-lg" id="bizDownloadBtn" style="display:none" download>Download Your Project Plan &darr;</a>
</div> </div>
</div> </div>
</section> </section>
+30 -26
View File
@@ -583,7 +583,6 @@ var si = 0,
var form = document.getElementById('bizForm'); var form = document.getElementById('bizForm');
if (!form) return; if (!form) return;
var success = document.getElementById('bizSuccess'); var success = document.getElementById('bizSuccess');
var downloadBtn = document.getElementById('bizDownloadBtn');
var submitBtn = document.getElementById('bizSubmitBtn'); var submitBtn = document.getElementById('bizSubmitBtn');
form.addEventListener('submit', function (e) { form.addEventListener('submit', function (e) {
@@ -600,30 +599,35 @@ var si = 0,
submitBtn.textContent = 'Generating...'; submitBtn.textContent = 'Generating...';
submitBtn.disabled = true; submitBtn.disabled = true;
fetch('https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/report', { /* Create a hidden form to POST to the webhook and open response in new window */
method: 'POST', var f = document.createElement('form');
headers: { 'Content-Type': 'application/json' }, f.method = 'POST';
body: JSON.stringify({ f.action = 'https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/report';
description: description, f.target = '_blank';
goals: goals, f.style.display = 'none';
challenges: challenges,
has_homepage: hasHomepage, var fields = {
uses_odoo: usesOdoo, description: description,
has_developer: hasDeveloper goals: goals,
}) challenges: challenges,
}) has_homepage: hasHomepage ? 'true' : 'false',
.then(function (r) { return r.json().catch(function () { return {}; }); }) uses_odoo: usesOdoo ? 'true' : 'false',
.then(function (data) { has_developer: hasDeveloper ? 'true' : 'false'
form.style.display = 'none'; };
success.style.display = 'block'; for (var key in fields) {
if (data.download_url) { var inp = document.createElement('input');
downloadBtn.href = data.download_url; inp.type = 'hidden';
downloadBtn.style.display = 'inline-block'; inp.name = key;
} inp.value = fields[key];
}) f.appendChild(inp);
.catch(function () { }
submitBtn.textContent = 'Generate My Project Plan \u2192';
submitBtn.disabled = false; document.body.appendChild(f);
}); f.submit();
f.remove();
/* Show success message — download will start automatically */
form.style.display = 'none';
success.style.display = 'block';
}); });
})(); })();