From fe7d6199bc16f8bd5707bff77cd5ffe4998a8269 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Fri, 1 Sep 2023 17:34:37 +0300 Subject: [PATCH] Added prices calculation --- cp/resources/views/admin/domains/create.twig | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/cp/resources/views/admin/domains/create.twig b/cp/resources/views/admin/domains/create.twig index 3b43f3a..ab137ae 100644 --- a/cp/resources/views/admin/domains/create.twig +++ b/cp/resources/views/admin/domains/create.twig @@ -29,7 +29,7 @@
Your Domain Name
- +
@@ -38,6 +38,11 @@ 1 Year + + +
Contacts
@@ -180,6 +185,35 @@ document.addEventListener("DOMContentLoaded", function() { dnssecData.style.display = 'none'; } }); + + const domainInput = document.getElementById('domainName'); + const yearInput = document.getElementById('registrationYears'); + const priceDisplay = document.getElementById('domainPriceDisplay'); + const priceValue = document.getElementById('domainPrice'); + + // Simulate an API request + function getDomainPrice(domain, years) { + // For now, we'll just return a dummy price. In a real scenario, you'd call your API here. + return new Promise(resolve => { + setTimeout(() => { + resolve(10.00 * years); // Example: Price is $10/year + }, 500); // Simulating API delay + }); + } + + function updatePrice() { + if (domainInput.value) { + getDomainPrice(domainInput.value, yearInput.value).then(price => { + priceValue.innerText = `$${price.toFixed(2)}`; + priceDisplay.style.display = 'block'; + }); + } else { + priceDisplay.style.display = 'none'; + } + } + + domainInput.addEventListener('input', updatePrice); + yearInput.addEventListener('input', updatePrice); }); {% endblock %} \ No newline at end of file